Merge pull request #181174 from ttuegel/emacs-wrapper-package-el

emacsWithPackages: Rely on package.el for autoloads
This commit is contained in:
adisbladis 2022-07-14 00:57:30 +08:00 committed by GitHub
commit 8619d75795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 16 deletions

View File

@ -135,16 +135,10 @@ runCommand
''} ''}
} }
siteAutoloads="$out/share/emacs/site-lisp/nix-generated-autoload.el"
touch $siteAutoloads
# Iterate over the array of inputs (avoiding nix's own interpolation) # Iterate over the array of inputs (avoiding nix's own interpolation)
for pkg in "''${requires[@]}"; do for pkg in "''${requires[@]}"; do
linkEmacsPackage $pkg linkEmacsPackage $pkg
find $pkg -name "*-autoloads.el" \
-exec echo \(load \"{}\" \'noerror \'nomessage\) \; >> $siteAutoloads
done done
echo "(provide 'nix-generated-autoload)" >> $siteAutoloads
siteStart="$out/share/emacs/site-lisp/site-start.el" siteStart="$out/share/emacs/site-lisp/site-start.el"
siteStartByteCompiled="$siteStart"c siteStartByteCompiled="$siteStart"c
@ -180,12 +174,12 @@ runCommand
> "$subdirs" > "$subdirs"
# Byte-compiling improves start-up time only slightly, but costs nothing. # Byte-compiling improves start-up time only slightly, but costs nothing.
$emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" "$subdirs" "$siteAutoloads" $emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" "$subdirs"
${optionalString nativeComp '' ${optionalString nativeComp ''
$emacs/bin/emacs --batch \ $emacs/bin/emacs --batch \
--eval "(add-to-list 'native-comp-eln-load-path \"$out/share/emacs/native-lisp/\")" \ --eval "(add-to-list 'native-comp-eln-load-path \"$out/share/emacs/native-lisp/\")" \
-f batch-native-compile "$siteStart" "$subdirs" "$siteAutoloads" -f batch-native-compile "$siteStart" "$subdirs"
''} ''}
''; '';
@ -197,18 +191,12 @@ runCommand
# Wrap emacs and friends so they find our site-start.el before the original. # Wrap emacs and friends so they find our site-start.el before the original.
for prog in $emacs/bin/*; do # */ for prog in $emacs/bin/*; do # */
local progname=$(basename "$prog") local progname=$(basename "$prog")
local autoloadExpression=""
rm -f "$out/bin/$progname" rm -f "$out/bin/$progname"
if [[ $progname == emacs ]]; then
# progs other than "emacs" do not understand the `-l` switches
autoloadExpression="-l cl-loaddefs -l nix-generated-autoload"
fi
substitute ${./wrapper.sh} $out/bin/$progname \ substitute ${./wrapper.sh} $out/bin/$progname \
--subst-var-by bash ${emacs.stdenv.shell} \ --subst-var-by bash ${emacs.stdenv.shell} \
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \ --subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp:" \ --subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp:" \
--subst-var autoloadExpression \
--subst-var prog --subst-var prog
chmod +x $out/bin/$progname chmod +x $out/bin/$progname
done done
@ -228,7 +216,6 @@ runCommand
--subst-var-by bash ${emacs.stdenv.shell} \ --subst-var-by bash ${emacs.stdenv.shell} \
--subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \ --subst-var-by wrapperSiteLisp "$deps/share/emacs/site-lisp" \
--subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp:" \ --subst-var-by wrapperSiteLispNative "$deps/share/emacs/native-lisp:" \
--subst-var-by autoloadExpression "-l cl-loaddefs -l nix-generated-autoload" \
--subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs" --subst-var-by prog "$emacs/Applications/Emacs.app/Contents/MacOS/Emacs"
chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs chmod +x $out/Applications/Emacs.app/Contents/MacOS/Emacs
fi fi

View File

@ -44,4 +44,4 @@ export emacsWithPackages_siteLisp=@wrapperSiteLisp@
export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}" export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@ export emacsWithPackages_siteLispNative=@wrapperSiteLispNative@
exec @prog@ @autoloadExpression@ "$@" exec @prog@ "$@"