From 18bb0f77715d66d6ba7ec48eee7b3bdb9a5a0008 Mon Sep 17 00:00:00 2001 Message-Id: <18bb0f77715d66d6ba7ec48eee7b3bdb9a5a0008.1718379570.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 2 May 2015 17:05:20 +0100 Subject: [PATCH] el/dot-emacs.el: Per-major-mode post-local-variables hooks. Organization: Straylight/Edgeware From: Mark Wooding As suggested in http://emacswiki.org/emacs/LocalVariables. --- el/dot-emacs.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 4f2df95..32188f9 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -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. -- [mdw]