unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: michael.albinus@gmx.de, Augusto Stoffel <arstoffel@gmail.com>,
	monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: [PATCH] Buffer-local process environments
Date: Sat, 28 Aug 2021 16:06:19 +0200	[thread overview]
Message-ID: <AM9PR09MB4977AA00F38A2674D57C97F196C99@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <837dg5oidr.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 28 Aug 2021 15:37:04 +0300")

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.




  parent reply	other threads:[~2021-08-28 14:06 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29 10:56 Buffer-local process environments Augusto Stoffel
2021-04-29 12:30 ` Eli Zaretskii
2021-04-29 12:40   ` Augusto Stoffel
2021-04-29 12:52     ` Eli Zaretskii
2021-04-29 13:06       ` Augusto Stoffel
2021-04-29 14:02 ` Stefan Monnier
2021-04-29 17:26   ` Augusto Stoffel
2021-04-29 17:34     ` Michael Albinus
2021-04-30  7:29       ` Augusto Stoffel
2021-04-30  7:48         ` Michael Albinus
2021-04-30 15:19           ` Augusto Stoffel
2021-04-30 15:51             ` Michael Albinus
2021-05-02  6:13               ` Augusto Stoffel
2021-05-08 17:51                 ` Michael Albinus
2021-05-09  5:06                   ` Augusto Stoffel
2021-05-09 16:38                     ` Michael Albinus
2021-08-28 12:28                       ` [PATCH] " Augusto Stoffel
2021-08-28 12:37                         ` Eli Zaretskii
2021-08-28 12:55                           ` Augusto Stoffel
2021-09-01 10:42                             ` Stephen Leake
2021-09-01 10:56                               ` Augusto Stoffel
2021-09-01 22:38                                 ` Stephen Leake
2021-09-02  7:14                                   ` Augusto Stoffel
2021-09-06 15:17                                     ` Stephen Leake
2021-08-28 14:06                           ` Arthur Miller [this message]
2021-08-28 14:33                             ` Eli Zaretskii
2021-08-28 15:27                               ` Arthur Miller
2021-08-28 15:38                                 ` Eli Zaretskii
2021-08-28 16:48                                   ` Arthur Miller
2021-08-28 15:39                                 ` Augusto Stoffel
2021-08-28 16:43                                   ` Arthur Miller
2021-08-28 12:47                         ` Michael Albinus
2021-08-28 12:59                           ` Augusto Stoffel
2021-08-28 13:18                             ` Michael Albinus
2021-08-28 13:54                               ` Augusto Stoffel
2021-08-28 14:05                               ` Stefan Monnier
2021-08-28 15:19                                 ` Augusto Stoffel
2021-04-30 15:32           ` Augusto Stoffel
2021-04-30 15:55             ` Michael Albinus
2021-04-29 15:37 ` Michael Albinus
2021-04-29 17:31   ` Augusto Stoffel
2021-04-29 17:44     ` Michael Albinus
2021-04-30  7:00       ` Augusto Stoffel
2021-04-30  7:25         ` Michael Albinus
2021-05-02 13:45 ` Stephen Leake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB4977AA00F38A2674D57C97F196C99@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=arstoffel@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).