Subject: Re: bug#7583: 23.2; ido loads tramp too eagerly

From: Michael Albinus <[email-masked]>
Date: Wed, 19 Oct 2011 12:04:45 +0200

Stefan Monnier <[email-masked]> writes:

>> To e.g "/ssh:" which is an incomplete address 
>> and hang indefinitely.
>> Just like when you do C-x C-f and enter in prompt /ssh: and press RET.
>
> I'm beginning to understand.  Indeed, I see that C-x C-f /ssh: RET and
> C-x C-f /sudo: RET both behave oddly (they try to connect to hosts `ssh'
> or `sudo').  They don't hang for me, but arguably they should not even
> try to treat the "ssh" or "sudo" as a hostname.

Why that? It is legal to have a hostname "ssh". Anybody can create such
an entry in ~/.ssh/config. Or an alias in /etc/hosts, or a DNS alias.

What we are speaking about is filename completion. If you enter RET, we
do not speak about completion anymore, but opening a file "/ssh:", using
Tramp's default connection method, which ought to be "scp" on GNU/Linux.

> ..Oh, wait, I think I see something interesting:
>
>   % emacs -Q
>   C-x C-f /ssh: TAB RET RET
>   C-x C-f /ssh: TAB
>
> The first C-x C-f just ends up loading Tramp then trying to connect to
> `ssh' and fail, but it also changes something inside Tramp because on
> the second C-x C-f the TAB causes Tramp to try to connect some "default"
> host (apparently it uses the first host in my ~/.ssh/config, and
> subsequent attempts will try subsequent hosts in that file).
>
> We don't want that, and your completion scheme might be bumping into
> this very problem.

Tramp has always the problem to understand what "C-x C-f /ssh: TAB"
means. This is due to the syntactic ambiguity of Tramp's file names
("ssh" can be both in this case, a method or a hostname).

[Side remark: with XEmacs, we use another syntax. There aren't such
 problems. But I guess it is much too late to change the syntax for GNU
 Emacs.]

I will try to change Tramp's completion algorithm such a way, that in
case "C-x C-f /foo: TAB" is pressed, and "foo" is a method found in
(mapcar 'car tramp-methods), Tramp does not check "foo" being a
hostname. This shall be sufficient for the incrimed case.

>         Stefan

Best regards, Michael.