chiark / gitweb /
el/dot-emacs.el: Front-end function for turning on `whitespace-mode'.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 11 Jan 2010 16:57:39 +0000 (16:57 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 11 Jan 2010 17:02:11 +0000 (17:02 +0000)
We (still) don't want to highlight trailing spaces because
`show-trailing-whitespace' does the job better.  But this is a useful
thing to be able to do interactively, so turn it into a command.

Maybe I should think about turning it into a derived minor mode.

el/dot-emacs.el

index 5a152f000d4ca9c6e027f310ba052e3fe92a5daa..797c7dc05ed9fa72baae54e4b1924db11b057ae7 100644 (file)
@@ -665,6 +665,14 @@ (defun mdw-standard-fill-prefix (rx &optional mat)
 (defvar mdw-auto-indent t
   "Whether to indent automatically after a newline.")
 
+(defun mdw-whitespace-mode (&optional arg)
+  "Turn on/off whitespace mode, but don't highlight trailing space."
+  (interactive "P")
+  (when (and (boundp 'whitespace-style)
+            (fboundp 'whitespace-mode))
+    (let ((whitespace-style (remove 'trailing whitespace-style)))
+      (whitespace-mode arg))))
+
 (defun mdw-misc-mode-config ()
   (and mdw-auto-indent
        (cond ((eq major-mode 'lisp-mode)
@@ -681,8 +689,7 @@ (defun mdw-misc-mode-config ()
   (auto-fill-mode 1)
   (setq fill-column 77)
   (setq show-trailing-whitespace t)
-  (let ((whitespace-style (remove 'trailing whitespace-style)))
-    (trap (whitespace-mode t)))
+  (mdw-whitespace-mode 1)
   (and (fboundp 'gtags-mode)
        (gtags-mode))
   (outline-minor-mode t)
@@ -691,8 +698,7 @@ (defun mdw-misc-mode-config ()
   (trap (turn-on-font-lock)))
 
 (defun mdw-post-config-mode-hack ()
-  (let ((whitespace-style (remove 'trailing whitespace-style)))
-    (trap (whitespace-mode t))))
+  (mdw-whitespace-mode 1))
 
 (eval-after-load 'gtags
   '(progn