summaryrefslogtreecommitdiffstats
path: root/pkgs/applications/editors/emacs/setup-hook.sh
blob: 15b1840de2c1439033298d799c47ab57bfec33a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
}

addEnvHooks "$targetOffset" addEmacsVars