depot/third_party/nixpkgs/pkgs/build-support/emacs/emacs-funcs.sh
Default email bb5b50588c Project import generated by Copybara.
GitOrigin-RevId: 9816b99e71c3504b0b4c1f8b2e004148460029d4
2021-02-19 20:06:45 +01:00

34 lines
1.1 KiB
Bash

addToEmacsLoadPath() {
local lispDir="$1"
if [[ -d $lispDir && ${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="$lispDir:${EMACSLOADPATH-}"
fi
}
addToEmacsNativeLoadPath() {
local nativeDir="$1"
if [[ -d $nativeDir && ${EMACSNATIVELOADPATH-} != *"$nativeDir":* ]]; then
export EMACSNATIVELOADPATH="$nativeDir:${EMACSNATIVELOADPATH-}"
fi
}
addEmacsVars () {
addToEmacsLoadPath "$1/share/emacs/site-lisp"
if [ -n "${addEmacsNativeLoadPath:-}" ]; then
addToEmacsNativeLoadPath "$1/share/emacs/native-lisp"
fi
# Add sub paths to the Emacs load path if it is a directory
# containing .el files. This is necessary to build some packages,
# e.g., using trivialBuild.
for lispDir in \
"$1/share/emacs/site-lisp/"* \
"$1/share/emacs/site-lisp/elpa/"*; do
if [[ -d $lispDir && "$(echo "$lispDir"/*.el)" ]] ; then
addToEmacsLoadPath "$lispDir"
fi
done
}