[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 16:06:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Augusto Stoffel <arstoffel@gmail.com>
>> Date: Sat, 28 Aug 2021 14:28:59 +0200
>>
>> Specifically, whenever `compile' is called from a buffer where
>> `process-environment' is local, the *compilation* buffer inherits the
>> original buffer's `process-environment' and `exec-path'. When
>> `process-environment' is not local in the buffer from which `compile'
>> is called, any local values of those two variables are killed in the
>> *compilation* buffer as well. (There's no check for buffer-localness
>> of `exec-path' because it's usually misguided to keep it out of sync
>> with PATH.)
>
> Thanks. The patch should be accompanied by a suitable documentation
> change, of course.
>
> 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?
I just wrote today a piece of code where I wanted to start a process with
different environment variables than what Emacs has, for LANG and LC_TIME. I
didn't know of other way to easily pass environment vars, other than to start
new shell process. If it is possible to use some process apis to change process
environment I would happily use them instead of starting an intermediate shell
process. I am really not happy to use shell there.
(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?
Otherwise if I can let-bind environment vars it would be even better.
Re: [PATCH] Buffer-local process environments, Michael Albinus, 2021/08/28