Subject: Re: bug#60505: 29.0.60; Fido Mode and Tramp Completion

From: Stefan Monnier <[email-masked]>
Date: Thu, 02 Feb 2023 10:39:25 -0500

> I could imagine that the completion machinery offers an API that a
> package could register its own idea of a file name syntax.

The completion code relies on `file-name-directory`,
`directory-file-name`, etc... for that.

The problem as I see it goes as follows:

According to `file-name-directory`, in `/ssh:myhost` the part
`ssh:myhost` is an element of the `/` directory.  For this reason, the
completion machinery would expect (file-name-all-completions "s" "/") to
include "ssh:myhost" in its return list rather than only "ssh:".

Now, it's impractical for Tramp to do that.  So the end result is the
kind of bug reports we're discussing.

One way to fix the problem is for Tramp to "teach" the rest of the
system that `/ssh:` is a kind of directory, in which case the completion
machinery would know that (file-name-all-completions "s" "/") returns
"ssh:" and that "myhost" would be included only in the return value of
(file-name-all-completions "" "/ssh:").

Another is to change Tramp's syntax so that it uses the regular "/"
separator rather than ":".  This would get a similar result but without
touching `file-name-directory` and friends.

We could also consider introducing a new set of (file-name) functions

    completion-file-name-directory, completion-directory-file-name, ...

so the completion code can use its own notion of how a file name gets
separated into parts.  But introducing such a subtle distinction would
likely introduce a lot of bugs&confusion as well.

        Stefan