Updating dotfiles.

This commit is contained in:
Derek Taylor
2020-09-29 16:28:27 -05:00
parent e8ae19d7ad
commit af5b75ee4d
204 changed files with 1870 additions and 2063 deletions

View File

@@ -34,7 +34,7 @@ direnv and then made available to the current shell.
This module provides no flags.
** Plugins
+ [[https://github.com/wbolster/emacs-direnv][direnv]]
+ [[https://github.com/purcell/envrc][envrc]]
** Hacks
+ Normally, the direnv environment is updated on ~post-command-hook~. We've

View File

@@ -5,30 +5,61 @@
"join_args" "expand_path" "dotenv" "user_rel_path" "find_up" "source_env"
"watch_file" "source_up" "direnv_load" "MANPATH_add" "load_prefix" "layout"
"use" "rvm" "use_nix" "use_guix")
"TODO")
"A list of direnv keywords, which are fontified when in `+direnv-rc-mode'.")
;;
;;; Packages
(use-package! direnv
:hook (before-hack-local-variables . direnv--maybe-update-environment)
:hook (flycheck-before-syntax-check . direnv--maybe-update-environment)
:hook (direnv-envrc-mode . +direnv-envrc-fontify-keywords-h)
(use-package! envrc
:when (executable-find "direnv")
:after-call doom-first-file-hook
:mode ("\\.envrc\\'" . +direnv-rc-mode)
:config
(add-to-list 'direnv-non-file-modes 'vterm-mode)
(add-to-list 'doom-debug-variables 'envrc-debug)
(defun +direnv-envrc-fontify-keywords-h ()
"Fontify special .envrc keywords; it's a good indication of whether or not
we've typed them correctly."
;; I'm avoiding `global-envrc-mode' intentionally, because it has the
;; potential to run too late in the mode startup process (and after, say,
;; server hooks that may rely on that local direnv environment).
(add-hook! 'change-major-mode-after-body-hook
(defun +direnv-init-h ()
(unless (or envrc-mode
(minibufferp)
(file-remote-p default-directory))
(envrc-mode 1))))
(define-derived-mode +direnv-rc-mode sh-mode "envrc"
"Major mode for .envrc files."
;; Fontify .envrc keywords; it's a good indication of whether or not we've
;; typed them correctly, and that we're in the correct major mode.
(font-lock-add-keywords
nil `((,(regexp-opt +direnv-keywords 'symbols)
(0 font-lock-keyword-face)))))
(defadvice! +direnv--fail-gracefully-a (&rest _)
"Don't try to use direnv if the executable isn't present."
:before-while #'direnv-update-directory-environment
:before-while #'envrc-mode
(or (executable-find "direnv")
(ignore (doom-log "Couldn't find direnv executable"))))
(direnv-mode +1))
;; HACK envrc-mode only affects the current buffer's environment, which is
;; generally what we want, except when we're running babel blocks in
;; org-mode, because there may be state or envvars those blocks need to
;; read. In order to perpetuate the org buffer's environment into the
;; execution of the babel block we need to temporarily change the global
;; environment. Let's hope it runs quickly enough that its effects aren't
;; felt in other buffers in the meantime!
(defvar +direnv--old-environment nil)
(defadvice! +direnv-persist-environment-a (orig-fn &rest args)
:around #'org-babel-execute-src-block
(if +direnv--old-environment
(apply orig-fn args)
(setq-default +direnv--old-environment
(cons (default-value 'process-environment)
(default-value 'exec-path))
exec-path exec-path
process-environment process-environment)
(unwind-protect (apply orig-fn args)
(setq-default process-environment (car +direnv--old-environment)
exec-path (cdr +direnv--old-environment)
+direnv--old-environment nil)))))

View File

@@ -1,4 +1,4 @@
;; -*- no-byte-compile: t; -*-
;;; tools/direnv/packages.el
(package! direnv :pin "f5484b0fc33d4e5116612626294efb362ff9ecd4")
(package! envrc :pin "1dc5aad14d2c27211c7c288d2d9dffeb2e27cb2d")