emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Buffer-local process environments


From: Michael Albinus
Subject: Re: Buffer-local process environments
Date: Fri, 30 Apr 2021 17:51:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Augusto Stoffel <arstoffel@gmail.com> writes:

>> Because there's a lot of functions out there, which work for the local
>> host, and should work also for remote hosts. See for example
>> vc-git-grep, which has
>>
>> (let ((default-directory dir)
>>       (compilation-environment (cons "PAGER=" compilation-environment)))
>>
>> compilation-environment will be propagated to process-environment later
>> on. And the setting for PAGER is needed for both local and remote
>> instances of vc-git-grep. There's no special code in vc-git-grep for the
>> remote case.
>
> Some observations:
>
> 1. In this case, one could call "git --no-pager" instead of relying on
>    an env var.
>
> 2. PAGER is overridden by `tramp-remote-process-environment' anyway,
>    right?  And unlike something of the likes of PYTHONPATH, I see no
>    reason to customize PAGER.
>
> 3. If Tramp checked for the buffer-local value of process-environment
>    instead of the default value, then the patch for compile.el I
>    attached yesterday wouldn't break for remote directories, and the
>    let-binding trick in your example would still work.

Please, it is just an example. And Tramp settings, like PAGER, have been
added later on.

A simple rgrep for "(process-environment" over Emacs' lisp directory
shows you several other hits, some of them are good for this discussion:

./vc/vc-bzr.el97:      (let ((process-environment (cons (format "BZR_LOG=%s" 
null-device)
./vc/vc-hg.el1432:             (process-environment (cons "HGPLAIN=1" 
process-environment))
./vc/vc-hg.el1507:         (process-environment (cons "HGPLAIN=1" 
process-environment))
./vc/vc-hg.el1522:  (let ((process-environment (cons "HGPLAIN=1" 
process-environment))
./vc/vc-dispatcher.el328:             (process-environment (cons 
"LC_MESSAGES=C" process-environment))

This list is not comprehensive, of course. And again, I have no idea
what is used in the wild.

> So I wonder:
>
> A. Are there more compelling examples showing that Lisp code needs
>    fine-grained control over variables being exported to a remote host?
>
> B. There is probably a small list of variables that should be preserved
>    across machines, while there is an unbounded quantity of variables
>    that probably only make sense machine-locally (e.g., any variable
>    holding directory names).
>
> In view of 3., one could introduce the convention that the buffer-local
> value of `process-environment' is for "project-local" variables, and the
> let-bound value is for variables that make sense even on remote machines.
>
> I'm not sure this is a good proposal, though.  It's a subtle rule, and
> it could be quite brittle and hard to use.

Honestly, the hack we have now is already annoying, at least to me. I
would prefer to have something more solid to apply.

> An alternative proposal is to introduce a variable
> `remote-exported-variables', which anyone could set or let-bind or even
> override on a connection-local basis.  The value of any variable whose
> name appears in this list would be passed though a remote connection.
> This proposal would make a lot of sense if assumption B. is true.

There is already tramp-remote-process-environment, for many years. Not
much appreciated by package authors.

Best regards, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]