Joel Reicher <[email protected]> writes:
Hi Joel,
>> Perhaps you contact Jonas and ask about? For example, it could
>> support the old mechanism via standard output/input, and the new
>> mechanism alternatively.
>
> I will do that, but notwithstanding what you said about you yourself
> not using emacsclient much, I think there is one aspect that is the
> "responsibility" of Tramp, and that is to set the EMACSCLIENT_TRAMP
> environment variable on initialisation of a remote shell. It needs to
> be set to the same remote identifier used to open the shell,
> particularly for an ad-hoc multi-hop sudo. (I can explain why I
> believe this to be the case, if needed.)
>
> What's the easiest way of making that code change? I'm fairly sure I'm
> right about it.
Something like the appended poatch?
> Thanks and regards,
>
> - Joel
Best regards, Michael.
diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index 92002b85..8d6028d1 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -3091,6 +3091,9 @@ will be used."
(if (string-search "=" elt)
(setq env (append env `(,elt)))
(setq uenv (cons elt uenv))))))
+ (env (setenv-internal
+ env "EMACSCLIENT_TRAMP"
+ (tramp-make-tramp-file-name v 'noloc) 'keep))
(env (setenv-internal
env "INSIDE_EMACS" (tramp-inside-emacs) 'keep))
;; Environment is too large. Keep it here.
@@ -3340,6 +3343,9 @@ will be used."
(if (string-search "=" elt)
(setq env (append env `(,elt)))
(setq uenv (cons elt uenv)))))
+ (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/tramp.el b/lisp/tramp.el
index 6219d097..578e199f 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -1528,6 +1528,9 @@ 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 according to the
+connection.
+
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"
@@ -5509,6 +5512,12 @@ processes."
(env (if sh-file-name-handler-p
(setenv-internal env "TERM" tramp-terminal-type 'keep)
env))
+ ;; Add EMACSCLIENT_TRAMP.
+ (env (if 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)))