summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-01-22 23:05:36 -0500
committerKyle Meyer <kyle@kyleam.com>2015-01-22 23:05:36 -0500
commit5f4f111cd367266fd9df656d409f0b0fe9cf9836 (patch)
treec3ee15ca881be0fe2b559f99faef0838a8d86363 /lisp
parenta4b053da8e07f2f390730eaaf33a61b66edb0e04 (diff)
downloademacs.d-5f4f111cd367266fd9df656d409f0b0fe9cf9836.tar.gz
Use whitespace-mode as cleanup indicator
- Activate global whitespace-mode. When not allowing the buffer to be cleaned up, use more annoying whitespace indicators. - Use whitespace-cleanup as cleanup function. Except for trailing whitespace, this should cover what km/cleanup-buffer was doing and more.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/init-editing.el25
-rw-r--r--lisp/init-general.el1
2 files changed, 18 insertions, 8 deletions
diff --git a/lisp/init-editing.el b/lisp/init-editing.el
index a8f37ae..ea1efac 100644
--- a/lisp/init-editing.el
+++ b/lisp/init-editing.el
@@ -158,23 +158,34 @@ and '<<<' mark the bounds of the narrowed region.
;; 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
+(defvar-local km/prevent-cleanup nil
"If set, `km/cleanup-buffer' does not perform clean up on save.")
+(setq whitespace-style '(face trailing indentation))
+(global-whitespace-mode 1)
+
(defun km/toggle-prevent-cleanup ()
"Toggle state of `km/prevent-cleanup'."
(interactive)
(if km/prevent-cleanup
- (message "Allowing cleanup on save ")
- (message "Preventing cleanup on save"))
- (set (make-local-variable 'km/prevent-cleanup) (not km/prevent-cleanup)))
+ (progn
+ (message "Allowing cleanup on save")
+ (kill-local-variable 'whitespace-style)
+ (global-whitespace-mode 0)
+ (global-whitespace-mode 1))
+ (message "Preventing cleanup on save")
+ (setq-local whitespace-style
+ '(face trailing indentation
+ tab-mark space-mark newline-mark))
+ (global-whitespace-mode 0)
+ (global-whitespace-mode 1))
+ (setq km/prevent-cleanup (not km/prevent-cleanup)))
(defun km/cleanup-buffer ()
(interactive)
(unless km/prevent-cleanup
- (unless indent-tabs-mode
- (untabify (point-min) (point-max)))
- (delete-trailing-whitespace)))
+ (whitespace-cleanup)))
+
(add-hook 'before-save-hook 'km/cleanup-buffer)
(define-key km/editing-map "t" 'km/toggle-prevent-cleanup)
diff --git a/lisp/init-general.el b/lisp/init-general.el
index f5f28f7..adc9df3 100644
--- a/lisp/init-general.el
+++ b/lisp/init-general.el
@@ -1,7 +1,6 @@
(setq echo-keystrokes 0.1
use-dialog-box nil
visible-bell t
- whitespace-style '(spaces tabs newline space-mark tab-mark newline-mark)
tramp-default-method "ssh"
enable-recursive-minibuffers t)