From 13cee6870ef7dce311d8207f8dd848b25daafe5b Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 28 Sep 2018 20:49:58 -0400 Subject: [PATCH] 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. --- core/core.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/core.el b/core/core.el index d3e1d1e09..8c52c7c35 100644 --- a/core/core.el +++ b/core/core.el @@ -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