summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2013-11-11 15:51:53 -0500
committerKyle Meyer <kyle@kyleam.com>2013-11-11 15:51:53 -0500
commit9e5bce94e18a933e44efa39dfdac1bde5442e9f0 (patch)
tree9e71dc21f70bb816e21d83e67a65cba76e94ecb6
parent8f90cdbe297ef532dda9a7b77559f4ecfa4f5b34 (diff)
downloademacs.d-9e5bce94e18a933e44efa39dfdac1bde5442e9f0.tar.gz
Toggle variable for save hook clean up
Useful for making changes to files from other people's projects
-rw-r--r--init/km-func.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/init/km-func.el b/init/km-func.el
index bf98552..e41bfcb 100644
--- a/init/km-func.el
+++ b/init/km-func.el
@@ -1,12 +1,27 @@
;; http://whattheemacsd.com/
;; whitespace cleanup
+;; buffer-specific prevention modified from
+;; http://stackoverflow.com/questions/14913398/
+;; in-emacs-how-do-i-save-without-running-save-hooks
+(defvar km/prevent-cleanup nil
+ "If set, `km/cleanup-buffer' does not perform clean up on save")
+
+(defun km/toggle-prevent-cleanup ()
+ "Toggle state of `km/prevent-cleanup'"
+ (interactive)
+ (let ((state t))
+ (when km/prevent-cleanup
+ (setq state nil))
+ (set (make-local-variable 'km/prevent-cleanup) state)))
+
(defun km/cleanup-buffer ()
(interactive)
- (unless (equal major-mode 'makefile-gmake-mode)
- (untabify (point-min) (point-max)))
- (delete-trailing-whitespace)
- (set-buffer-file-coding-system 'utf-8))
+ (unless km/prevent-cleanup
+ (unless (equal major-mode 'makefile-gmake-mode)
+ (untabify (point-min) (point-max)))
+ (delete-trailing-whitespace)
+ (set-buffer-file-coding-system 'utf-8)))
(add-hook 'before-save-hook 'km/cleanup-buffer)
(defun km/rename-current-buffer-file ()