]> git.eshelyaron.com Git - emacs.git/commitdiff
Obey tramp-histfile-override in remote direct async processes
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 29 May 2024 15:11:49 +0000 (17:11 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 29 May 2024 16:00:58 +0000 (18:00 +0200)
* 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)

doc/emacs/custom.texi
lisp/net/tramp-sh.el
lisp/net/tramp.el

index 2bf53df2ed20ce0b3a40284ed1df7eefb5b17185..1d6419d78f150cbe4964ceda7a82fcafcb76fe82 100644 (file)
@@ -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
index 350cbebe55056821fc6f32cb20a3f9f210f87021..16153b1d6ab3822db28504c6044aad8c2a935bb7 100644 (file)
@@ -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.
index 63f1b39c458b52f88a44813f65648350ba34a2af..eb7de36b56067e227b29beb9eade80d7e207fa75 100644 (file)
@@ -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)))