hack-local-variables before mode hooks

The default behavior is to read file+directory-local variables after the
major mode and its hooks have run. I think this is backwards. What if we
want to use these local variables to customize the things running in
hooks?

This does mean hack-local-variables will run at least twice when the
mode changes, but this is an acceptable compromise.
This commit is contained in:
Henrik Lissner 2018-09-28 20:49:58 -04:00
parent 05d759fa8b
commit 13cee6870e

View file

@ -302,6 +302,16 @@ original value of `symbol-file'."
(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection)
(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection)
;; The default behavior is to read file+directory-local variables after the
;; major mode and its hooks have run. I think this is backwards. What if we want
;; to use these local variables to customize the things running in hooks?
(defun doom|hack-local-variables ()
(with-demoted-errors "File local-variables error: %s"
(hack-local-variables 'no-mode)))
;; `change-major-mode-hook' is too soon (runs before `kill-all-local-variables'
;; is run). `after-change-major-mode-hook' is too late (runs after mode hooks).
(add-hook 'change-major-mode-after-body-hook #'doom|hack-local-variables)
;;
;; Incremental lazy-loading