tools/direnv: conform to new hook conventions

This commit is contained in:
Henrik Lissner
2019-07-22 23:25:09 +02:00
parent d7ed52f3c7
commit 8e096f7a23

View File

@ -10,22 +10,24 @@
(def-package! direnv (def-package! direnv
:after-call (after-find-file dired-initial-position-hook) :after-call (after-find-file dired-initial-position-hook)
:config :config
(defun +direnv|init () (add-hook 'direnv-mode-hook
"Instead of checking for direnv on `post-command-hook', check on (defun +direnv-init-h ()
"Instead of checking for direnv on `post-command-hook', check on
buffer/window/frame switch, which is less expensive." buffer/window/frame switch, which is less expensive."
(direnv--disable) (direnv--disable)
(when direnv-mode (when direnv-mode
(add-hook 'doom-switch-buffer-hook #'direnv--maybe-update-environment) (add-hook 'doom-switch-buffer-hook #'direnv--maybe-update-environment)
(add-hook 'doom-switch-window-hook #'direnv--maybe-update-environment) (add-hook 'doom-switch-window-hook #'direnv--maybe-update-environment)
(add-hook 'doom-switch-frame-hook #'direnv--maybe-update-environment) (add-hook 'doom-switch-frame-hook #'direnv--maybe-update-environment)
(add-hook 'focus-in-hook #'direnv--maybe-update-environment))) (add-hook 'focus-in-hook #'direnv--maybe-update-environment))))
(add-hook 'direnv-mode-hook #'+direnv|init)
(defun +direnv|envrc-fontify-keywords () ;; Fontify special .envrc keywords; it's a good indication of whether or not
(font-lock-add-keywords ;; we've typed them correctly.
nil `((,(regexp-opt +direnv--keywords 'symbols) (add-hook 'direnv-envrc-mode-hook
(0 font-lock-keyword-face))))) (defun +direnv-envrc-fontify-keywords-h ()
(add-hook 'direnv-envrc-mode-hook #'+direnv|envrc-fontify-keywords) (font-lock-add-keywords
nil `((,(regexp-opt +direnv--keywords 'symbols)
(0 font-lock-keyword-face))))))
(def-advice! +direnv--update-a (&rest _) (def-advice! +direnv--update-a (&rest _)
"Update direnv. Useful to advise functions that may run "Update direnv. Useful to advise functions that may run