From e46913ec1f0e3f839dd8a36022095587b1962ac5 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index af7b8292b7..1c11b7707e 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) + (bufferenv (when (local-variable-p 'process-environment) + (cons exec-path process-environment))) outwin outbuf) (with-current-buffer (setq outbuf @@ -1850,6 +1852,11 @@ 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 bufferenv + (setq-local exec-path (car bufferenv) + process-environment (cdr bufferenv)) + (kill-local-variable 'exec-path) + (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