Created
July 19, 2012 20:37
-
-
Save richlowe/3146623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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