emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/exec-path-from-shell f88aa7edec 010/114: Make the list of


From: ELPA Syncer
Subject: [nongnu] elpa/exec-path-from-shell f88aa7edec 010/114: Make the list of copied variables customizable. (See #2)
Date: Tue, 5 Sep 2023 03:59:57 -0400 (EDT)

branch: elpa/exec-path-from-shell
commit f88aa7edecf1ed93a9ec5a1e7ba623e485b833e4
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Make the list of copied variables customizable. (See #2)
---
 README.md               |  8 +++++---
 exec-path-from-shell.el | 28 +++++++++++++++++++++-------
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index 500151c589..cce69ca0b6 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ different environment than a shell in a terminal window, 
because OS X does not
 run a shell during the login.  Obviously this will lead to unexpected results
 when calling external utilities like `make` from Emacs.
 
-This library intends to work around this problem by copying important
-environment variables from the user's shell.
+This library works around this problem by copying important environment
+variables from the user's shell.
 
 Installation
 ------------
@@ -33,7 +33,9 @@ Add the following to your `init.el`:
 
 This sets `$MANPATH`, `$PATH` and `exec-path` from your shell, but only on OS 
X.
 
-You can copy values of other environment variables with
+You can copy values of other environment variables by customizing
+`exec-path-from-shell-variables` before invoking
+`exec-path-from-shell-initialize`, or by calling
 `exec-path-from-shell-copy-env`, e.g.:
 
 ```scheme
diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index 99567a2693..ecdc4d25e2 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -56,6 +56,16 @@
 
 ;;; Code:
 
+(defgroup exec-path-from-shell nil
+  "Make Emacs use shell-defined values for $PATH etc."
+  :prefix "exec-path-from-shell-"
+  :group 'environment)
+
+(defcustom exec-path-from-shell-variables
+  '("PATH" "MANPATH")
+  "List of environment variables which are copied from the shell."
+  :group 'exec-path-from-shell)
+
 (defun exec-path-from-shell-getenv (name)
   "Get the environment variable NAME from the user's shell.
 
@@ -71,20 +81,24 @@ variable of NAME and return this output as string."
 (defun exec-path-from-shell-copy-env (name)
   "Set the environment variable $NAME from the user's shell.
 
-Return the value of the environment variable."
+As a special case, if the variable is $PATH, then `exec-path' is
+also set appropriately.  Return the value of the environment
+variable."
   (interactive "sCopy value of which environment variable from shell? ")
-  (setenv name (exec-path-from-shell-getenv name)))
+  (prog1
+      (setenv name (exec-path-from-shell-getenv name))
+    (when (string-equal "PATH" name)
+      (setq exec-path (split-string (getenv "PATH") path-separator)))))
 
 ;;;###autoload
 (defun exec-path-from-shell-initialize ()
   "Initialize environment from the user's shell.
 
-Set $MANPATH, $PATH and `exec-path' from the corresponding
-variables in the user's shell."
+The values of all the environment variables named in
+`exec-path-from-shell-variables' are set from the corresponding
+values used in the user's shell."
   (interactive)
-  (exec-path-from-shell-copy-env "MANPATH")
-  (setq exec-path (split-string (exec-path-from-shell-copy-env "PATH")
-                                path-separator)))
+  (mapc 'exec-path-from-shell-copy-env exec-path-from-shell-variables))
 
 
 (provide 'exec-path-from-shell)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]