diff options
| author | Michael Albinus <michael.albinus@gmx.de> | 2026-05-13 18:39:04 +0200 |
|---|---|---|
| committer | Michael Albinus <michael.albinus@gmx.de> | 2026-05-13 18:39:04 +0200 |
| commit | 2e71d2c709f003cd33597d106e8a483500ec99c9 (patch) | |
| tree | 71b8fc79e150fa99db45cf170fe4902802f44a04 /lisp/net | |
| parent | ff96db93f23d17a1dcdc12aec4067007b5a4e18e (diff) | |
Propagate EMACSCLIENT_TRAMP to remote hosts with Tramp
* doc/misc/tramp.texi (Remote processes):
Explain `tramp-propagate-emacsclient-tramp'.
* lisp/net/tramp.el (tramp-remote-process-environment): Adapt docstring.
(tramp-propagate-emacsclient-tramp): New defcustom.
(tramp-handle-make-process):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process)
(tramp-sh-handle-process-file): Use it.
* test/lisp/net/tramp-tests.el (tramp-test33-environment-variables):
Adapt test.
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-sh.el | 9 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 92002b854b3..7b90ae9c11b 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3091,6 +3091,11 @@ will be used." (if (string-search "=" elt) (setq env (append env `(,elt))) (setq uenv (cons elt uenv)))))) + (env (if tramp-propagate-emacsclient-tramp + (setenv-internal + env "EMACSCLIENT_TRAMP" + (tramp-make-tramp-file-name v 'noloc) 'keep) + env)) (env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep)) ;; Environment is too large. Keep it here. @@ -3340,6 +3345,10 @@ will be used." (if (string-search "=" elt) (setq env (append env `(,elt))) (setq uenv (cons elt uenv))))) + (when tramp-propagate-emacsclient-tramp + (setq env (setenv-internal + env "EMACSCLIENT_TRAMP" + (tramp-make-tramp-file-name v 'noloc) 'keep))) (setq env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep)) (when env (setq command diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 6219d097f4f..ffcf8f4929c 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1528,12 +1528,21 @@ The PATH environment variable should be set via `tramp-remote-path'. The TERM environment variable should be set via `tramp-terminal-type'. +The EMACSCLIENT_TRAMP environment variable will be set accordingly, if +`tramp-propagate-emacsclient-tramp' is non-nil. + The INSIDE_EMACS environment variable will automatically be set based on the Tramp and Emacs versions, and should not be set here." :version "26.1" :type '(repeat string) :link '(info-link :tag "Tramp manual" "(tramp) Remote processes")) +(defcustom tramp-propagate-emacsclient-tramp nil + "Whether to propagate the EMACSCLIENT_TRAMP environment variable." + :version "31.1" + :type 'boolean + :link '(info-link :tag "Tramp manual" "(tramp) Remote processes")) + ;;; Internal Variables: ;;;###tramp-autoload @@ -5509,6 +5518,13 @@ processes." (env (if sh-file-name-handler-p (setenv-internal env "TERM" tramp-terminal-type 'keep) env)) + ;; Add EMACSCLIENT_TRAMP. + (env (if (and tramp-propagate-emacsclient-tramp + sh-file-name-handler-p) + (setenv-internal + env "EMACSCLIENT_TRAMP" + (tramp-make-tramp-file-name v 'noloc) 'keep) + env)) ;; Add INSIDE_EMACS. (env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep)) (env (mapcar #'tramp-shell-quote-argument (delq nil env))) |
