bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

classic Classic list List threaded Threaded
9 messages Options
Tad
Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Tad
Emacs populates `load-path' at startup from `$EMACSLOADPATH' in the
process environment. It would be useful to have an
`$EMACSNATIVELOADPATH' or equivalent to populate `comp-eln-load-path'.

I have implemented a workaround in NixOS with some code in
`site-start.el', but it would probably be useful in other contexts as
well.

    ;; Append paths set via `EMACSNATIVELOADPATH', an environment
    ;; variable made up for this purpose.
    (when-let ((path-env (getenv "EMACSNATIVELOADPATH"))
               (paths-from-env (split-string path-env))
               (paths (seq-filter (lambda (path) (not (string= "" path)))
                                  paths-from-env)))
      (setq comp-eln-load-path
            (append paths comp-eln-load-path)))

Thanks,
Tad



Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Emacs - Bugs mailing list
Tad <[hidden email]> writes:

> Emacs populates `load-path' at startup from `$EMACSLOADPATH' in the
> process environment. It would be useful to have an
> `$EMACSNATIVELOADPATH' or equivalent to populate `comp-eln-load-path'.
>
> I have implemented a workaround in NixOS with some code in
> `site-start.el', but it would probably be useful in other contexts as
> well.
>
>     ;; Append paths set via `EMACSNATIVELOADPATH', an environment
>     ;; variable made up for this purpose.
>     (when-let ((path-env (getenv "EMACSNATIVELOADPATH"))
>                (paths-from-env (split-string path-env))
>                (paths (seq-filter (lambda (path) (not (string= "" path)))
>                                   paths-from-env)))
>       (setq comp-eln-load-path
>             (append paths comp-eln-load-path)))

Wouldn't EMACS_NATIVE_LOAD_PATH be more idiomatic?

  Andrea



Tad
Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Tad
On Wed, Nov 18, 2020 at 1:15 PM Andrea Corallo <[hidden email]> wrote:

> Wouldn't EMACS_NATIVE_LOAD_PATH be more idiomatic?

I don't have a personal preference regarding the name. However, looking
at [1], we don't generally use underscores in the variables we support.
Some do have underscores, such as `DBUS_SESSION_BUS_ADDRESS' and `LC_*',
but these are standardized outside of Emacs and used by other programs.

[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html



Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Emacs - Bugs mailing list
Tad <[hidden email]> writes:

> On Wed, Nov 18, 2020 at 1:15 PM Andrea Corallo <[hidden email]> wrote:
>
>> Wouldn't EMACS_NATIVE_LOAD_PATH be more idiomatic?
>
> I don't have a personal preference regarding the name. However, looking
> at [1], we don't generally use underscores in the variables we support.
> Some do have underscores, such as `DBUS_SESSION_BUS_ADDRESS' and `LC_*',
> but these are standardized outside of Emacs and used by other programs.
>
> [1] https://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html

Fair.

Other question, shouldn't we use ":" as separator as in PATH?  I'm
asking because I see in your snippet you don't so I was wondering if
that's intentional.



Tad
Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Tad
On Wed, Nov 18, 2020 at 1:41 PM Andrea Corallo <[hidden email]> wrote:

> Other question, shouldn't we use ":" as separator as in PATH?  I'm
> asking because I see in your snippet you don't so I was wondering if
> that's intentional.

That's not intentional, and thanks for catching that! Yes, ":" should
be used as the separator.



Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Emacs - Bugs mailing list
Tad <[hidden email]> writes:

> On Wed, Nov 18, 2020 at 1:41 PM Andrea Corallo <[hidden email]> wrote:
>
>> Other question, shouldn't we use ":" as separator as in PATH?  I'm
>> asking because I see in your snippet you don't so I was wondering if
>> that's intentional.
>
> That's not intentional, and thanks for catching that! Yes, ":" should
> be used as the separator.

Last question, what is specific need to filter out empty strings after
splitting?

  Andrea



Tad
Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Tad
On Thu, Nov 19, 2020 at 11:52 AM Andrea Corallo <[hidden email]> wrote:

> Last question, what is specific need to filter out empty strings after
> splitting?

NixOS has code which appends an extra path separator[1], which looks
like:

    # 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-}"

The link to the Emacs manual leads to a section containing the text:

    An empty element in the value of the environment variable, whether
    trailing (as in the above example), leading, or embedded, is
    replaced by the default value of load-path as determined by the
    standard initialization procedure. If there are no such empty
    elements, then EMACSLOADPATH specifies the entire load-path. You
    must include either an empty element, or the explicit path to the
    directory containing the standard Lisp files, else Emacs will not
    function. (Another way to modify load-path is to use the -L
    command-line option when starting Emacs; see below.)

As the code I posted above simply prepends the value of this variable to
`comp-eln-load-path', which is already initialized with appropriate
default values, I didn't believe the special handling of empty path
entries was warranted in site-start.el. It would be consistent for
`comp' to implement the behavior as is done for `EMACSLOADPATH',
however.

[1] https://github.com/NixOS/nixpkgs/blob/bf486f784ddd969c03243dba4c93d0e8e861173e/pkgs/build-support/emacs/setup-hook.sh#L4-L6



Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Emacs - Bugs mailing list
Hi Tad,

a55415af7e should do what we want.

Okay to close?

Thanks

  Andrea



Reply | Threaded
Open this post in threaded view
|

bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment

Emacs - Bugs mailing list
Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[hidden email]> writes:

> Hi Tad,
>
> a55415af7e should do what we want.
>
> Okay to close?
>
> Thanks
>
>   Andrea

Closing this as I think is fulfilled.

Happy to repopen in case it's not :)

  Andrea