mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-05-31 01:32:00 -07:00
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.
This commit is contained in:
parent
ff96db93f2
commit
2e71d2c709
4 changed files with 48 additions and 0 deletions
|
|
@ -4227,6 +4227,14 @@ called is local or remote, since @value{tramp} would add just the
|
|||
@env{HGPLAIN} setting and local processes would take whole value of
|
||||
@code{process-environment} along with the new value of @env{HGPLAIN}.
|
||||
|
||||
@vindex tramp-propagate-emacsclient-tramp
|
||||
@vindex EMACSCLIENT_TRAMP@r{, environment variable}
|
||||
If you set the user option @code{tramp-propagate-emacsclient-tramp} to
|
||||
a non-@code{nil} value, the environment variable
|
||||
@env{EMACSCLIENT_TRAMP} will be set to a value which allows to call
|
||||
@command{emacsclient} from a process running on the remote
|
||||
host. @xref{emacsclient Options, , , emacs}.
|
||||
|
||||
For integrating other Emacs packages so @value{tramp} can execute
|
||||
remotely, please file a bug report. @xref{Bug Reports}.
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -6555,6 +6555,21 @@ INPUT, if non-nil, is a string sent to the process."
|
|||
(funcall
|
||||
this-shell-command-to-string "echo \"${INSIDE_EMACS:-bla}\""))))
|
||||
|
||||
;; Check EMACSCLIENT_TRAMP.
|
||||
(setenv "EMACSCLIENT_TRAMP")
|
||||
(let ((tramp-propagate-emacsclient-tramp t))
|
||||
(should
|
||||
(string-equal
|
||||
(format "%s\n" (tramp-make-tramp-file-name tramp-test-vec 'noloc))
|
||||
(funcall
|
||||
this-shell-command-to-string "echo \"${EMACSCLIENT_TRAMP:-bla}\""))))
|
||||
(let (tramp-propagate-emacsclient-tramp)
|
||||
(should
|
||||
(string-equal
|
||||
"bla\n"
|
||||
(funcall
|
||||
this-shell-command-to-string "echo \"${EMACSCLIENT_TRAMP:-bla}\""))))
|
||||
|
||||
;; Set a value.
|
||||
(let ((process-environment
|
||||
(cons (concat envvar "=foo") process-environment)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue