Subject: bug#23006: 25.0.92; Loading Tramp breaks pcomplete in eshell-mode

From: Stefan Monnier <[email-masked]>
Date: Tue, 22 Mar 2016 09:37:39 -0400

> cd / TAB calls file-name-all-completions. This returns several
> candidates, like "/adb:". That's OK.

Indeed.

> Afterwards, (file-directory-p "adb:") is called from completion-file-name-table:

Aha, now we're going somewhere:

>   file-directory-p("adb:")
>   #[257 "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207"
> [file-directory-p #[257
> "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207"
> ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"]
> nil] 3 "\n\n(fn F)"]("adb:")
>   completion-file-name-table("/" #[257
> "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207"
> [file-directory-p #[257
> "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207"
> ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"]
> nil] 3 "\n\n(fn F)"] t)

So, it seems the issue is that the completion predicate calls
file-directory-p and that this happens in a part of the file name that's
just at the boundary between "a local file name" and "a remote file
name", so while file-name-all-completions did not need receive a remote
file name it returned (apparently) remote file names.

One avenue that may be needed then is to bind non-essential while
checking the completion predicate (somewhere in pcomplete.el, or
comint.el, or minibuffer.el.).

But in this specific instance, (file-directory-p "/adb:") should simply
return nil, IMO.

> Tramp has no information, that file-name-completion is still in
> progress, and does its job. It tries to connect to the remote host
> "/adb:" in order to check.

For me (file-directory-p "/adb:") doesn't try to connect to "adb" but
instead signals "Host name must not match method name 'adb'".  I think
it's correct not to try to connect to "adb", but I think it should just
return nil because "/adb:" is not a directory.

> And yes, this is our basic disagreement.  I'm not able to implement
> proper Tramp operation without this information.  Why do you refuse to
> tell this to Tramp?

Because I don't see any fundamental difference between "completion" and
"non completion".  I do see that in some cases, the completion code may
try to "generate" new file names, and maybe in these particular
sub-cases it would make sense to bind non-essential, but not wholesale
around the whole completion operation.

        Stefan