el/dot-emacs.el: Fix `whitespace' hacking.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 15 Dec 2009 12:06:27 +0000 (12:06 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 15 Dec 2009 12:07:12 +0000 (12:07 +0000)
Life is more complicated, because `whitespace' fiddles with font lock.
So we have to arrange to turn on `whitespace' /after/ doing the font
lock configuration for the individual modes.  Oh, well.

el/dot-emacs.el

index 95cfac4..4d82b1a 100644 (file)
@@ -681,8 +681,6 @@ case."
   (auto-fill-mode 1)
   (setq fill-column 77)
   (setq show-trailing-whitespace t)
-  (let ((whitespace-style (remove 'trailing whitespace-style)))
-    (whitespace-mode t))
   (and (fboundp 'gtags-mode)
        (gtags-mode))
   (outline-minor-mode t)
@@ -690,6 +688,10 @@ case."
   (reveal-mode t)
   (trap (turn-on-font-lock)))
 
+(defun mdw-post-config-mode-hack ()
+  (let ((whitespace-style (remove 'trailing whitespace-style)))
+    (trap (whitespace-mode t))))
+
 (eval-after-load 'gtags
   '(progn
      (dolist (key '([mouse-2] [mouse-3]))
@@ -1129,7 +1131,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face))))
+
+    (mdw-post-config-mode-hack)))
 
 ;;;--------------------------------------------------------------------------
 ;;; AP calc mode.
@@ -1181,7 +1185,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Java programming configuration.
@@ -1243,7 +1249,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; C# programming configuration.
@@ -1310,7 +1318,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 (define-derived-mode csharp-mode java-mode "C#"
   "Major mode for editing C# code.")
@@ -1346,7 +1356,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Awk programming configuration.
@@ -1404,7 +1416,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Perl programming style.
@@ -1451,7 +1465,9 @@ doesn't match any of the regular expressions in
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 (defun perl-number-tests (&optional arg)
   "Assign consecutive numbers to lines containing `#t'.  With ARG,
@@ -1493,7 +1509,9 @@ strip numbers instead."
 
         ;; And anything else is punctuation.
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face)))))
+              '(0 mdw-punct-face))))
+
+  (mdw-post-config-mode-hack))
 
 ;; Define Python fontification styles.
 
@@ -1567,7 +1585,9 @@ strip numbers instead."
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; ARM assembler programming configuration.
@@ -1648,8 +1668,9 @@ strip numbers instead."
 
         ;; And anything else is punctuation.
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face))))
+              '(0 mdw-punct-face)))
 
+  (mdw-post-config-mode-hack))
   (run-hooks 'arm-assembler-mode-hook))
 
 ;;;--------------------------------------------------------------------------
@@ -1675,7 +1696,8 @@ strip numbers instead."
                       "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face)))))
+              '(0 mdw-punct-face))))
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; REXX configuration.
@@ -1748,7 +1770,9 @@ strip numbers instead."
 
           ;; And everything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Standard ML programming style.
@@ -1798,7 +1822,9 @@ strip numbers instead."
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Haskell configuration.
@@ -1835,7 +1861,9 @@ strip numbers instead."
                         "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)")
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Erlang configuration.
@@ -1869,7 +1897,9 @@ strip numbers instead."
           (list "\\<[0-9]+\\(\\|#[0-9a-zA-Z]+\\|[eE][+-]?[0-9]+\\)\\>"
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+                '(0 mdw-punct-face)))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; Texinfo configuration.
@@ -1903,7 +1933,9 @@ strip numbers instead."
 
         ;; Fontify TeX special characters as punctuation.
         (list "[{}]+"
-              '(0 mdw-punct-face)))))
+              '(0 mdw-punct-face))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; TeX and LaTeX configuration.
@@ -1969,7 +2001,9 @@ strip numbers instead."
 
         ;; Fontify TeX special characters as punctuation.
         (list "[$^_{}#&]"
-              '(0 mdw-punct-face)))))
+              '(0 mdw-punct-face))))
+
+  (mdw-post-config-mode-hack))
 
 ;;;--------------------------------------------------------------------------
 ;;; SGML hacking.
@@ -2221,7 +2255,8 @@ strip numbers instead."
                       "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face)))))
+              '(0 mdw-punct-face))))
+  (mdw-post-config-mode-hack))
 
 ;; Lispy languages.
 
@@ -2261,7 +2296,9 @@ strip numbers instead."
   (setq font-lock-keywords
        (list
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face)))))
+              '(0 mdw-punct-face))))
+
+  (mdw-post-config-mode-hack))
 
 (defun comint-send-and-indent ()
   (interactive)