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: Augusto Stoffel
Subject: Re: [PATCH] Buffer-local process environments
Date: Sat, 28 Aug 2021 15:54:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

On Sat, 28 Aug 2021 at 15:18, Michael Albinus <michael.albinus@gmx.de> wrote:

> Augusto Stoffel <arstoffel@gmail.com> writes:
>
>>> W/o further reading, this cannot be right. Elements of
>>> `process-environment' have always the syntax "VAR=VALUE". You add only a
>>> VALUE (`exec-path') in `bufferenv'. I understand your intention, using
>>> `bufferenv' as transportation vehicle, but I believe this is
>>> mis-designed, and good for trouble. If not now, then later.
>>
>> This is a temporary, lexical variable that is inaccessible to the user
>> directly.  It's "destructured" again in the next hunk of the patch.
>
> I've seen this. But we shall avoid this dirty kind of programming, even
> if it is internal only.

In this case, here is a variation that handles the two lists separately.

(It will have a surprising effect if some of these lists is empty, but
this should never happen --- and the solution would be to wrap the lists
in a cons, which you don't like...)

>From a104e1eae100f01585587df30f49866f3b038785 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Thu, 29 Apr 2021 12:45:04 +0200
Subject: [PATCH] Make 'compile' respect buffer-local process environment

* lisp/progmodes/compile.el (compilation-start): Use
`process-environment' from original buffer in the compilation process.
---
 lisp/progmodes/compile.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index af7b8292b7..bdf20a3f51 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1783,6 +1783,8 @@ compilation-start
            (replace-regexp-in-string "-mode\\'" "" (symbol-name mode))))
         (thisdir default-directory)
         (thisenv compilation-environment)
+         (bufferpath (when (local-variable-p 'exec-path) exec-path))
+         (bufferenv (when (local-variable-p 'process-environment) 
process-environment))
         outwin outbuf)
     (with-current-buffer
        (setq outbuf
@@ -1850,6 +1852,12 @@ compilation-start
         ;; NB: must be done after (funcall mode) as that resets local variables
         (setq-local compilation-directory thisdir)
         (setq-local compilation-environment thisenv)
+        (if bufferpath
+            (setq-local exec-path bufferpath)
+          (kill-local-variable 'exec-path))
+        (if bufferenv
+            (setq-local process-environment bufferenv)
+          (kill-local-variable 'process-environment))
        (if highlight-regexp
             (setq-local compilation-highlight-regexp highlight-regexp))
         (if (or compilation-auto-jump-to-first-error
-- 
2.31.1


reply via email to

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