From ae365272ad8e41a56945b089561d9894ec27baf1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 18 Jun 2019 11:44:50 +0200 Subject: [PATCH] Set exec-path/shell-file-name in doom-load-env-vars And perform file-readable-p check inside doom-load-env-vars --- core/autoload/config.el | 7 +------ core/core.el | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/core/autoload/config.el b/core/autoload/config.el index 0185288f1..1605054b6 100644 --- a/core/autoload/config.el +++ b/core/autoload/config.el @@ -56,12 +56,7 @@ Uses the same mechanism as 'bin/doom env reload'." (sit-for 1)) (unless (file-readable-p doom-env-file) (error "Failed to generate env file")) - (doom-load-env-vars doom-env-file) - (setq-default - exec-path (append (split-string (getenv "PATH") ":") - (list exec-directory)) - shell-file-name (or (getenv "SHELL") - shell-file-name))) + (doom-load-env-vars doom-env-file)) ;;;###autoload (defun doom/reload-font () diff --git a/core/core.el b/core/core.el index d233cc748..80e8f066d 100644 --- a/core/core.el +++ b/core/core.el @@ -429,7 +429,8 @@ in interactive sessions, nil otherwise (but logs a warning)." (defun doom-load-env-vars (file) "Read and set envvars in FILE." - (let (vars) + (if (not (file-readable-p file)) + (doom-log "Couldn't read %S envvar file" file) (with-temp-buffer (insert-file-contents file) (re-search-forward "\n\n" nil t) @@ -442,7 +443,12 @@ in interactive sessions, nil otherwise (but logs a warning)." (line-beginning-position)) (point-max)))))) (setenv var value))))) - vars)) + (setq exec-path (append (split-string (getenv "PATH") + (if IS-WINDOWS ";" ":")) + (list exec-directory)) + shell-file-name (or (getenv "SHELL") + shell-file-name)) + t)) (defun doom-initialize (&optional force-p) "Bootstrap Doom, if it hasn't already (or if FORCE-P is non-nil). @@ -510,14 +516,8 @@ to least)." (user-error "Your package autoloads are missing! Run `bin/doom refresh' to regenerate them"))) ;; Load shell environment - (when (and (not noninteractive) - (file-readable-p doom-env-file)) - (doom-load-env-vars doom-env-file) - (setq exec-path (append (split-string (getenv "PATH") - (if IS-WINDOWS ";" ":")) - (list exec-directory)) - shell-file-name (or (getenv "SHELL") - shell-file-name)))) + (unless noninteractive + (doom-load-env-vars doom-env-file))) (require 'core-modules) (require 'core-os)