From 4289044ccf5a07862234903f09d6eb46ac08a925 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 27 May 2023 10:14:50 +0200 Subject: [PATCH] Minor Tramp fixes * lisp/net/tramp-sh.el (tramp-sh-handle-process-file): Set `env' explicitly. (tramp-barf-if-no-shell-prompt): Still add optional trailing `ansi-color-control-seq-regexp'. * lisp/net/tramp.el (tramp-make-tramp-file-name): Keep hop while in file name completion. * test/lisp/net/tramp-tests.el (tramp-test26-interactive-file-name-completion): Adapt test. --- lisp/net/tramp-sh.el | 3 ++- lisp/net/tramp.el | 6 ++++-- test/lisp/net/tramp-tests.el | 10 +++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 25a26d67d6d..fb8112c384d 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -3127,7 +3127,7 @@ implementation will be used." (if (tramp-compat-string-search "=" elt) (setq env (append env `(,elt))) (setq uenv (cons elt uenv))))) - (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep) + (setq env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep)) (when env (setq command (format @@ -4316,6 +4316,7 @@ seconds. If not, it produces an error message with the given ERROR-ARGS." proc timeout (rx (| (regexp shell-prompt-pattern) (regexp tramp-shell-prompt-pattern)) + (? (regexp ansi-color-control-seq-regexp)) eos)) (error (delete-process proc) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3ceb20f2634..ecc950adfde 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1802,7 +1802,9 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)." (when (cadr args) (setq localname (and (stringp (cadr args)) (cadr args)))) (when hop - (setq hop nil) + ;; Keep hop in file name for completion. + (unless minibuffer-completing-file-name + (setq hop nil)) ;; Assure that the hops are in `tramp-default-proxies-alist'. ;; In tramp-archive.el, the slot `hop' is used for the archive ;; file name. @@ -5720,7 +5722,7 @@ See `tramp-process-actions' for the format of ACTIONS." ;; Obviously, the output was not complete. (while (tramp-accept-process-output proc)) ;; Remove ANSI control escape sequences. - (with-current-buffer (tramp-get-connection-buffer vec) + (with-current-buffer (tramp-get-connection-buffer vec) (goto-char (point-min)) (while (re-search-forward ansi-color-control-seq-regexp nil t) (replace-match ""))) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index eec4a66a329..017cb73f3bb 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4749,7 +4749,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." tramp-prefix-format hop (substring-no-properties method 0 (min 2 (length method)))) - ,(concat tramp-prefix-format method-string) + ,(concat tramp-prefix-format hop method-string) ,method-string))) ;; Complete user name. (unless (tramp-string-empty-or-nil-p user) @@ -4758,7 +4758,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (substring-no-properties user 0 (min 2 (length user)))) ,(concat - tramp-prefix-format method-string user-string) + tramp-prefix-format hop method-string user-string) ,user-string))) ;; Complete host name. (unless (tramp-string-empty-or-nil-p host) @@ -4768,9 +4768,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (substring-no-properties host 0 (min 2 (length host)))) (,(concat - tramp-prefix-format method-string host-string) + tramp-prefix-format hop method-string host-string) ,(concat - tramp-prefix-format method-string + tramp-prefix-format hop method-string user-string host-string)) ,host-string))) ;; Complete user and host name. @@ -4782,7 +4782,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (substring-no-properties host 0 (min 2 (length host)))) ,(concat - tramp-prefix-format method-string + tramp-prefix-format hop method-string user-string host-string) ,host-string))))) -- 2.39.2