[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/exec-path-from-shell f349bc25aa 009/114: Merge pull reques
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/exec-path-from-shell f349bc25aa 009/114: Merge pull request #2 from lunaryorn/init-manpath |
Date: |
Tue, 5 Sep 2023 03:59:57 -0400 (EDT) |
branch: elpa/exec-path-from-shell
commit f349bc25aa114d27ad200f10da88d1be282b05a0
Merge: 4223b12cf9 96ef5e6093
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>
Merge pull request #2 from lunaryorn/init-manpath
Initialize MANPATH
---
README.md | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
exec-path-from-shell.el | 19 ++++++++++----
2 files changed, 81 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000..500151c589
--- /dev/null
+++ b/README.md
@@ -0,0 +1,67 @@
+exec-path-from-shell
+=====================
+
+A GNU Emacs library to setup environment variables from the user's shell.
+
+Motivation
+----------
+
+On OS X, an Emacs instance started from the graphical user interface will have
a
+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.
+
+Installation
+------------
+
+ELPA packages are available on Marmalade and MELPA. Alternatively,
[download][]
+the latest release or clone the repository, and install
+`exec-path-from-shell.el` with `M-x package-install-from-file`.
+
+Usage
+-----
+
+Add the following to your `init.el`:
+
+```scheme
+(when (memq window-system '(mac ns))
+ (exec-path-from-shell-initialize))
+```
+
+This sets `$MANPATH`, `$PATH` and `exec-path` from your shell, but only on OS
X.
+
+You can copy values of other environment variables with
+`exec-path-from-shell-copy-env`, e.g.:
+
+```scheme
+(exec-path-from-shell-copy-env "PYTHONPATH")
+```
+
+This function may also be called interactively.
+
+Further help
+------------
+
+* `C-h f exec-path-from-shell-initialize`
+* `C-h f exec-path-from-shell-copy-env`
+
+License
+-------
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
+Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+[download]: https://github.com/purcell/exec-path-from-shell/tags
diff --git a/exec-path-from-shell.el b/exec-path-from-shell.el
index f68251cfc3..99567a2693 100644
--- a/exec-path-from-shell.el
+++ b/exec-path-from-shell.el
@@ -57,6 +57,10 @@
;;; Code:
(defun exec-path-from-shell-getenv (name)
+ "Get the environment variable NAME from the user's shell.
+
+Execute $SHELL as interactive login shell, have it output the
+variable of NAME and return this output as string."
(with-temp-buffer
(call-process (getenv "SHELL") nil (current-buffer) nil
"--login" "-i" "-c" (concat "echo __RESULT=$" name))
@@ -65,17 +69,22 @@
;;;###autoload
(defun exec-path-from-shell-copy-env (name)
- "Set the environment variable with `NAME' to match the value seen in the
user's shell."
+ "Set the environment variable $NAME from the user's shell.
+
+Return the value of the environment variable."
(interactive "sCopy value of which environment variable from shell? ")
(setenv name (exec-path-from-shell-getenv name)))
;;;###autoload
(defun exec-path-from-shell-initialize ()
- "Set the PATH environment variable and `exec-path' to match that seen in the
user's shell."
+ "Initialize environment from the user's shell.
+
+Set $MANPATH, $PATH and `exec-path' from the corresponding
+variables in the user's shell."
(interactive)
- (let ((path-from-shell (exec-path-from-shell-getenv "PATH")))
- (setenv "PATH" path-from-shell)
- (setq exec-path (split-string path-from-shell path-separator))))
+ (exec-path-from-shell-copy-env "MANPATH")
+ (setq exec-path (split-string (exec-path-from-shell-copy-env "PATH")
+ path-separator)))
(provide 'exec-path-from-shell)
- [nongnu] elpa/exec-path-from-shell 2d152d1781 095/114: Clarify what the sample usage snippet does, (continued)
- [nongnu] elpa/exec-path-from-shell 2d152d1781 095/114: Clarify what the sample usage snippet does, ELPA Syncer, 2023/09/05
- [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 <=
- [nongnu] elpa/exec-path-from-shell f88aa7edec 010/114: Make the list of copied variables customizable. (See #2), ELPA Syncer, 2023/09/05
- [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