emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Buffer-local process environments


From: Arthur Miller
Subject: Re: [PATCH] Buffer-local process environments
Date: Sat, 28 Aug 2021 17:27:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Arthur Miller <arthur.miller@live.com>
>> Cc: Augusto Stoffel <arstoffel@gmail.com>,  michael.albinus@gmx.de,
>>   monnier@iro.umontreal.ca,  emacs-devel@gnu.org
>> Date: Sat, 28 Aug 2021 16:06:19 +0200
>> 
>> > And I'm not sure I understand the rationale, and you didn't describe
>> > it.  Environment variables and PATH in particular are generally global
>> > on the entire system, so what does this feature correspond to?
>> > separate environment variables in each shell window?  Why would anyone
>> > want to do that?  And why should we make it easier by providing
>> > buffer-local values of those, instead of letting each Lisp program
>> > that needs it let-bind the variables instead?
>> 
>> Excuse me if I ask here, it is probably more help than contribution to this
>> discussion. Is it possible to let-bind environment variables so that a
>> subprocess inherit those? 
>
> Of course.  You let-bind process-environment, and then change the
> local value.  We have a number of places where we do that.

Ah, ok, I thought it process-environment was for entire Emacs, globally. I just
was looking at docs, I haven't seen examples in the code. Thanks.

>> (defun emacs-vision--get-date ()
>>   (let ((lang (concat "LANG=" emacs-vision-locale))
>>         (lctime (concat "LC_TIME=" emacs-vision-locale)))
>>     (with-temp-buffer
>>       (insert
>>        (shell-command-to-string
>>         (concat lang lctime " date +'%A, %B %d'")))
>>       (goto-char (- (point-max) 1))
>>       (buffer-substring-no-properties
>>        (line-beginning-position) (line-end-position)))))
>> 
>> Do I understand correctly, this patch will let me have separate process
>> environment, so I could use separate environment variables in subprocess?
>
> Yes, but that's not what you were asking about, I believe.

Now you make me confused again :). I want my process to use different env for
LANG and LC_TIME, but Emacs should continue to work with old values. Concretely
I want english date string, but my Emacs should continue to use swedish for it's
normal use.

So if I let-bind, it will be reflected only localy in that let scope, and the
subprocess will inherit that local environment too? That is what I want, and why
I went via shell command. Forgive me if I am confused. I hope what you said
above is what I want :-).



reply via email to

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