From ed7b46b929b31bc38b472caeeededbd676371afc Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Tue, 15 Dec 2009 12:06:27 +0000 Subject: [PATCH] el/dot-emacs.el: Fix `whitespace' hacking. Organization: Straylight/Edgeware From: Mark Wooding 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 | 79 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 95cfac4..4d82b1a 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -681,8 +681,6 @@ (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))) - (whitespace-mode t)) (and (fboundp 'gtags-mode) (gtags-mode)) (outline-minor-mode t) @@ -690,6 +688,10 @@ (defun mdw-misc-mode-config () (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 @@ (defun mdw-fontify-c-and-c++ () ;; 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 @@ (defun mdw-fontify-apcalc () ;; 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 @@ (defun mdw-fontify-java () ;; 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 @@ (defun mdw-fontify-csharp () ;; 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 @@ (defun mdw-fontify-go () ;; 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 @@ (defun mdw-fontify-awk () ;; 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 @@ (defun mdw-fontify-perl () ;; 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 @@ (defun mdw-fontify-pythonic (keywords) ;; 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 @@ (defun mdw-fontify-icon () ;; 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 @@ (defun arm-assembler-mode () ;; 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 @@ (defun mdw-fontify-tcl () "\\([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 @@ (defun mdw-fontify-rexx () ;; 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 @@ (defun mdw-fontify-sml () ;; 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 @@ (defun mdw-fontify-haskell () "\\([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 @@ (defun mdw-fontify-erlang () (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 @@ (defun mdw-fontify-texinfo () ;; 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 @@ (defun mdw-fontify-tex () ;; 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 @@ (defun mdw-fontify-smalltalk () "\\([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 @@ (defun mdw-fontify-lispy () (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) -- [mdw]