Add Tramp option showing ad-hoc multi-hops

* doc/misc/tramp.texi (Ad-hoc multi-hops):
Describe tramp-show-ad-hoc-proxies.

* lisp/net/tramp.el (tramp-show-ad-hoc-proxies): New defcustom.
(tramp-make-tramp-file-name): Use it.
(tramp-make-tramp-hop-name): Don't add hop twice.

* test/lisp/net/tramp-tests.el (tramp-test02-file-name-dissect)
(tramp-test02-file-name-dissect-simplified)
(tramp-test02-file-name-dissect-separate): Adapt tests.
This commit is contained in:
Michael Albinus 2023-06-21 18:25:32 +02:00
parent 195ca6b9a3
commit 72f1c12e58
3 changed files with 577 additions and 420 deletions

View file

@ -3644,10 +3644,20 @@ Each involved method must be an inline method (@pxref{Inline methods}).
@code{tramp-default-proxies-alist} and is available for re-use during
that Emacs session. Subsequent @value{tramp} connections to the same
remote host can then use the shortcut form:
@samp{@trampfn{ssh,you@@remotehost,/path}}. Ad-hoc definitions are
removed from @code{tramp-default-proxies-alist} via the command
@kbd{M-x tramp-cleanup-all-connections @key{RET}} (@pxref{Cleanup
remote connections}).
@samp{@trampfn{ssh,you@@remotehost,/path}}.
@defopt tramp-show-ad-hoc-proxies
If this user option is non-@code{nil}, ad-hoc definitions are kept in
remote file names instead of showing the shortcuts.
@lisp
(customize-set-variable 'tramp-show-ad-hoc-proxies t)
@end lisp
@end defopt
Ad-hoc definitions are removed from @code{tramp-default-proxies-alist}
via the command @kbd{M-x tramp-cleanup-all-connections @key{RET}}
(@pxref{Cleanup remote connections}).
@defopt tramp-save-ad-hoc-proxies
For ad-hoc definitions to be saved automatically in

View file

@ -520,6 +520,11 @@ interpreted as a regular expression which always matches."
:version "24.3"
:type 'boolean)
(defcustom tramp-show-ad-hoc-proxies nil
"Whether to show ad-hoc proxies in file names."
:version "29.2"
:type 'boolean)
;; For some obscure technical reasons, `system-name' on w32 returns
;; either lower case or upper case letters. See
;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=38079#20>.
@ -1802,8 +1807,8 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
(when (cadr args)
(setq localname (and (stringp (cadr args)) (cadr args))))
(when hop
;; Keep hop in file name for completion.
(unless minibuffer-completing-file-name
;; Keep hop in file name for completion or when indicated.
(unless (or minibuffer-completing-file-name tramp-show-ad-hoc-proxies)
(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
@ -1853,7 +1858,7 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
(replace-regexp-in-string
(rx (regexp tramp-postfix-host-regexp) eos)
tramp-postfix-hop-format
(tramp-make-tramp-file-name vec 'noloc)))))
(tramp-make-tramp-file-name (tramp-file-name-unify vec))))))
(defun tramp-completion-make-tramp-file-name (method user host localname)
"Construct a Tramp file name from METHOD, USER, HOST and LOCALNAME.

File diff suppressed because it is too large Load diff