chiark / gitweb /
Merge branch 'master' of us:etc/profile
[profile] / el / dot-emacs.el
index 316b9e050266b8bfe6d5062f6520a684c0db5182..2fb1520d6fd390ce7299018b939ae9f3155a6674 100644 (file)
@@ -810,6 +810,8 @@ (defun mdw-whitespace-mode (&optional arg)
       (whitespace-mode arg))
     (setq show-trailing-whitespace whitespace-mode)))
 
+(defvar mdw-do-misc-mode-hacking nil)
+
 (defun mdw-misc-mode-config ()
   (and mdw-auto-indent
        (cond ((eq major-mode 'lisp-mode)
@@ -819,14 +821,13 @@ (defun mdw-misc-mode-config ()
              nil)
             (t
              (local-set-key "\C-m" 'newline-and-indent))))
+  (set (make-local-variable 'mdw-do-misc-mode-hacking) t)
   (local-set-key [C-return] 'newline)
   (make-local-variable 'page-delimiter)
   (setq page-delimiter "\f\\|^.*-\\{6\\}.*$")
   (setq comment-column 40)
   (auto-fill-mode 1)
   (setq fill-column 77)
-  (setq show-trailing-whitespace t)
-  (mdw-whitespace-mode 1)
   (and (fboundp 'gtags-mode)
        (gtags-mode))
   (if (fboundp 'hs-minor-mode)
@@ -835,8 +836,17 @@ (defun mdw-misc-mode-config ()
   (reveal-mode t)
   (trap (turn-on-font-lock)))
 
-(defun mdw-post-config-mode-hack ()
-  (mdw-whitespace-mode 1))
+(defun mdw-post-local-vars-misc-mode-config ()
+  (when (and mdw-do-misc-mode-hacking
+            (not buffer-read-only))
+    (setq show-trailing-whitespace t)
+    (mdw-whitespace-mode 1)))
+(add-hook 'hack-local-variables-hook 'mdw-post-local-vars-misc-mode-config)
+
+(defadvice toggle-read-only (after mdw-angry-fruit-salad activate)
+  (when mdw-do-misc-mode-hacking
+    (setq show-trailing-whitespace (not buffer-read-only))
+    (mdw-whitespace-mode (if buffer-read-only 0 1))))
 
 (eval-after-load 'gtags
   '(progn
@@ -1226,7 +1236,7 @@ (mdw-define-face whizzy-error-face
 (mdw-define-face mdw-ellipsis-face
   (((type tty)) :foreground "blue") (t :foreground "grey60"))
 (let ((dollar (make-glyph-code ?$ 'mdw-ellipsis-face))
-      (backslash (make-glyph-code ?\ 'mdw-ellipsis-face))
+      (backslash (make-glyph-code ?\\ 'mdw-ellipsis-face))
       (dot (make-glyph-code ?. 'mdw-ellipsis-face))
       (bar (make-glyph-code ?| mdw-ellipsis-face)))
   (set-display-table-slot standard-display-table 0 dollar)
@@ -1461,9 +1471,7 @@ (defun mdw-fontify-c-and-c++ ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))
-
-    (mdw-post-config-mode-hack)))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; AP calc mode.
@@ -1515,9 +1523,7 @@ (defun mdw-fontify-apcalc ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Java programming configuration.
@@ -1583,9 +1589,7 @@ (defun mdw-fontify-java ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Javascript programming configuration.
@@ -1643,9 +1647,7 @@ (defun mdw-fontify-javascript ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Scala programming configuration.
@@ -1718,9 +1720,7 @@ (defun mdw-fontify-scala ()
                         "\\|" "\\\\" "." "\\)"
                         "\\('\\)")
                 '(1 "\"")
-                '(4 "\"")))))
-
-  (mdw-post-config-mode-hack))
+                '(4 "\""))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; C# programming configuration.
@@ -1791,9 +1791,7 @@ (defun mdw-fontify-csharp ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 (define-derived-mode csharp-mode java-mode "C#"
   "Major mode for editing C# code.")
@@ -1908,9 +1906,7 @@ (defun mdw-fontify-fsharp ()
                      '(0 mdw-number-face))
 
                (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                     '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                     '(0 mdw-punct-face))))))
 
 (defun mdw-fontify-inferior-fsharp ()
   (mdw-fontify-fsharp)
@@ -1979,9 +1975,7 @@ (defun mdw-fontify-go ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Rust programming configuration.
@@ -2057,10 +2051,7 @@ (defun mdw-fontify-rust ()
 
   ;; Hack key bindings.
   (local-set-key [?{] 'mdw-self-insert-and-indent)
-  (local-set-key [?}] 'mdw-self-insert-and-indent)
-
-  ;; Final hacking.
-  (mdw-post-config-mode-hack))
+  (local-set-key [?}] 'mdw-self-insert-and-indent))
 
 ;;;--------------------------------------------------------------------------
 ;;; Awk programming configuration.
@@ -2118,9 +2109,7 @@ (defun mdw-fontify-awk ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Perl programming style.
@@ -2182,9 +2171,7 @@ (defun mdw-fontify-perl ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 (defun perl-number-tests (&optional arg)
   "Assign consecutive numbers to lines containing `#t'.  With ARG,
@@ -2227,9 +2214,7 @@ (defun mdw-fontify-pythonic (keywords)
 
         ;; And anything else is punctuation.
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face))))
-
-  (mdw-post-config-mode-hack))
+              '(0 mdw-punct-face)))))
 
 ;; Define Python fontification styles.
 
@@ -2303,9 +2288,7 @@ (defun mdw-fontify-icon ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Assembler mode.
@@ -2339,8 +2322,7 @@ (defun mdw-fontify-tcl ()
                       "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face))))
-  (mdw-post-config-mode-hack))
+              '(0 mdw-punct-face)))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Dylan programming configuration.
@@ -2406,9 +2388,7 @@ (defun mdw-fontify-dylan ()
                              "\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\|"
                              "\\_<[-+*/=<>:&|]+\\_>"
                              "\\)")
-                     '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                     '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Algol 68 configuration.
@@ -2450,9 +2430,7 @@ (defun mdw-fontify-algol-68 ()
                              "\\>")
                      '(0 mdw-number-face))
                (list "\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/"
-                     '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                     '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; REXX configuration.
@@ -2525,9 +2503,7 @@ (defun mdw-fontify-rexx ()
 
           ;; And everything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Standard ML programming style.
@@ -2577,9 +2553,7 @@ (defun mdw-fontify-sml ()
 
           ;; And anything else is punctuation.
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Haskell configuration.
@@ -2657,9 +2631,7 @@ (defun mdw-fontify-haskell ()
                         "\\([eE]\\([-+]\\|\\)[0-9]+\\|\\)")
                 '(0 mdw-number-face))
           (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Erlang configuration.
@@ -2692,9 +2664,7 @@ (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)))))
-
-  (mdw-post-config-mode-hack))
+                '(0 mdw-punct-face))))))
 
 ;;;--------------------------------------------------------------------------
 ;;; Texinfo configuration.
@@ -2728,9 +2698,7 @@ (defun mdw-fontify-texinfo ()
 
         ;; Fontify TeX special characters as punctuation.
         (list "[{}]+"
-              '(0 mdw-punct-face))))
-
-  (mdw-post-config-mode-hack))
+              '(0 mdw-punct-face)))))
 
 ;;;--------------------------------------------------------------------------
 ;;; TeX and LaTeX configuration.
@@ -2796,9 +2764,7 @@ (defun mdw-fontify-tex ()
 
         ;; Fontify TeX special characters as punctuation.
         (list "[$^_{}#&]"
-              '(0 mdw-punct-face))))
-
-  (mdw-post-config-mode-hack))
+              '(0 mdw-punct-face)))))
 
 ;;;--------------------------------------------------------------------------
 ;;; SGML hacking.
@@ -3158,8 +3124,7 @@ (defun mdw-fontify-smalltalk ()
                       "\\([eE]\\([-+]\\|\\)[0-9_]+\\|\\)")
               '(0 mdw-number-face))
         (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-              '(0 mdw-punct-face))))
-  (mdw-post-config-mode-hack))
+              '(0 mdw-punct-face)))))
 
 ;; Lispy languages.
 
@@ -3216,9 +3181,7 @@ (defun mdw-fontify-lispy ()
                            "\\)\\_>")
                    '(0 mdw-number-face))
              (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                   '(0 mdw-punct-face))))
-
-  (mdw-post-config-mode-hack))
+                   '(0 mdw-punct-face)))))
 
 (defun comint-send-and-indent ()
   (interactive)