0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 14:10:33 +03:00

Merge pull request #82604 from rycee/fix/emacs-setup-hook

emacs: improve setup hook
This commit is contained in:
adisbladis 2020-03-15 01:20:41 +00:00 committed by GitHub
commit d15090dbe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,13 +1,25 @@
addEmacsVars () {
if test -d $1/share/emacs/site-lisp; then
# it turns out, that the trailing : is actually required
for lispDir in \
"$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
export EMACSLOADPATH="$1/share/emacs/site-lisp:${EMACSLOADPATH-}"
fi
export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}"
fi
done
}
# If this is for a wrapper derivation, emacs and the dependencies are all
# 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
if [[ ! -v emacsHookDone ]]; then
emacsHookDone=1
# If this is for a wrapper derivation, emacs and the dependencies are all
# 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