forked from mirrors/nixpkgs
emacs: improve setup hook
- Add packages installed in a sub-directory of site-lisp, such as mu4e, to EMACSLOADPATH. - Add ELPA packages to EMACSLOADPATH. - Add each package only once to EMACSLOADPATH. Before, each package would typically be added twice for each transitive dependency leading to a huge variable for a package having many dependencies. Fixed #78680
This commit is contained in:
parent
2547ef9286
commit
2d2de743d0
|
@ -1,13 +1,25 @@
|
||||||
addEmacsVars () {
|
addEmacsVars () {
|
||||||
if test -d $1/share/emacs/site-lisp; then
|
for lispDir in \
|
||||||
# it turns out, that the trailing : is actually required
|
"$1/share/emacs/site-lisp" \
|
||||||
|
"$1/share/emacs/site-lisp/"* \
|
||||||
|
"$1/share/emacs/site-lisp/elpa/"*; do
|
||||||
|
# Add the path to the Emacs load path if it is a directory
|
||||||
|
# containing .el files and it has not already been added to the
|
||||||
|
# load path.
|
||||||
|
if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" && ${EMACSLOADPATH-} != *"$lispDir":* ]] ; then
|
||||||
|
# It turns out, that the trailing : is actually required
|
||||||
# see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html
|
# see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html
|
||||||
export EMACSLOADPATH="$1/share/emacs/site-lisp:${EMACSLOADPATH-}"
|
export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# If this is for a wrapper derivation, emacs and the dependencies are all
|
if [[ ! -v emacsHookDone ]]; then
|
||||||
# run-time dependencies. If this is for precompiling packages into bytecode,
|
emacsHookDone=1
|
||||||
# emacs is a compile-time dependency of the package.
|
|
||||||
addEnvHooks "$hostOffset" addEmacsVars
|
# If this is for a wrapper derivation, emacs and the dependencies are all
|
||||||
addEnvHooks "$targetOffset" addEmacsVars
|
# run-time dependencies. If this is for precompiling packages into bytecode,
|
||||||
|
# emacs is a compile-time dependency of the package.
|
||||||
|
addEnvHooks "$hostOffset" addEmacsVars
|
||||||
|
addEnvHooks "$targetOffset" addEmacsVars
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue