unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
@ 2020-11-18 21:05 Tad
  2020-11-18 21:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-11-20 14:43 ` Stefan Monnier
  0 siblings, 2 replies; 10+ messages in thread
From: Tad @ 2020-11-18 21:05 UTC (permalink / raw)
  To: 44726; +Cc: Andrea Corallo

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-18 21:05 bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment Tad
@ 2020-11-18 21:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-11-18 21:20   ` Tad
  2020-11-20 14:43 ` Stefan Monnier
  1 sibling, 1 reply; 10+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-11-18 21:15 UTC (permalink / raw)
  To: Tad; +Cc: 44726

Tad <tadfisher@gmail.com> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-18 21:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-11-18 21:20   ` Tad
  2020-11-18 21:41     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Tad @ 2020-11-18 21:20 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: 44726

On Wed, Nov 18, 2020 at 1:15 PM Andrea Corallo <akrl@sdf.org> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-18 21:20   ` Tad
@ 2020-11-18 21:41     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-11-18 21:45       ` Tad
  0 siblings, 1 reply; 10+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-11-18 21:41 UTC (permalink / raw)
  To: Tad; +Cc: 44726

Tad <tadfisher@gmail.com> writes:

> On Wed, Nov 18, 2020 at 1:15 PM Andrea Corallo <akrl@sdf.org> 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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-18 21:41     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-11-18 21:45       ` Tad
  2020-11-19 19:52         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Tad @ 2020-11-18 21:45 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: 44726

On Wed, Nov 18, 2020 at 1:41 PM Andrea Corallo <akrl@sdf.org> 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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-18 21:45       ` Tad
@ 2020-11-19 19:52         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-11-19 22:50           ` Tad
  0 siblings, 1 reply; 10+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-11-19 19:52 UTC (permalink / raw)
  To: Tad; +Cc: 44726

Tad <tadfisher@gmail.com> writes:

> On Wed, Nov 18, 2020 at 1:41 PM Andrea Corallo <akrl@sdf.org> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-19 19:52         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-11-19 22:50           ` Tad
  2020-11-20 10:03             ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Tad @ 2020-11-19 22:50 UTC (permalink / raw)
  To: Andrea Corallo; +Cc: 44726

On Thu, Nov 19, 2020 at 11:52 AM Andrea Corallo <akrl@sdf.org> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-19 22:50           ` Tad
@ 2020-11-20 10:03             ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2020-11-30 23:25               ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 10+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-11-20 10:03 UTC (permalink / raw)
  To: Tad; +Cc: 44726

Hi Tad,

a55415af7e should do what we want.

Okay to close?

Thanks

  Andrea





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-18 21:05 bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment Tad
  2020-11-18 21:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-11-20 14:43 ` Stefan Monnier
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Monnier @ 2020-11-20 14:43 UTC (permalink / raw)
  To: Tad; +Cc: 44726, Andrea Corallo

> 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'.

Can you explain why you need that?

The eln-load-path is basically a list of cache-directories, so it plays
a role fairly different from that of EMACSLOADPATH.


        Stefan






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment
  2020-11-20 10:03             ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2020-11-30 23:25               ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 10+ messages in thread
From: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2020-11-30 23:25 UTC (permalink / raw)
  To: Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
  Cc: Tad, 44726-done

Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@gnu.org> 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





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-30 23:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 21:05 bug#44726: 28.0.50; [feature/native-comp] Provide a mechanism to populate comp-eln-load-path from the environment Tad
2020-11-18 21:15 ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-18 21:20   ` Tad
2020-11-18 21:41     ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-18 21:45       ` Tad
2020-11-19 19:52         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-19 22:50           ` Tad
2020-11-20 10:03             ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-30 23:25               ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-11-20 14:43 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).