]> git.eshelyaron.com Git - emacs.git/commitdiff
Make 'compile' respect buffer-local process environment
authorAugusto Stoffel <arstoffel@gmail.com>
Thu, 16 Sep 2021 14:06:29 +0000 (16:06 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 16 Sep 2021 14:06:29 +0000 (16:06 +0200)
* lisp/progmodes/compile.el (compilation-start): Use
`process-environment' from original buffer in the compilation
process (bug#50607).

lisp/progmodes/compile.el

index 8d1486b6e687a35b5f07b68770e0c7472fed8dfa..431b01b8ba912b67f9b84ecdb8db13afd5154eb3 100644 (file)
@@ -1783,6 +1783,9 @@ Returns the compilation buffer created."
            (replace-regexp-in-string "-mode\\'" "" (symbol-name mode))))
         (thisdir default-directory)
         (thisenv compilation-environment)
+         (buffer-path (and (local-variable-p 'exec-path) exec-path))
+         (buffer-env (and (local-variable-p 'process-environment)
+                          process-environment))
         outwin outbuf)
     (with-current-buffer
        (setq outbuf
@@ -1850,6 +1853,12 @@ Returns the compilation buffer created."
         ;; NB: must be done after (funcall mode) as that resets local variables
         (setq-local compilation-directory thisdir)
         (setq-local compilation-environment thisenv)
+        (if buffer-path
+            (setq-local exec-path buffer-path)
+          (kill-local-variable 'exec-path))
+        (if buffer-env
+            (setq-local process-environment buffer-env)
+          (kill-local-variable 'process-environment))
        (if highlight-regexp
             (setq-local compilation-highlight-regexp highlight-regexp))
         (if (or compilation-auto-jump-to-first-error