Subject: bug#50387: closed (Re: bug#50387: Possible bug in Tramp or in completions)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 07 Sep 2021 17:52:02 +0000

Your bug report

#50387: Possible bug in Tramp or in completions

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
50387: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=50387
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#50387: Possible bug in Tramp or in completions
From: Gregory Heytings <[email-masked]>
To: Michael Albinus <[email-masked]>
Cc: Stefan Monnier <[email-masked]>, [email-masked]
Date: Tue, 07 Sep 2021 17:51:17 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

>>> That means, "scp:" hasn't been passed to 
>>> tramp-completion-handle-file-name-all-completions, and the result of 
>>> that function looks proper to me.
>>
>> Yet it isn't.
>
> Why not? In this example, `completion-styles' contains `substring'. And 
> then you ask for completion of "/scp:". Looking at the candidates 
> returned by `tramp-completion-handle-file-name-all-completions', only 
> "pscp:" and "scp:" have the substring "scp:".
>

Because after typing "/s" or "/sc" or "/scp" it makes sense to see that 
"/scp:" is among the completion candidates, but after typing "/scp:" it 
doesn't make sense anymore, the method has already been entered by the 
user, what they now want to see is a list of hosts, and there is no way to 
see it.

>> - before your attempt to fix the problem, C-x C-f / TAB only displayed 
>> "scp:" and "scpx:" among the completion candidates (or e.g. "ssh:", 
>> "sshfs:" and "sshx:" with tramp-default-method set to "ssh");
>
> Yes, this is changed.
>
>> - now C-x C-f / TAB displays all Tramp methods;
>
> When Tramp is loaded. I regard this to be correct.
>
>> - with my patch, which actually fixes the bug, C-x C-f / TAB does not 
>> display any Tramp method, as it should.
>
> Again, C-x C-f / TAB displays a Tramp method only when Tramp is loaded.
>

I filed a bug report, explained in every detail what the bug is, provided 
a patch, and the end result is a situation that is worse than earlier.  I 
expect other bug reports from confused users, and hope that you'll change 
your mind.

Closing.

Subject: Possible bug in Tramp or in completions
From: Gregory Heytings <[email-masked]>
To: [email-masked]
Date: Sun, 05 Sep 2021 00:43:59 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

With a ~/.ssh/config file containing two entries:

Host foo
   ...
Host bar
   ...

emacs -Q
M-: (setq tramp-default-method "ssh")
M-: (add-to-list 'completion-styles 'substring)
C-x C-x /ssh: TAB

displays "Sole completion".  If, instead of having completion-styles set 
to:

(substring basic partial-completion emacs22)

it is set to:

(basic substring partial-completion emacs22)

then two completion candidates are shown (as expected): "ssh:foo:" and 
"ssh:bar:".

This happens because the "substring" completion mechanism is tried first 
by completion--some in completion--nth-completion, and returns (t . 
substring), because

(completion-substring-try-completion "/ssh:" #'completion-file-name-table 
#'file-exists-p 5)

returns t, because

(completion-substring--all-completions "/ssh:" 
#'completion-file-name-table #'file-exists-p 5) returns (("ssh:")

returns (prefix "ssh:") "/" "" 1), because

(completion-boundaries "/ssh:" #'completion-file-name-table 
#'file-exists-p "")

returns (1 . 0).

When the "basic" completion mechanism is tried first,

(completion-basic-try-completion "/ssh:" #'completion-file-name-table 
#'file-exists-p 5)

returns ("/ssh:" . 5).

It is not clear to me whether this is a bug (I always thought that the 
order of completion mechanisms in completion-styles did not matter, and in 
this case it does indeed make no difference with (setq 
tramp-default-method "scp")), and if so if it is a bug in Tramp, or in the 
completion functions.