Make 'python-shell--with-environment' respect buffer-local vars
authorEvgenii Klimov <eugene.dev@lipklim.org>
Thu, 29 Aug 2024 22:36:12 +0000 (23:36 +0100)
committerEli Zaretskii <eliz@gnu.org>
Sat, 31 Aug 2024 10:16:42 +0000 (13:16 +0300)
* lisp/progmodes/python.el (python-shell--with-environment):
Make `with-temp-buffer' respect buffer-local values of
`process-environment' and `exec-path', if set.  (Bug#72849)

lisp/progmodes/python.el

index 227be64b5b0f16450268f4714bbedccdab65919b..a50446343a0a430542a6dcd6e1d63ee6a49d789c 100644 (file)
@@ -3030,11 +3030,11 @@ machine then modifies `tramp-remote-process-environment' and
                  (tramp-dissect-file-name default-directory 'noexpand)))))
     (if vec
         (python-shell--tramp-with-environment vec extraenv bodyfun)
-      (let ((process-environment
-             (append extraenv process-environment))
-            (exec-path
-             ;; FIXME: This is still Python-specific.
-             (python-shell-calculate-exec-path)))
+      (cl-letf (((default-value 'process-environment)
+                (append extraenv process-environment))
+               ((default-value 'exec-path)
+                ;; FIXME: This is still Python-specific.
+                (python-shell-calculate-exec-path)))
         (funcall bodyfun)))))
 
 (defun python-shell--tramp-with-environment (vec extraenv bodyfun)