diff --git a/core/core.el b/core/core.el index 134b27061..ad2eb1813 100644 --- a/core/core.el +++ b/core/core.el @@ -302,15 +302,14 @@ 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) +;; File+dir local variables are initialized after the major mode and its hooks +;; have run. If you want hook functions to be aware of these customizations, add +;; them to MODE-local-vars-hook instead. +(defun doom|run-local-var-hooks () + "Run MODE-local-vars-hook after local variables are initialized." + (run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode)) + #'doom-try-run-hook)) +(add-hook 'hack-local-variables-hook #'doom|run-local-var-hooks) ;; diff --git a/modules/lang/haskell/+dante.el b/modules/lang/haskell/+dante.el index dcc4b7e97..e52f49c2f 100644 --- a/modules/lang/haskell/+dante.el +++ b/modules/lang/haskell/+dante.el @@ -2,7 +2,7 @@ ;;;###if (featurep! +dante) (def-package! dante - :hook (haskell-mode . dante-mode) + :hook (haskell-mode-local-vars . dante-mode) :init (setq dante-load-flags '(;; defaults: "+c" diff --git a/modules/lang/haskell/+intero.el b/modules/lang/haskell/+intero.el index b92a20c2a..e1985fc23 100644 --- a/modules/lang/haskell/+intero.el +++ b/modules/lang/haskell/+intero.el @@ -11,7 +11,7 @@ This is necessary because `intero-mode' doesn't do its own error checks." (if (executable-find "stack") (intero-mode +1) (message "Couldn't find stack. Refusing to enable intero-mode.")))) - (add-hook 'haskell-mode-hook #'+haskell|init-intero) + (add-hook 'haskell-mode-local-vars-hook #'+haskell|init-intero) :config (setq haskell-compile-cabal-build-command "stack build --fast") (set-lookup-handlers! 'intero-mode :definition #'intero-goto-definition)