From: Michael Albinus Date: Wed, 29 May 2024 15:11:49 +0000 (+0200) Subject: Obey tramp-histfile-override in remote direct async processes X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5cb48a4eb5535c6abe429a981de5320a6e2bf2e0;p=emacs.git Obey tramp-histfile-override in remote direct async processes * doc/emacs/custom.texi (Connection Variables): Mention `permanent-local' symbol property. * lisp/net/tramp-sh.el (tramp-histfile-override): Add ;;;###tramp-autoload cookie and `permanent-local' symbol property. * lisp/net/tramp.el (tramp-handle-make-process): Obey `tramp-histfile-override'. (Bug#71049) (cherry picked from commit 063b67325b4e00a31c1178b340529a94e0de1c4e) --- diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index 2bf53df2ed2..1d6419d78f1 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi @@ -1607,6 +1607,13 @@ matches all buffers with a remote default directory. and setting these profiles to criteria which could match in parallel. It is unspecified which variable value is used then. + Be also careful when setting connection-local variables in a buffer, +which changes its major mode afterwards. Because all buffer-local +variables will be killed when changing the major mode, the +connection-local variable's value would be lost. You can prevent this +by setting the respective variable's @code{permanent-local} symbol +property to non-@code{nil}. + @node Key Bindings @section Customizing Key Bindings @cindex key bindings diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 350cbebe550..16153b1d6ab 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -64,6 +64,7 @@ If it is nil, out-of-the-band copy will be used without a check." :group 'tramp :type '(choice (const nil) integer)) +;;;###tramp-autoload (defcustom tramp-histfile-override "~/.tramp_history" "When invoking a shell, override the HISTFILE with this value. When setting to a string, it redirects the shell history to that @@ -80,6 +81,8 @@ the default storage location, e.g. \"$HOME/.sh_history\"." (const :tag "Unset HISTFILE" t) (string :tag "Redirect to a file"))) +(put 'tramp-histfile-override 'permanent-local t) + ;; ksh on OpenBSD 4.5 requires that $PS1 contains a `#' character for ;; root users. It uses the `$' character for other users. In order ;; to guarantee a proper prompt, we use "#$ " for the prompt. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 63f1b39c458..eb7de36b560 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4952,6 +4952,18 @@ should be set conmnection-local.") (string-join (tramp-get-remote-path v) ":"))) (setenv-internal env "PATH" remote-path 'keep) env)) + ;; Add HISTFILE if indicated. + (env (if-let ((sh-file-name-handler-p)) + (cond + ((stringp tramp-histfile-override) + (setenv-internal env "HISTFILE" tramp-histfile-override 'keep)) + (tramp-histfile-override + (setq env (setenv-internal env "HISTFILE" "''" 'keep)) + (setq env (setenv-internal env "HISTSIZE" "0" 'keep)) + (setenv-internal env "HISTFILESIZE" "0" 'keep)) + (t env)) + env)) + ;; Add INSIDE_EMACS. (env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep)) (env (mapcar #'tramp-shell-quote-argument (delq nil env)))