doom|hack-local-variables => MODE-local-vars-hook
Uses a less destructive method (the same that Spacemacs uses) than the
one introduced in 13cee68
, by introducing MODE-local-vars-hook hooks,
which run after local vars have been initialized.
The old method was to call `hack-local-variables` *before* mode hooks
run, however, this causes variables set by modes to have higher
precedence than local vars, which is unacceptable.
Also moved intero-mode & dante-mode to haskell-mode-local-vars-hook
This commit is contained in:
parent
b674aef31b
commit
fd19698927
3 changed files with 10 additions and 11 deletions
17
core/core.el
17
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)
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue