[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)
- [nongnu] elpa/exec-path-from-shell ad68d36747 102/114: Instead of checking startup files, just warn if execution is slow, (continued)
- [nongnu] elpa/exec-path-from-shell ad68d36747 102/114: Instead of checking startup files, just warn if execution is slow, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 6336db9be1 111/114: Add Emacs 28.1 to CI matrix, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 03fc0a38af 114/114: Release 2.1, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell d17c4e0b73 094/114: Notes about increasing speed, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 81125c5adb 093/114: Add FUNDING.yml, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell e1f14450f1 098/114: Fix MELPA URL, add author footer, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 39aca32dda 001/114: Initial check-in, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 9c25f03459 006/114: Simplify initialization, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 0b81e0bf05 007/114: Copy $MANPATH on initialization, too, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell f349bc25aa 009/114: Merge pull request #2 from lunaryorn/init-manpath, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell f88aa7edec 010/114: Make the list of copied variables customizable. (See #2),
ELPA Syncer <=
- [nongnu] elpa/exec-path-from-shell ed17558245 011/114: Fix local variables block formatting, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 3b280d3093 013/114: Set all variables using just one shell invocation, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 4b2f672301 020/114: Make use of printf safer, in case env var values contain escapes (see #5), ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 89aed99c12 021/114: Can now single-quote format argument to printf, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 2b6651242f 018/114: Unambigiously escape the null character (fixes #5), ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 9f034cdb97 022/114: Explicitly double-quote args, so empty var values don't mess things up, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 95b7aee732 025/114: Use -d in place of --login for tcsh (fixes #7), ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell 96afc511bb 030/114: Add missing custom type, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell bfaa02106e 031/114: [Fix #13] Make shell arguments customizable, ELPA Syncer, 2023/09/05
- [nongnu] elpa/exec-path-from-shell a5162e6f99 032/114: Merge pull request #14 from lunaryorn/customizable-args, ELPA Syncer, 2023/09/05