git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #82604 from rycee/fix/emacs-setup-hook

emacs: improve setup hook

commitd15090dbe6f538e3dafca625bdc9ab1b5542f55d authoradisbladis <adisbladis@gmail.com> dateSun 15 Mar 2020, 01:20 (7 years ago) parentcf719bf2d2de74
1 file changed+21−9
pkgs/build-support/emacs/setup-hook.sh+21−9
pkgs/build-support/emacs/setup-hook.sh+21−9
@@ -1,13 +1,25 @@
11addEmacsVars () {
2− if test -d $1/share/emacs/site-lisp; then
3− # it turns out, that the trailing : is actually required
2+ for lispDir in \
3+ "$1/share/emacs/site-lisp" \
4+ "$1/share/emacs/site-lisp/"* \
5+ "$1/share/emacs/site-lisp/elpa/"*; do
6+ # Add the path to the Emacs load path if it is a directory
7+ # containing .el files and it has not already been added to the
8+ # load path.
9+ if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" && ${EMACSLOADPATH-} != *"$lispDir":* ]] ; then
10+ # It turns out, that the trailing : is actually required
411 # see https://www.gnu.org/software/emacs/manual/html_node/elisp/Library-Search.html
5− export EMACSLOADPATH="$1/share/emacs/site-lisp:${EMACSLOADPATH-}"
6− fi
12+ export EMACSLOADPATH="$lispDir:${EMACSLOADPATH-}"
13+ fi
14+ done
715}
816
9−# If this is for a wrapper derivation, emacs and the dependencies are all
10−# run-time dependencies. If this is for precompiling packages into bytecode,
11−# emacs is a compile-time dependency of the package.
12−addEnvHooks "$hostOffset" addEmacsVars
13−addEnvHooks "$targetOffset" addEmacsVars
17+if [[ ! -v emacsHookDone ]]; then
18+ emacsHookDone=1
19+
20+ # If this is for a wrapper derivation, emacs and the dependencies are all
21+ # run-time dependencies. If this is for precompiling packages into bytecode,
22+ # emacs is a compile-time dependency of the package.
23+ addEnvHooks "$hostOffset" addEmacsVars
24+ addEnvHooks "$targetOffset" addEmacsVars
25+fi