diff options
author | Robert Helgesson <robert@rycee.net> | 2020-03-14 19:28:24 +0100 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2020-03-14 19:46:28 +0100 |
commit | 2d2de743d0ece3931c01a04043c218b76dfc5cf6 (patch) | |
tree | 8831bf42c38671e3ca16518f4ccde332f68c5589 /pkgs/build-support/emacs | |
parent | 2547ef92863f0fa7fe9073bd71047a66c4923e5d (diff) | |
download | nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.tar nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.tar.gz nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.tar.bz2 nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.tar.lz nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.tar.xz nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.tar.zst nixpkgs-2d2de743d0ece3931c01a04043c218b76dfc5cf6.zip |
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
Diffstat (limited to 'pkgs/build-support/emacs')
-rw-r--r-- | pkgs/build-support/emacs/setup-hook.sh | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/pkgs/build-support/emacs/setup-hook.sh b/pkgs/build-support/emacs/setup-hook.sh index b210511d670..8f074e0b406 100644 --- a/pkgs/build-support/emacs/setup-hook.sh +++ b/pkgs/build-support/emacs/setup-hook.sh @@ -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 |