Revert direnv modifications

Not worth the trouble. I'll move it to my private config.

Fixes #2384
Closes #2384
This commit is contained in:
Henrik Lissner 2020-02-02 03:18:49 -05:00
parent 6337912d13
commit a12a54b28f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -7,37 +7,20 @@
"use" "rvm" "use_nix" "use_guix") "use" "rvm" "use_nix" "use_guix")
"TODO") "TODO")
;;
;;; Packages
(use-package! direnv (use-package! direnv
:after-call after-find-file dired-initial-position-hook :after-call after-find-file dired-initial-position-hook
:config :config
(add-hook! 'direnv-mode-hook
(defun +direnv-init-h ()
"Instead of checking for direnv on `post-command-hook', check only once,
when the file is first opened/major mode is activated. This is significantly
less expensive, but is less sensitive to changes to .envrc done outside of
Emacs."
(direnv--disable)
(funcall (if direnv-mode 'add-hook 'remove-hook)
'after-change-major-mode-hook
#'direnv--maybe-update-environment)))
(defadvice! +direnv--make-process-environment-buffer-local-a (items)
:filter-return #'direnv--export
(when items
(mapc 'kill-local-variable '(process-environment exec-path))
(mapc 'make-local-variable '(process-environment exec-path)))
items)
;; Fontify special .envrc keywords; it's a good indication of whether or not ;; Fontify special .envrc keywords; it's a good indication of whether or not
;; we've typed them correctly. ;; we've typed them correctly.
(add-hook! 'direnv-envrc-mode-hook (add-hook! 'direnv-envrc-mode-hook
(defun +direnv-envrc-fontify-keywords-h () (defun +direnv-envrc-fontify-keywords-h ()
(font-lock-add-keywords (font-lock-add-keywords
nil `((,(regexp-opt +direnv--keywords 'symbols) nil `((,(regexp-opt +direnv--keywords 'symbols)
(0 font-lock-keyword-face))))) (0 font-lock-keyword-face))))))
(defun +direnv-update-on-save-h ()
(add-hook 'after-save-hook #'direnv--maybe-update-environment
nil 'local)))
(defadvice! +direnv-update-a (&rest _) (defadvice! +direnv-update-a (&rest _)
"Update direnv. Useful to advise functions that may run "Update direnv. Useful to advise functions that may run
@ -46,24 +29,10 @@ flycheck issues with direnv and on nix."
:before #'flycheck-default-executable-find :before #'flycheck-default-executable-find
(direnv--maybe-update-environment)) (direnv--maybe-update-environment))
(defadvice! +direnv--fail-gracefully-a (orig-fn) (defadvice! +direnv--fail-gracefully-a (&rest _)
"Don't try to update direnv if the executable isn't present." "Don't try to use direnv if the executable isn't present."
:around #'direnv--maybe-update-environment :before-while #'direnv-update-directory-environment
(if (executable-find "direnv") (or (executable-find "direnv")
(when (file-readable-p (or buffer-file-name default-directory)) (ignore (doom-log "Couldn't find direnv executable"))))
(funcall orig-fn))
(doom-log "Couldn't find direnv executable")))
(defadvice! +direnv-update-async-shell-command-a (command &optional output-buffer _error-buffer)
:before #'shell-command
(when (string-match "[ \t]*&[ \t]*\\'" command)
(let ((environment process-environment)
(path exec-path)
(shell shell-file-name))
(with-current-buffer
(get-buffer-create (or output-buffer "*Async Shell Command*"))
(setq-local process-environment environment)
(setq-local exec-path path)
(setq-local shell-file-name shell)))))
(direnv-mode +1)) (direnv-mode +1))