Subject: bug#10085: 24.0.91; completion-pcm--find-all-completions returns wrong remote file names

From: Stefan Monnier <[email-masked]>
Date: Wed, 27 Apr 2016 10:16:30 -0400

> Tramp does not know of programmed completion and pcm style completion;
> all what it knows is file-name-all-completions.
> What else could Tramp do?

Tramp has control via file-name-directory.

>>> I guess we need to find out, what are separators in Tramp wrt
>>> completion tables, and how to handle them.
>> The user finds out, the implementer decides.
> Oh. You haven't seen Tramp's heuristic to determine, whether completion
> of "/sudo" means the method or the user or the host (in fact, it is all).

;-)

OK, here are some inconsistencies I found just now in emacs-25:

    ELISP> (completion-boundaries "/sudo:" #'completion-file-name-table nil "")
    (6 . 0)
    
    ELISP> (let ((non-essential t)) (completion-boundaries "/sudo:" #'completion-file-name-table nil ""))
    (1 . 0)

In the above the first answer looks good to me.
The second looks wrong: it should be the same as the first.
This is controlled by Tramp via (file-name-directory "/sudo:").

    ELISP> (all-completions "/sudo:" #'completion-file-name-table)
    *** Eval error ***  Host name must not match method "sudo"
    ELISP> (let ((non-essential t)) (all-completions "/sudo:" #'completion-file-name-table))
    ("sudo:root@")

The first answer above looks wrong (there's no reason for Tramp to
assume that "/sudo:" uses "sudo" as a host name, and indeed in the
second case it correctly interprets "sudo" as a method rather than
a host name).

Assuming we fix the completion-boundaries to be (6 . 0) the second
answer (which comes from `file-name-all-completions "" "/sudo:") should
be ("root@").

Fixing those inconsistencies should fix bug#10085.

        Stefan