Skip to content

Instantly share code, notes, and snippets.

@richlowe
Created July 19, 2012 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richlowe/3146623 to your computer and use it in GitHub Desktop.
Save richlowe/3146623 to your computer and use it in GitHub Desktop.
(defun maybe-squash-sccs-keywords ()
"If the current buffer contains SCCS keywords, ask the user whether they should be deleted.
This is designed to be in `write-file-functions'.
If the prompt is answered affirmatively, the line containing the
keywords is deleted, whitespace is compressed, point is left in
the gap and the save is aborted. Otherwise the buffer is saved
as usual."
(interactive)
(let ((loc (save-excursion
(goto-char (point-min))
(search-forward "%Z%%M%" nil t))))
(when (and loc
(memq major-mode squash-sccs-keyword-modes)
(y-or-n-p "File contains SCCS keywords. Delete them?"))
(goto-char loc)
(beginning-of-line)
(kill-line)
(delete-blank-lines)
t)))
(add-hook 'write-file-functions 'maybe-squash-sccs-keywords)
(setf squash-sccs-keyword-modes '(c-mode c++-mode asm-mode
java-mode perl-mode
python-mode
shell-script-mode
makefile-bsdmake-mode
makefile-gmake-mode
nroff-mode nxml-mode
xml-mode))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment