mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
emacs: allow wrapped emacs to execute itself again
fixes #145302 #237855
emacsWithPackages wrapper script/`site-start.el` sanitize
EMACSLOADPATH, to make nested emacs invocations independent of the
package set specified in emacsWithPackages.
But there are valid use cases when one needs to call nested emacs with
the same package set. This includes built-in emacs functionality such
as async native compilations, and also external packages like
`emacs-async` and `esup`. In all of these cases
`invocation-directory`/`invocation-name` variables are being used to
launch nested emacs.
With this patch these variables will be populated to point to the
emacsWithPackages wrapper executable, so that executing
`(file-name-concat invocation-directory invocation-name)` will give a
fully functional emacs again.
`EMACSLOADPATH` sanitization was introduced by #106486, this behaviour
stays unchanged. The reasoning was to be able to run different emacs
executables without polluting their EMACSLOADPATH (as described here
23d4bfb666
).
The only change is that invoking itself is again feasible (and that's
what emacs actually expects).
Co-authored-by: Lin Jian <me@linj.tech>
This commit is contained in:
parent
47b7878e2c
commit
5f9cbf9898
3 changed files with 17 additions and 0 deletions
|
@ -198,6 +198,8 @@ runCommand
|
||||||
--subst-var-by bash ${emacs.stdenv.shell} \
|
--subst-var-by bash ${emacs.stdenv.shell} \
|
||||||
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
||||||
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \
|
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \
|
||||||
|
--subst-var-by wrapperInvocationDirectory "$out/bin/" \
|
||||||
|
--subst-var-by wrapperInvocationName "$progname" \
|
||||||
--subst-var prog
|
--subst-var prog
|
||||||
chmod +x $out/bin/$progname
|
chmod +x $out/bin/$progname
|
||||||
# Create a “NOP” binary wrapper for the pure sake of it becoming a
|
# Create a “NOP” binary wrapper for the pure sake of it becoming a
|
||||||
|
@ -222,6 +224,8 @@ runCommand
|
||||||
--subst-var-by bash ${emacs.stdenv.shell} \
|
--subst-var-by bash ${emacs.stdenv.shell} \
|
||||||
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
|
||||||
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \
|
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp" \
|
||||||
|
--subst-var-by wrapperInvocationDirectory "$out/Applications/Emacs.app/Contents/MacOS/" \
|
||||||
|
--subst-var-by wrapperInvocationName "Emacs" \
|
||||||
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
|
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
|
||||||
chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs
|
chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs
|
||||||
wrapProgramBinary $out/Applications/Emacs.app/Contents/MacOS/Emacs
|
wrapProgramBinary $out/Applications/Emacs.app/Contents/MacOS/Emacs
|
||||||
|
|
3
pkgs/applications/editors/emacs/build-support/wrapper.sh
Normal file → Executable file
3
pkgs/applications/editors/emacs/build-support/wrapper.sh
Normal file → Executable file
|
@ -50,4 +50,7 @@ export emacsWithPackages_siteLisp=@wrapperSiteLisp@
|
||||||
export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
|
export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
|
||||||
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@
|
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@
|
||||||
|
|
||||||
|
export emacsWithPackages_invocationDirectory=@wrapperInvocationDirectory@
|
||||||
|
export emacsWithPackages_invocationName=@wrapperInvocationName@
|
||||||
|
|
||||||
exec @prog@ "$@"
|
exec @prog@ "$@"
|
||||||
|
|
|
@ -39,6 +39,16 @@ least specific (the system profile)"
|
||||||
(setenv "EMACSNATIVELOADPATH" (when new-env-list
|
(setenv "EMACSNATIVELOADPATH" (when new-env-list
|
||||||
(mapconcat 'identity new-env-list ":"))))))
|
(mapconcat 'identity new-env-list ":"))))))
|
||||||
|
|
||||||
|
(let ((wrapper-invocation-directory (getenv "emacsWithPackages_invocationDirectory")))
|
||||||
|
(when wrapper-invocation-directory
|
||||||
|
(setq invocation-directory (file-name-as-directory wrapper-invocation-directory))
|
||||||
|
(setenv "emacsWithPackages_invocationDirectory" nil)))
|
||||||
|
|
||||||
|
(let ((wrapper-invocation-name (getenv "emacsWithPackages_invocationName")))
|
||||||
|
(when wrapper-invocation-name
|
||||||
|
(setq invocation-name wrapper-invocation-name)
|
||||||
|
(setenv "emacsWithPackages_invocationName" nil)))
|
||||||
|
|
||||||
;;; Set up native-comp load path.
|
;;; Set up native-comp load path.
|
||||||
(when (featurep 'native-compile)
|
(when (featurep 'native-compile)
|
||||||
;; Append native-comp subdirectories from `NIX_PROFILES'.
|
;; Append native-comp subdirectories from `NIX_PROFILES'.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue