summary refs log tree commit diff
path: root/pkgs/build-support/emacs/wrapper.sh
blob: 44762bd4582b0b06ad416ee6a216c3e891b23f9c (plain) (blame)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!@bash@

IFS=:

newLoadPath=()
newNativeLoadPath=()
addedNewLoadPath=
addedNewNativeLoadPath=

if [[ -n $EMACSLOADPATH ]]
then
    while read -rd: entry
    do
        if [[ -z $entry && -z $addedNewLoadPath ]]
        then
            newLoadPath+=(@wrapperSiteLisp@)
            addedNewLoadPath=1
        fi
        newLoadPath+=("$entry")
    done <<< "$EMACSLOADPATH:"
else
    newLoadPath+=(@wrapperSiteLisp@)
    newLoadPath+=("")
fi

# NOTE: Even though we treat EMACSNATIVELOADPATH like EMACSLOADPATH in
# this wrapper, empty elements in EMACSNATIVELOADPATH have no special
# meaning for Emacs.  Only non-empty elements in EMACSNATIVELOADPATH
# will be prepended to native-comp-eln-load-path.
# https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/startup.el?id=3685387e609753293c4518be75e77c659c3b2d8d#n599
if [[ -n $EMACSNATIVELOADPATH ]]
then
    while read -rd: entry
    do
        if [[ -z $entry && -z $addedNewNativeLoadPath ]]
        then
            newNativeLoadPath+=(@wrapperSiteLispNative@)
            addedNewNativeLoadPath=1
        fi
        newNativeLoadPath+=("$entry")
    done <<< "$EMACSNATIVELOADPATH:"
else
    newNativeLoadPath+=(@wrapperSiteLispNative@)
    newNativeLoadPath+=("")
fi

export EMACSLOADPATH="${newLoadPath[*]}"
export emacsWithPackages_siteLisp=@wrapperSiteLisp@

export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@

exec @prog@ "$@"