Warren Lynn <wrn.l...@gmail.com> writes:

> Hi Michael,

Hi Warren,

> I actually put in a similar patch as yours myself, and found that is
> not enough. The tricky part is when tramp-make-tramp-file-name is
> called by tramp-make-tramp-hop-name, the hop name must be omitted (set
> to nil). Otherwise, we will get into some infinite loop. For other
> cases, keep the hop. With that additional consideration, it works for
> me, although I do not know how the whole system works and the code is
> really hacky. Maybe you can give some thoughts on that?

I've seen the same problem in my regression tests. See a reworked patch
appended. Note also, that I have renamed the new user option to
`tramp-show-ad-hoc-proxies', in order to be consistent with other
variable names.

> Thanks.
>
> Warren

Best regards, Michael.

diff --git a/lisp/tramp.el b/lisp/tramp.el
index 90fd53b0..8e5b7527 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -523,6 +523,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>.
@@ -1825,8 +1830,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
@@ -1877,7 +1882,7 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME &optional HOP)."
      (tramp-compat-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.

Reply via email to