From 0e58a7c2869daf65ca2c854c82dacef040b46a5f Mon Sep 17 00:00:00 2001 Message-Id: <0e58a7c2869daf65ca2c854c82dacef040b46a5f.1718353104.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 11 Jan 2010 16:57:39 +0000 Subject: [PATCH] el/dot-emacs.el: Front-end function for turning on `whitespace-mode'. Organization: Straylight/Edgeware From: Mark Wooding 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 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 5a152f0..797c7dc 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -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 -- [mdw]