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

From: Michael Albinus <[email-masked]>
Date: Tue, 22 Nov 2011 22:55:25 +0100

Stefan Monnier <[email-masked]> writes:

>> Start "emacs -Q". Apply "C-x C-f /sudo:: TAB". This results in
>> "/sudo:sudo:root@". A correct expansion would be "/sudo:root@".
>
>> As far as I can see, Tramp's completion functions work properly.
>> The problem seems to be `completion-pcm--find-all-completions'.

> I think the patch below fixes it.

Yes, it does.

> The problem is that PCM assumes that
> a field separator cannot appear within a field.  In "/sudo::" the first
> / is a field separator, and the last ":" is also a field separator, but
> the first ":" isn't.

Unfortunately, I don't know anything about the completion machinery in
minibuffer.el. Maybe I should learn about. Is there documentation which
explains the concept of completion-table?

And is there something Tramp could do? It shall know the boundaries, and
it could provide such information more precisely.

> If you do "C-x C-f /sudo ?" you get "/sudo:" but if you
> do "C-x C-f /sudo: ?" you get "sudo:root@".  So fundamentally, the : of
> "/sudo:" acts a field separator, so (completion-boundaries "/sudo:") should
> probably return (6 . 0) rather than (1 . 0), and then "C-x C-f /sudo: ?"
> should list '("root@" ":") rather than '("sudo:root@").
>
> Related inconsistency from a trace of C-x C-f /sud: TAB:
>    1 -> completion-file-name-table: string="/sud:" pred=file-exists-p action=(boundaries . "")
>    1 <- completion-file-name-table: (boundaries 5)
>    [...]
>    ======================================================================
>    1 -> completion-file-name-table: string="/sudo:" pred=file-exists-p action=(boundaries . "")
>    1 <- completion-file-name-table: (boundaries 1)

I'ld like to check it if I could understand what's behind.

>         Stefan

Best regards, Michael.