From c2c6a6411801b8b9ded87503b9454c512ae7f989 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 3 Aug 2021 16:17:50 -0400 Subject: [PATCH] fix: doom/reload now regenerates the envvar file Removes doom/reload-env, now that it is redundant. --- core/autoload/config.el | 46 ++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/core/autoload/config.el b/core/autoload/config.el index 6a27ac598..d8a043841 100644 --- a/core/autoload/config.el +++ b/core/autoload/config.el @@ -74,15 +74,23 @@ package list, and lastly, reloads your private config.el. Runs `doom-after-reload-hook' afterwards." (interactive) - (when (and IS-WINDOWS (file-exists-p doom-env-file)) - (message "Can't regenerate envvar file from within Emacs. Run 'doom env' from the console")) - ;; In case doom/reload is run before incrementally loaded packages are loaded, - ;; which could cause odd load order issues. (mapc #'require (cdr doom-incremental-packages)) - (doom--if-compile (format "%S sync -e" doom-bin) - (let ((doom-reloading-p t) - doom-env-file) + (doom--if-compile (format "%S sync" doom-bin) + (let ((doom-reloading-p t)) (doom-run-hooks 'doom-before-reload-hook) + (when (file-readable-p doom-env-file) + (if IS-WINDOWS + (message "Can't regenerate envvar file from within Emacs in Windows. Skipping...") + (let (process-environment) + (doom--if-compile + (format "%s -ic '%S env%s'" + (string-trim + (shell-command-to-string + (format "getent passwd %S | cut -d: -f7" + (user-login-name)))) + doom-bin (if arg " -c" "")) + (message "Successfully regenerated envvar file") + (error "Failed to generate env file"))))) (doom-initialize 'force) (with-demoted-errors "PRIVATE CONFIG ERROR: %s" (general-auto-unbind-keys) @@ -109,30 +117,6 @@ line." (doom-initialize-packages) (doom-autoloads-reload)) -;;;###autoload -(defun doom/reload-env (&optional arg) - "Regenerates and/or reloads your envvar file. - -If passed the prefix ARG, clear the envvar file. Uses the same mechanism as -'bin/doom env'. - -An envvar file contains a snapshot of your shell environment, which can be -imported into Emacs." - (interactive "P") - (when IS-WINDOWS - (user-error "Cannot reload envvar file from within Emacs on Windows, run it from cmd.exe")) - (doom--if-compile - (format "%s -ic '%S env%s'" - (string-trim - (shell-command-to-string - (format "getent passwd %S | cut -d: -f7" - (user-login-name)))) - doom-bin (if arg " -c" "")) - (let ((doom-reloading-p t)) - (unless arg - (doom-load-envvars-file doom-env-file))) - (error "Failed to generate env file"))) - ;;;###autoload (defun doom/upgrade () "Run 'doom upgrade' then prompt to restart Emacs."