Commit Graph

8 Commits

Author SHA1 Message Date
Lin Jian
3e025f1393 emacsWithPackages: add a note for EMACSNATIVELOADPATH 2023-08-25 17:42:21 +00:00
Lin Jian
d380784357 emacsWithPackages: fix logic of adding EMACSNATIVELOADPATH
Without this change, EMACSNATIVELOADPATH will not be added if
EMACSLOADPATH is added.
2023-08-25 17:42:21 +00:00
Thomas Tuegel
017fa2d7a0
emacsWithPackages: Rely on package.el for autoloads
The builtin `package.el` functionality is necessary and sufficient to handle
autoloads in the Emacs wrapper.
2022-07-11 20:22:20 -05:00
Daniel Nagy
0f316e5553
emacsWrapper: fix mishandling of empty package list
The native compiler of emacs does not handle empty files well.

This arose in https://github.com/NixOS/nixpkgs/pull/168954 .
2022-04-19 21:12:45 +02:00
Daniel Nagy
4489718d8f
emacsWrapper: preload autoloads
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
2022-04-17 14:36:24 +02:00
Tad Fisher
a7cb8e36ac
emacs: Add comp-eln-load-path infrastructure 2020-12-16 19:45:07 +01:00
Alyssa Ross
23d4bfb666
emacsWithPackages: don't tell sub-Emacs about pkgs
If I'm running an Emacs executable from emacsWithPackages as my main
programming environment, and I'm hacking on Emacs, or the Emacs
packaging in Nixpkgs, or whatever, I don't want the Emacs packages
from the wrapper to show up in the load path of that child Emacs.  It
results in differing behaviour depending on whether the child Emacs is
run from Emacs or from, for example, an external terminal emulator,
which is very surprising.

To avoid this, pass another environment variable containing the
wrapper site-lisp path, and use that value to remove the corresponding
entry in EMACSLOADPATH, so it won't be propagated to child Emacsen.
2020-12-10 22:52:31 +00:00
Alyssa Ross
0127013b0f
emacsWithPackages: mutate EMACSLOADPATH correctly
An empty entry in EMACSLOADPATH gets filled with the default value.
This is presumably why the wrapper inserted a colon after the entry it
added for the dependencies.  But this naive approach wasn't always
correct.

For example, if the user ran emacs with EMACSLOADPATH=foo, the wrapper
would insert the default value (by adding the trailing `:') even
though the user was trying to expressly opt out of it.

To do this correctly, here I've replaced makeWrapper with a bespoke
script that will actually parse the EMACSLOADPATH provided in the
environment (if given), and insert the wrapper's load path just before
the default value.  If EMACSLOADPATH is given but contains no default
value, we respect that and don't add the wrapped dependencies at all.
If no EMACSLOADPATH is given, we insert the wrapped dependencies
before the default value, just like before.  In this way, the wrapped
Emacs should now behave as if the wrapped dependencies were part of
Emacs's default load-path value.
2020-12-10 22:35:57 +00:00