Skip to content

Commit

Permalink
emacsWithPackages: don't tell sub-Emacs about pkgs
Browse files Browse the repository at this point in the history
If I'm running an Emacs executable from emacsWithPackages as my main
programming environment, and I'm hacking on Emacs, or the Emacs
packaging in Nixpkgs, or whatever, I don't want the Emacs packages
from the wrapper to show up in the load path of that child Emacs.  It
results in differing behaviour depending on whether the child Emacs is
run from Emacs or from, for example, an external terminal emulator,
which is very surprising.

To avoid this, pass another environment variable containing the
wrapper site-lisp path, and use that value to remove the corresponding
entry in EMACSLOADPATH, so it won't be propagated to child Emacsen.
  • Loading branch information
alyssais committed Dec 10, 2020
1 parent 0127013 commit 23d4bfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkgs/applications/editors/emacs/site-start.el
Expand Up @@ -22,6 +22,17 @@ least specific (the system profile)"
(nix--profile-paths)))))
(setq load-path (append paths load-path)))

;;; Remove wrapper site-lisp from EMACSLOADPATH so it's not propagated
;;; to any other Emacsen that might be started as subprocesses.
(let ((wrapper-site-lisp (getenv "emacsWithPackages_siteLisp"))
(env-load-path (getenv "EMACSLOADPATH")))
(when wrapper-site-lisp
(setenv "emacsWithPackages_siteLisp" nil))
(when (and wrapper-site-lisp env-load-path)
(let* ((env-list (split-string env-load-path ":"))
(new-env-list (delete wrapper-site-lisp env-list)))
(setenv "EMACSLOADPATH" (when new-env-list
(mapconcat 'identity new-env-list ":"))))))

;;; Make `woman' find the man pages
(defvar woman-manpath)
Expand Down
1 change: 1 addition & 0 deletions pkgs/build-support/emacs/wrapper.sh
Expand Up @@ -22,5 +22,6 @@ else
fi

export EMACSLOADPATH="${newLoadPath[*]}"
export emacsWithPackages_siteLisp=@wrapperSiteLisp@

exec @prog@ "$@"

0 comments on commit 23d4bfb

Please sign in to comment.