From f803ce025b4161bea68f115ac50ba1174ef863e3 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index 7a02c3a896..52873d2f29 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1779,6 +1779,9 @@ compilation-start (replace-regexp-in-string "-mode\\'" "" (symbol-name mode)))) (thisdir default-directory) (thisenv compilation-environment) + (bufferenv (if (local-variable-p 'process-environment) + process-environment + 'global)) outwin outbuf) (with-current-buffer (setq outbuf @@ -1846,6 +1849,9 @@ 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 (eq bufferenv 'global) + (kill-local-variable 'process-environment) + (setq-local process-environment bufferenv)) (if highlight-regexp (setq-local compilation-highlight-regexp highlight-regexp)) (if (or compilation-auto-jump-to-first-error -- 2.30.2