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

From: Gregory Heytings <[email-masked]>
Date: Tue, 07 Sep 2021 13:23:10 +0000

>
> All of this does not fit to your commit message "Do not return methods 
> when the filename already contains a complete method.", I believe. But 
> so what.
>

It could be more precise indeed: "when the filename alread contains a 
complete method or does not contain the prefix of a method", or something 
like that.

>
> Your patch does not handle the case when `tramp-syntax' is `separate'. 
> There are no methods in the remote file name then, and you must handle 
> user and host names properly.
>

I guess adding a test to the conditional would be sufficient: (unless 
(string-empty-p method) -> (unless (or (string-empty-p method) (eq 
'tramp-syntax 'separate)).  I do know what the "separate" syntax is, so I 
did not test it.

>
> Finally, I have submitted a patch to master, which deactivates *default* 
> method, user and host name expansion in 
> `tramp-completion-handle-file-name-all-completions'. The difference to 
> your patch is, that it doesn't manipulate the results, but it 
> deactivates this expansion by usual Tramp means.
>
> Could you pls check how it fits in your use case? My (limited) tests 
> along your examples look good.
>

Alas it doesn't.

emacs -Q -l tramp --eval "(add-to-list 'completion-styles 'substring)"

C-x C-f /scp: TAB

still shows "Sole completion".