This commits changes the Emacs wrapper, in order to preload all autoload definitions when built with additional packages. The list of all definitions is generated at build-time. Packages do not need to be (require)d for them to work. Before this change, a code like ```sh nix-shell -I "nixpkgs=$PWD" -p "emacs.pkgs.withPackages(e:[e.magit])" \ --run "emacs -Q -nw -f magit" ``` will fail with the message `Symbol’s function definition is void: magit` After the change, the same code above will open Emacs with magit enabled. A slightly longer startup time of ~10ms was detected in local, informal experiments. More information on autoloading: https://www.gnu.org/software/emacs/manual/html_node/eintr/Autoload.html
48 lines
1 KiB
Bash
48 lines
1 KiB
Bash
#!@bash@
|
|
|
|
IFS=:
|
|
|
|
newLoadPath=()
|
|
newNativeLoadPath=()
|
|
added=
|
|
|
|
if [[ -n $EMACSLOADPATH ]]
|
|
then
|
|
while read -rd: entry
|
|
do
|
|
if [[ -z $entry && -z $added ]]
|
|
then
|
|
newLoadPath+=(@wrapperSiteLisp@)
|
|
added=1
|
|
fi
|
|
newLoadPath+=("$entry")
|
|
done <<< "$EMACSLOADPATH:"
|
|
else
|
|
newLoadPath+=(@wrapperSiteLisp@)
|
|
newLoadPath+=("")
|
|
fi
|
|
|
|
if [[ -n $EMACSNATIVELOADPATH ]]
|
|
then
|
|
while read -rd: entry
|
|
do
|
|
if [[ -z $entry && -z $added ]]
|
|
then
|
|
newNativeLoadPath+=(@wrapperSiteLispNative@)
|
|
added=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@ -l cl-loaddefs -l nix-generated-autoload "$@"
|