branch: elpa/with-editor
commit bc6520b269b498855d472602e5102a6f401134d8
Author: Noam Postavsky <[email protected]>
Commit: Noam Postavsky <[email protected]>
Replace setenv with push on process-environment
Let-binding process-environment does not nessarily protect from changes
made by setenv, because setenv may destructively modify the list object.
---
with-editor.el | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/with-editor.el b/with-editor.el
index a9abedc..3ebde90 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -377,7 +377,8 @@ ENVVAR is provided then bind that environment variable
instead.
(process-environment process-environment))
(if (or (not with-editor-emacsclient-executable)
(file-remote-p default-directory))
- (setenv with-editor--envvar with-editor-sleeping-editor)
+ (push (concat with-editor--envvar "=" with-editor-sleeping-editor)
+ process-environment)
;; Make sure server-use-tcp's value is valid.
(unless (featurep 'make-network-process '(:family local))
(setq server-use-tcp t))
@@ -389,19 +390,22 @@ ENVVAR is provided then bind that environment variable
instead.
(server-force-delete server-name)))
(server-start))
;; Tell $EDITOR to use the Emacsclient.
- (setenv with-editor--envvar
- (concat (shell-quote-argument
with-editor-emacsclient-executable)
+ (push (concat with-editor--envvar "="
+ (shell-quote-argument with-editor-emacsclient-executable)
;; Tell the process where the server file is.
- (and (not server-use-tcp)
- (concat " --socket-name="
- (shell-quote-argument
- (expand-file-name server-name
- server-socket-dir))))))
+ (and (not server-use-tcp)
+ (concat " --socket-name="
+ (shell-quote-argument
+ (expand-file-name server-name
+ server-socket-dir)))))
+ process-environment)
(when server-use-tcp
- (setenv "EMACS_SERVER_FILE"
- (expand-file-name server-name server-auth-dir)))
+ (push (concat "EMACS_SERVER_FILE="
+ (expand-file-name server-name server-auth-dir))
+ process-environment))
;; As last resort fallback to the sleeping editor.
- (setenv "ALTERNATE_EDITOR" with-editor-sleeping-editor))
+ (push (concat "ALTERNATE_EDITOR=" with-editor-sleeping-editor)
+ process-environment))
,@body))
(defun with-editor-server-window ()