chiark / gitweb /
el/dot-emacs.el: Per-major-mode post-local-variables hooks.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 2 May 2015 16:05:20 +0000 (17:05 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 19 May 2015 09:32:15 +0000 (10:32 +0100)
As suggested in http://emacswiki.org/emacs/LocalVariables.

el/dot-emacs.el

index 4f2df95bb2457619d585f91bfccb6b784f9fa473..32188f94e048a0a7c80b7e95b54c822414ddecb8 100644 (file)
@@ -91,6 +91,14 @@ (defun mdw-config (sym)
                    (concat "(" (buffer-string) ")")))))))
   (cdr (assq sym mdw-config)))
 
+;; Local variables hacking.
+
+(defun run-local-vars-mode-hook ()
+  "Run a hook for the major-mode after local variables have been processed."
+  (run-hooks (intern (concat (symbol-name major-mode)
+                            "-local-variables-hook"))))
+(add-hook 'hack-local-variables-hook 'run-local-vars-mode-hook)
+
 ;; Set up the load path convincingly.
 
 (dolist (dir (append (and (boundp 'debian-emacs-flavor)
@@ -2733,8 +2741,8 @@ (defun mdw-conf-quote-normal-acceptable-value-p (value)
   (or (booleanp value)
       (every (lambda (v) (memq v '(?\" ?')))
             (if (listp value) value (list value)))))
-(put 'mdw-conf-quote-normal 'safe-local-variable '
-     mdw-conf-quote-normal-acceptable-value-p)
+(put 'mdw-conf-quote-normal 'safe-local-variable
+     'mdw-conf-quote-normal-acceptable-value-p)
 
 (defun mdw-fix-up-quote ()
   "Apply the setting of `mdw-conf-quote-normal'."
@@ -2749,15 +2757,7 @@ (defun mdw-fix-up-quote ()
                   (if (listp flag) flag (list flag)))
             (set-syntax-table table)
             (and font-lock-mode (font-lock-fontify-buffer)))))))
-(defun mdw-fix-up-quote-hack ()
-  "Unpleasant hack to call `mdw-fix-up-quote' at the right time.
-Annoyingly, `hack-local-variables' is done after `set-auto-mode'
-so we wouldn't see a local-variable setting of
-`mdw-conf-quote-normal' in `conf-mode-hook'.  Instead, wire
-ourselves onto `hack-local-variables-hook' here, and check the
-setting once it's actually been made."
-  (add-hook 'hack-local-variables-hook 'mdw-fix-up-quote t t))
-(add-hook 'conf-mode-hook 'mdw-fix-up-quote-hack t)
+(add-hook 'conf-mode-local-variables-hook 'mdw-fix-up-quote t t)
 
 ;;;--------------------------------------------------------------------------
 ;;; Shell scripts.