Subject: bug#50387: Possible bug in Tramp or in completions

From: Gregory Heytings <[email-masked]>
Date: Tue, 07 Sep 2021 16:46:00 +0000

>
> When I type "C-x C-f /scp: TAB", I see the same result as you, "pscp:" 
> and "scp:". However, the buffer *trace-output* contains
>
> ======================================================================
> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
> 1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
> ======================================================================
> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
> 1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
>
> 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.

By the way, before your attempt to fix the problem, you would have seen:

1 -> (tramp-completion-handle-file-name-all-completions "" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("scp:" "scpx:")

IOW, one side effect of your patch is that C-x C-f / TAB now displays all 
Tramp methods.  And you said in your reply to Stefan: "For a completion of 
"/" Tramp tries to be silent, in order not to surprise the many users 
which don't use Tramp with candidates like "/adb:". They wouldn't know 
what's that."  I fully agree with that, and the problem is that Tramp 
tried to be "too smart" here, and to display completions that correspond 
to tramp-default-method, which confuses completion mechanisms.

IOW again:

- 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");

- now C-x C-f / TAB displays all Tramp methods;

- with my patch, which actually fixes the bug, C-x C-f / TAB does not 
display any Tramp method, as it should.