GNU bug report logs - #50387
Possible bug in Tramp or in completions

Previous Next

Package: emacs;

Reported by: Gregory Heytings <gregory <at> heytings.org>

Date: Sun, 5 Sep 2021 00:45:01 UTC

Severity: normal

Done: Gregory Heytings <gregory <at> heytings.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50387 in the body.
You can then email your comments to 50387 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Sun, 05 Sep 2021 00:45:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gregory Heytings <gregory <at> heytings.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 05 Sep 2021 00:45:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Possible bug in Tramp or in completions
Date: Sun, 05 Sep 2021 00:43:59 +0000
With a ~/.ssh/config file containing two entries:

Host foo
  ...
Host bar
  ...

emacs -Q
M-: (setq tramp-default-method "ssh")
M-: (add-to-list 'completion-styles 'substring)
C-x C-x /ssh: TAB

displays "Sole completion".  If, instead of having completion-styles set 
to:

(substring basic partial-completion emacs22)

it is set to:

(basic substring partial-completion emacs22)

then two completion candidates are shown (as expected): "ssh:foo:" and 
"ssh:bar:".

This happens because the "substring" completion mechanism is tried first 
by completion--some in completion--nth-completion, and returns (t . 
substring), because

(completion-substring-try-completion "/ssh:" #'completion-file-name-table 
#'file-exists-p 5)

returns t, because

(completion-substring--all-completions "/ssh:" 
#'completion-file-name-table #'file-exists-p 5) returns (("ssh:")

returns (prefix "ssh:") "/" "" 1), because

(completion-boundaries "/ssh:" #'completion-file-name-table 
#'file-exists-p "")

returns (1 . 0).

When the "basic" completion mechanism is tried first,

(completion-basic-try-completion "/ssh:" #'completion-file-name-table 
#'file-exists-p 5)

returns ("/ssh:" . 5).

It is not clear to me whether this is a bug (I always thought that the 
order of completion mechanisms in completion-styles did not matter, and in 
this case it does indeed make no difference with (setq 
tramp-default-method "scp")), and if so if it is a bug in Tramp, or in the 
completion functions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Sun, 05 Sep 2021 12:50:01 GMT) Full text and rfc822 format available.

Message #8 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Sun, 05 Sep 2021 12:49:00 +0000
I analyzed this bug a bit further, and the root problem is that

(tramp-completion-handle-file-name-all-completions "" "/")

returns ("sshfs:" "ssh:" "sshx:" ...) when tramp-default-method is "ssh", 
and ("scp:" "scpx:" ...) when tramp-default-method is "scp".

This happens because "possible methods" are added to the result in 
tramp-completion-handle-file-name-all-completions.

Therefore completion-substring-try-completion finds that "ssh:" is already 
a complete match.

I'm not sure how this bug should be fixed.  Removing these two lines from 
that function fixes the bug, but that's not really optimal because in that 
case /s TAB does not show "ssh:", "sshfs:" and "sshx:" anymore.  Not 
displaying these completions is perhaps better than not displaying 
hostnames, however.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 08:19:02 GMT) Full text and rfc822 format available.

Message #11 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 10:18:43 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

Hi Gregory,

> I analyzed this bug a bit further, and the root problem is that
>
> (tramp-completion-handle-file-name-all-completions "" "/")
>
> returns ("sshfs:" "ssh:" "sshx:" ...) when tramp-default-method is
> "ssh", and ("scp:" "scpx:" ...) when tramp-default-method is "scp".
>
> This happens because "possible methods" are added to the result in
> tramp-completion-handle-file-name-all-completions.
>
> Therefore completion-substring-try-completion finds that "ssh:" is
> already a complete match.
>
> I'm not sure how this bug should be fixed.  Removing these two lines
> from that function fixes the bug, but that's not really optimal
> because in that case /s TAB does not show "ssh:", "sshfs:" and "sshx:"
> anymore.  Not displaying these completions is perhaps better than not
> displaying hostnames, however.

Tramp doesn't know anything about completion-styles, it just implements
file-name-all-completions and file-name-completion. Cutting valid
results from those functions seems to be wrong, IMO.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 16:35:02 GMT) Full text and rfc822 format available.

Message #14 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 16:34:41 +0000
Hi Michael,

Thanks for your answer!

>> I analyzed this bug a bit further, and the root problem is that
>>
>> (tramp-completion-handle-file-name-all-completions "" "/")
>>
>> returns ("sshfs:" "ssh:" "sshx:" ...) when tramp-default-method is 
>> "ssh", and ("scp:" "scpx:" ...) when tramp-default-method is "scp".
>>
>> This happens because "possible methods" are added to the result in 
>> tramp-completion-handle-file-name-all-completions.
>>
>> Therefore completion-substring-try-completion finds that "ssh:" is 
>> already a complete match.
>>
>> I'm not sure how this bug should be fixed.  Removing these two lines 
>> from that function fixes the bug, but that's not really optimal because 
>> in that case /s TAB does not show "ssh:", "sshfs:" and "sshx:" anymore. 
>> Not displaying these completions is perhaps better than not displaying 
>> hostnames, however.
>
> Tramp doesn't know anything about completion-styles, it just implements 
> file-name-all-completions and file-name-completion. Cutting valid 
> results from those functions seems to be wrong, IMO.
>

The problem is not that results are cut in this case, the problem is that 
because the return value of 
tramp-completion-handle-file-name-all-completions includes the methods 
("sshfs:" "ssh:" "sshx:"), some completion mechanisms do not look further 
when "ssh:" is entered and the user hits TAB to list host candidates:

- substring considers that there is nothing more to complete because 
"ssh:" is one completion candidate

- partial-completion and flex consider that "ssh:" is not complete, but 
the completion candidates they propose are "ssh:", "sshx:" and "sshfs:".

For the case of the substring completion mechanisms (i.e. after 
(add-to-list 'completion-styles 'substring),

(completion-substring-try-completion "/ssh:" #'completion-file-name-table 
#'file-exists-p 5)

returns t with tramp-default-method set to "ssh" (and therefore the 
completion system does not try further), and nil with tramp-default-method 
set to "scp" (and therefore the completion system does try further, and 
eventually finds the hosts).

Without

;; Possible methods.
(setq result (append result (tramp-get-completion-methods m)))

in tramp-completion-handle-file-name-all-completions, all completion 
mechanisms do what a user would expect, namely list host candidates. 
(But the tramp methods are not shown anymore in the completion candidates 
after e.g. /s TAB.)

It seems to me that adding methods (which are not file names), 
conditionally to tramp-default-method, to file-name-all-completions, is 
not TRT, hence this bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 17:00:01 GMT) Full text and rfc822 format available.

Message #17 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 18:59:17 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

> Hi Michael,

Hi Grepory,

> It seems to me that adding methods (which are not file names),

I disagree. Methods are part of a remote file name in Emacs.

> conditionally to tramp-default-method, to file-name-all-completions,
> is not TRT, hence this bug.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 17:27:02 GMT) Full text and rfc822 format available.

Message #20 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 17:26:13 +0000
Hi Michael,

>> It seems to me that adding methods (which are not file names), 
>> conditionally to tramp-default-method, to file-name-all-completions, is 
>> not TRT, hence this bug.
>
> I disagree. Methods are part of a remote file name in Emacs.
>

Okay.  So what would you suggest to fix that bug?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 17:42:02 GMT) Full text and rfc822 format available.

Message #23 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 19:41:09 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

> Hi Michael,

Hi Gregory,

>>> It seems to me that adding methods (which are not file names),
>>> conditionally to tramp-default-method, to
>>> file-name-all-completions, is not TRT, hence this bug.
>>
>> I disagree. Methods are part of a remote file name in Emacs.
>
> Okay.  So what would you suggest to fix that bug?

I don't know completion styles, so I have no suggestions. I have
analysed what Tramp does, and this seems to be right.

I hope somebody else chimes in.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 18:23:02 GMT) Full text and rfc822 format available.

Message #26 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 18:22:11 +0000
Hi Michael,

>>>> It seems to me that adding methods (which are not file names), 
>>>> conditionally to tramp-default-method, to file-name-all-completions, 
>>>> is not TRT, hence this bug.
>>>
>>> I disagree. Methods are part of a remote file name in Emacs.
>>
>> Okay.  So what would you suggest to fix that bug?
>
> I don't know completion styles, so I have no suggestions. I have 
> analysed what Tramp does, and this seems to be right.
>

I'm not really an expert of completion mechanisms either, but what I do 
know is that what Tramp does with methods in completions is not consistent 
with the way completion mechanisms usually work.

With emacs -Q and (require 'tramp), if you C-x C-f / TAB TAB, you'll see 
only two methods, namely "scp:" and "scpx:".  If you C-x C-f /a TAB TAB, 
you'll see two other methods "adb:" and "afp:".

If you now (add-to-list 'completion-styles 'substring), you still see 
"scp:" and "scpx:" after C-x C-f / TAB TAB, but you do not see any methods 
after C-x C-f /a TAB TAB.

>
> I hope somebody else chimes in.
>

Adding Stefan M in Cc.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 19:40:01 GMT) Full text and rfc822 format available.

Message #29 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 21:39:14 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

> Hi Michael,

Hi Gregory,

> I'm not really an expert of completion mechanisms either, but what I
> do know is that what Tramp does with methods in completions is not
> consistent with the way completion mechanisms usually work.
>
> With emacs -Q and (require 'tramp), if you C-x C-f / TAB TAB, you'll
> see only two methods, namely "scp:" and "scpx:".  If you C-x C-f /a
> TAB TAB, you'll see two other methods "adb:" and "afp:".

Correct. We see

--8<---------------cut here---------------start------------->8---
$ emacs -Q -batch -l tramp --eval '(message "%S" (file-name-all-completions "" "/"))'

("scp:" "scpx:" "sbin/" "proc/" "bin/" "snap/" "opt/" "var/" "dev/" "lib64/" "./" "nonexistent/" "lost+found/" "media/" "root/" "srv/" "etc/" "mnt/" "../" "tmp/" "net/" "sys/" "lib/" "boot/" "home/" "run/" "usr/")

$ emacs -Q -batch -l tramp --eval '(message "%S" (file-name-all-completions "s" "/"))'

("sudoedit:" "sshfs:" "smb:" "scp:" "scpx:" "ssh:" "sshx:" "su:" "sg:" "sudo:" "sftp:" "sbin/" "snap/" "srv/" "sys/")
--8<---------------cut here---------------end--------------->8---

That is, if there's nothing which could be interpreted as method name
(and "" is nothing in this sense),
tramp-completion-handle-file-name-all-completions uses the default
method, "scp", instead, and it completes this to "scp: and "scpx:".

OTOH, if there is at least one character which could belong to a method
("s" in this case), tramp-completion-handle-file-name-all-completions
returns all possible completions of this like "sudoedit:", "sshfs:",
"smb:", "scp:", "scpx:", "ssh:", "sshx:", "su:", "sg:", "sudo:" and
"sftp:".

I believe this is consistent, and it is implemented like this for at
least 15 years I believe.

> If you now (add-to-list 'completion-styles 'substring), you still see
> "scp:" and "scpx:" after C-x C-f / TAB TAB, but you do not see any
> methods after C-x C-f /a TAB TAB.

What completion styles do with these results, is out of my
knowledge. The Tramp manual says

--8<---------------cut here---------------start------------->8---
User name and host name completion is activated only, if file name
completion has one of the styles ‘basic’, ‘emacs21’, or ‘emacs22’.
--8<---------------cut here---------------end--------------->8---

Does this help? Although I have added this sentence myself, I have done
this on recommendation by somebody, w/o really understanding why this is so.

>> I hope somebody else chimes in.
>
> Adding Stefan M in Cc.

Yes, hopefully he can tell us what happens then.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 20:01:02 GMT) Full text and rfc822 format available.

Message #32 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 20:00:16 +0000
[Message part 1 (text/plain, inline)]
I squashed the bug.  Fix attached.
[Improve-handling-of-non-default-completion-styles-wi.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 20:32:01 GMT) Full text and rfc822 format available.

Message #35 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 22:31:31 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

Hi Gregory,

> * lisp/net/tramp.el (tramp-completion-handle-file-name-all-completions):
> Do not return methods when the filename already contains a complete method.
> Fixes bug#50387.

I don't see this implemented. You rather don't return methods when the
filename does not contain a possible method string at all.

>  	    ;; Possible methods.
> -	    (setq result
> -		  (append result (tramp-get-completion-methods m)))))))
> +	    (unless (or (string-empty-p method)
> +		        (string-empty-p user)
> +		        (string-empty-p host))

The check for (string-empty-p user) and (string-empty-p host) wouldn't
be needed, you are in the else branch of (or user host). IOW, user and
host are already nil, nothing left to test for them.

But I'm not convinced this is the proper solution. I still don't
understand why the default method must be suppressed.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 20:42:02 GMT) Full text and rfc822 format available.

Message #38 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Gregory Heytings <gregory <at> heytings.org>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 16:41:15 -0400
>> Adding Stefan M in Cc.
> Yes, hopefully he can tell us what happens then.

The completion tables's API only directly support prefix completion.
So in order to implement `substring` style, when the minibuffer.el code
sees a request for completion of "/a" it will request all the
possible prefix-completions for "/" and then filter them based on the
presence of "a" in there.

Tramp can only affect the file name completion table, so all it gets to
see is a request for the set of prefix-completions of "/".
Maybe Tramp could include "/adb:" and friends in there, but Michael
probably has good reasons for not doing so.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 20:50:02 GMT) Full text and rfc822 format available.

Message #41 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Gregory Heytings <gregory <at> heytings.org>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 22:49:47 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

Hi Stefan,

> Tramp can only affect the file name completion table, so all it gets to
> see is a request for the set of prefix-completions of "/".
> Maybe Tramp could include "/adb:" and friends in there, but Michael
> probably has good reasons for not doing so.

For a completion of "/" Tramp tries to be silent, in order not to
surprise the many users which don't use Tramp with candidates like
"/adb:". They wouldn't know what's that.

The compromise is to show them only the default method "/scp:" (and
"/scpx:" due to completion), in order to give them an idea that there's
more in Emacs but the local file system.

>         Stefan

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 20:56:01 GMT) Full text and rfc822 format available.

Message #44 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 20:55:15 +0000
[Message part 1 (text/plain, inline)]
Hi Michael,

>> * lisp/net/tramp.el (tramp-completion-handle-file-name-all-completions):
>> Do not return methods when the filename already contains a complete method.
>> Fixes bug#50387.
>
> I don't see this implemented. You rather don't return methods when the 
> filename does not contain a possible method string at all.
>

Yet this is what is happening.  You can try it yourself: emacs -Q, M-: 
(require 'tramp), M-: (add-to-list 'completion-styles 'substring), C-x C-f 
/scp: TAB.  This will display "Sole completion", and it displays "Sole 
completion" because "scp:" and "scpx:" are added in the completion 
candiates in tramp-completion-handle-file-name-all-completions.  You can 
see this with

(message "method '%s' result '%s'" method (tramp-get-completion-methods m))

around "Possible methods".  With C-x C-f /scp TAB, you will see

method ’scp’ result ’(nil nil nil nil nil nil nil nil nil nil nil nil nil 
nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil /scpx: /scp: 
nil nil nil nil nil)’

which is correct, but with C-x C-f /scp: TAB, you will see

method ’’ result ’(nil nil nil nil nil nil nil nil nil nil nil nil nil nil 
nil nil nil nil nil nil nil nil nil nil nil nil nil nil /scpx: /scp: nil 
nil nil nil nil)’

which is wrong.

>>  	    ;; Possible methods.
>> -	    (setq result
>> -		  (append result (tramp-get-completion-methods m)))))))
>> +	    (unless (or (string-empty-p method)
>> +		        (string-empty-p user)
>> +		        (string-empty-p host))
>
> The check for (string-empty-p user) and (string-empty-p host) wouldn't 
> be needed, you are in the else branch of (or user host). IOW, user and 
> host are already nil, nothing left to test for them.
>

Whoops, yes, indeed.  Updated patch attached.
[Improve-handling-of-non-default-completion-styles-wi.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Mon, 06 Sep 2021 21:40:01 GMT) Full text and rfc822 format available.

Message #47 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Michael Albinus <michael.albinus <at> gmx.de>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Mon, 06 Sep 2021 21:39:06 +0000
>
> The completion tables's API only directly support prefix completion. So 
> in order to implement `substring` style, when the minibuffer.el code 
> sees a request for completion of "/a" it will request all the possible 
> prefix-completions for "/" and then filter them based on the presence of 
> "a" in there.
>

Thank you.  Now I understand the bug better: when the user types / TAB, 
Tramp returns the default methods (scp: scpx:), when the user types /sc 
TAB, Tramp returns the methods starting with 'sc', i.e. scp: scpx:, and 
when the user types /scp: TAB, Tramp again returns the default methods 
scp: scpx:, because it is again at '/', and the substring completion 
backend concludes that "scp:" cannot be completed further, which is wrong.

With my patch, when the user types / TAB, Tramp does not return the 
default methods anymore, and therefore they are not returned after /scp: 
TAB either.  So IMO the patch does TRT, and fixes both the behavior with 
substring and flex completion styles.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 05:43:01 GMT) Full text and rfc822 format available.

Message #50 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: michael.albinus <at> gmx.de, monnier <at> iro.umontreal.ca, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 08:42:26 +0300
> Date: Mon, 06 Sep 2021 21:39:06 +0000
> From: Gregory Heytings <gregory <at> heytings.org>
> Cc: Michael Albinus <michael.albinus <at> gmx.de>, 50387 <at> debbugs.gnu.org
> 
> With my patch, when the user types / TAB, Tramp does not return the 
> default methods anymore, and therefore they are not returned after /scp: 
> TAB either.  So IMO the patch does TRT, and fixes both the behavior with 
> substring and flex completion styles.

When the dust settles on this, please make sure typing "C-x C-f / TAB"
doesn't cause Tramp to be loaded into Emacs due to these changes.
(I'm not saying it should, but we had trouble with this before, and
Michael solved them.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 11:31:01 GMT) Full text and rfc822 format available.

Message #53 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Gregory Heytings <gregory <at> heytings.org>, monnier <at> iro.umontreal.ca,
 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 13:29:48 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

Hi Eli,

> When the dust settles on this, please make sure typing "C-x C-f / TAB"
> doesn't cause Tramp to be loaded into Emacs due to these changes.
> (I'm not saying it should, but we had trouble with this before, and
> Michael solved them.)

This is guaranteed. tramp-completion-file-name-handler is added to
file-name-handler-alist only while Tramp is loading.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 12:59:01 GMT) Full text and rfc822 format available.

Message #56 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 14:58:06 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

> Hi Michael,

Hi Gregory,

>>> * lisp/net/tramp.el (tramp-completion-handle-file-name-all-completions):
>>> Do not return methods when the filename already contains a complete method.
>>> Fixes bug#50387.
>>
>> I don't see this implemented. You rather don't return methods when
>> the filename does not contain a possible method string at all.
>
> Yet this is what is happening.  You can try it yourself: emacs -Q, M-:
> (require 'tramp), M-: (add-to-list 'completion-styles 'substring), C-x
> C-f /scp: TAB.  This will display "Sole completion", and it displays
> "Sole completion" because "scp:" and "scpx:" are added in the
> completion candiates in
> tramp-completion-handle-file-name-all-completions.  You can see this
> with
>
> (message "method '%s' result '%s'" method (tramp-get-completion-methods m))
>
> around "Possible methods".  With C-x C-f /scp TAB, you will see
>
> method ’scp’ result ’(nil nil nil nil nil nil nil nil nil nil nil nil
> nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil /scpx:
> /scp: nil nil nil nil nil)’
>
> which is correct, but with C-x C-f /scp: TAB, you will see
>
> method ’’ result ’(nil nil nil nil nil nil nil nil nil nil nil nil nil
> nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil /scpx:
> /scp: nil nil nil nil nil)’
>
> which is wrong.

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.

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.

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.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 13:24:01 GMT) Full text and rfc822 format available.

Message #59 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
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".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 13:31:01 GMT) Full text and rfc822 format available.

Message #62 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 13:30:22 +0000
>
> 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".
>

Sorry, I typed too fast.  It displays two completion candidates: "pscp:" 
and "scp:", which is not what one expects at that point.

With tramp-default-method set to "ssh", C-x C-f /ssh: TAB still displays 
"Sole completion".




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 13:38:01 GMT) Full text and rfc822 format available.

Message #65 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Gregory Heytings <gregory <at> heytings.org>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 15:37:31 +0200
I'm getting this today:

1 unexpected results:
   FAILED  tramp-test26-file-name-completion

Test tramp-test26-file-name-completion condition:
    (ert-test-failed
     ((should
       (member
	(concat prefix-format method-marker tramp-postfix-method-format ipv6-prefix host ipv6-postfix tramp-postfix-host-format)
	(file-name-all-completions ... "/")))
      :form
      (member
       #("-:elva:" 2 6
	 (tramp-default t))
       nil)
      :value nil))


I'm guessing it has something to do with this bug report...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 14:24:01 GMT) Full text and rfc822 format available.

Message #68 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 16:23:08 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

>> 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".

In order to see what Tramp does, I have called

--8<---------------cut here---------------start------------->8---
# emacs -Q -l tramp --eval "(add-to-list 'completion-styles 'substring)" --eval "(trace-function-background 'tramp-completion-handle-file-name-all-completions)"
--8<---------------cut here---------------end--------------->8---

> Sorry, I typed too fast.  It displays two completion candidates:
> "pscp:" and "scp:", which is not what one expects at that point.

When I type "C-x C-f /scp: TAB", I see the same result as you, "pscp:"
and "scp:". However, the buffer *trace-output* contains

--8<---------------cut here---------------start------------->8---
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
--8<---------------cut here---------------end--------------->8---

That means, "scp:" hasn't been passed to
tramp-completion-handle-file-name-all-completions, and the result of
that function looks proper to me.

> With tramp-default-method set to "ssh", C-x C-f /ssh: TAB still
> displays "Sole completion".

Now I have called

--8<---------------cut here---------------start------------->8---
# emacs -Q -l tramp --eval "(add-to-list 'completion-styles 'substring)" --eval "(trace-function-background 'tramp-completion-handle-file-name-all-completions)" --eval '(setq tramp-default-method "ssh")'
--8<---------------cut here---------------end--------------->8---

Calling "C-x C-f /ssh: TAB" gives me indeed "Sole completion", and
*trace-output* still contains

--8<---------------cut here---------------start------------->8---
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
--8<---------------cut here---------------end--------------->8---

This also looks proper to me.

From the Tramp POV, there's no problem I believe. How completion
packages call file-name-all-completions, and how they interpret the
result, is out of Tramp's responsibility.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 14:33:01 GMT) Full text and rfc822 format available.

Message #71 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Gregory Heytings <gregory <at> heytings.org>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 16:31:51 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

Hi Lars,

> 1 unexpected results:
>    FAILED  tramp-test26-file-name-completion

Oops, yes. The test for default method completion doesn't make sense
anymore. I've fixed this in master. Sorry for the trouble!

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 16:47:01 GMT) Full text and rfc822 format available.

Message #74 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 16:46:00 +0000
>
> When I type "C-x C-f /scp: TAB", I see the same result as you, "pscp:" 
> and "scp:". However, the buffer *trace-output* contains
>
> ======================================================================
> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
> 1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
> ======================================================================
> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
> 1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:" "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:" "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:" "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:" "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:" "sftp:" "ftp:" "adb:")
>
> That means, "scp:" hasn't been passed to 
> tramp-completion-handle-file-name-all-completions, and the result of 
> that function looks proper to me.
>

Yet it isn't.

By the way, before your attempt to fix the problem, you would have seen:

1 -> (tramp-completion-handle-file-name-all-completions "" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("scp:" "scpx:")

IOW, one side effect of your patch is that C-x C-f / TAB now displays all 
Tramp methods.  And you said in your reply to Stefan: "For a completion of 
"/" Tramp tries to be silent, in order not to surprise the many users 
which don't use Tramp with candidates like "/adb:". They wouldn't know 
what's that."  I fully agree with that, and the problem is that Tramp 
tried to be "too smart" here, and to display completions that correspond 
to tramp-default-method, which confuses completion mechanisms.

IOW again:

- before your attempt to fix the problem, C-x C-f / TAB only displayed 
"scp:" and "scpx:" among the completion candidates (or e.g. "ssh:", 
"sshfs:" and "sshx:" with tramp-default-method set to "ssh");

- now C-x C-f / TAB displays all Tramp methods;

- with my patch, which actually fixes the bug, C-x C-f / TAB does not 
display any Tramp method, as it should.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 17:33:01 GMT) Full text and rfc822 format available.

Message #77 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 19:31:51 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

Hi Gregory,

>> When I type "C-x C-f /scp: TAB", I see the same result as you,
>> "pscp:" and "scp:". However, the buffer *trace-output* contains
>>
>> ======================================================================
>> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
>> 1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:"
>> "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:"
>> "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:"
>> "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:"
>> "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:"
>> "sftp:" "ftp:" "adb:")
>> ======================================================================
>> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
>> 1 <- tramp-completion-handle-file-name-all-completions: ("sudoedit:"
>> "sshfs:" "smb:" "rcp:" "remcp:" "scp:" "scpx:" "rsync:" "rsh:"
>> "remsh:" "ssh:" "sshx:" "telnet:" "nc:" "su:" "sg:" "sudo:" "doas:"
>> "ksu:" "krlogin:" "plink:" "plinkx:" "pscp:" "psftp:" "fcp:"
>> "rclone:" "afp:" "dav:" "davs:" "gdrive:" "mtp:" "nextcloud:"
>> "sftp:" "ftp:" "adb:")
>>
>> That means, "scp:" hasn't been passed to
>> tramp-completion-handle-file-name-all-completions, and the result of
>> that function looks proper to me.
>
> Yet it isn't.

Why not? In this example, `completion-styles' contains `substring'. And
then you ask for completion of "/scp:". Looking at the candidates
returned by `tramp-completion-handle-file-name-all-completions', only
"pscp:" and "scp:" have the substring "scp:".

Intuitively, I believe it is correct to show these two methods.

> By the way, before your attempt to fix the problem, you would have seen:
>
> 1 -> (tramp-completion-handle-file-name-all-completions "" "/")
> 1 <- tramp-completion-handle-file-name-all-completions: ("scp:" "scpx:")
>
> IOW, one side effect of your patch is that C-x C-f / TAB now displays
> all Tramp methods.

Yes.

> And you said in your reply to Stefan: "For a completion of "/" Tramp
> tries to be silent, in order not to surprise the many users which
> don't use Tramp with candidates like "/adb:". They wouldn't know
> what's that."  I fully agree with that, and the problem is that Tramp
> tried to be "too smart" here, and to display completions that
> correspond to tramp-default-method, which confuses completion
> mechanisms.

Indeed, I have changed my mind. The initial intention of Tramp's method
completion was to be not invasive, i.e. not to disturb Emacs users not
interested in Tramp.

Eli has reminded me, that we have changed Tramp later on such a way,
that its completion happens only when Tramp is loaded. This wasn't the
case before; Tramp was autoloaded just for its completion, which was not
appreciated by the users not interested in Tramp.

With that change, which is still preserved, there's no need for this
restriction any longer, because a user will see Tramp's completion only
after Tramp has been loaded.

> IOW again:
>
> - before your attempt to fix the problem, C-x C-f / TAB only displayed
>   "scp:" and "scpx:" among the completion candidates (or e.g. "ssh:",
>   "sshfs:" and "sshx:" with tramp-default-method set to "ssh");

Yes, this is changed.

> - now C-x C-f / TAB displays all Tramp methods;

When Tramp is loaded. I regard this to be correct.

> - with my patch, which actually fixes the bug, C-x C-f / TAB does not
>   display any Tramp method, as it should.

Again, C-x C-f / TAB displays a Tramp method only when Tramp is
loaded. What is wrong with this?

Best regards, Michael.




Reply sent to Gregory Heytings <gregory <at> heytings.org>:
You have taken responsibility. (Tue, 07 Sep 2021 17:52:02 GMT) Full text and rfc822 format available.

Notification sent to Gregory Heytings <gregory <at> heytings.org>:
bug acknowledged by developer. (Tue, 07 Sep 2021 17:52:02 GMT) Full text and rfc822 format available.

Message #82 received at 50387-done <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387-done <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 17:51:17 +0000
>>> That means, "scp:" hasn't been passed to 
>>> tramp-completion-handle-file-name-all-completions, and the result of 
>>> that function looks proper to me.
>>
>> Yet it isn't.
>
> Why not? In this example, `completion-styles' contains `substring'. And 
> then you ask for completion of "/scp:". Looking at the candidates 
> returned by `tramp-completion-handle-file-name-all-completions', only 
> "pscp:" and "scp:" have the substring "scp:".
>

Because after typing "/s" or "/sc" or "/scp" it makes sense to see that 
"/scp:" is among the completion candidates, but after typing "/scp:" it 
doesn't make sense anymore, the method has already been entered by the 
user, what they now want to see is a list of hosts, and there is no way to 
see it.

>> - before your attempt to fix the problem, C-x C-f / TAB only displayed 
>> "scp:" and "scpx:" among the completion candidates (or e.g. "ssh:", 
>> "sshfs:" and "sshx:" with tramp-default-method set to "ssh");
>
> Yes, this is changed.
>
>> - now C-x C-f / TAB displays all Tramp methods;
>
> When Tramp is loaded. I regard this to be correct.
>
>> - with my patch, which actually fixes the bug, C-x C-f / TAB does not 
>> display any Tramp method, as it should.
>
> Again, C-x C-f / TAB displays a Tramp method only when Tramp is loaded.
>

I filed a bug report, explained in every detail what the bug is, provided 
a patch, and the end result is a situation that is worse than earlier.  I 
expect other bug reports from confused users, and hope that you'll change 
your mind.

Closing.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 18:05:02 GMT) Full text and rfc822 format available.

Message #85 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 20:04:03 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

Hi Gregory,

>> Why not? In this example, `completion-styles' contains
>> `substring'. And then you ask for completion of "/scp:". Looking at
>> the candidates returned by
>> `tramp-completion-handle-file-name-all-completions', only "pscp:"
>> and "scp:" have the substring "scp:".
>>
>
> Because after typing "/s" or "/sc" or "/scp" it makes sense to see
> that "/scp:" is among the completion candidates, but after typing
> "/scp:" it doesn't make sense anymore, the method has already been
> entered by the user, what they now want to see is a list of hosts, and
> there is no way to see it.

Type any first char of a user or host name, and you'll see it.

> I filed a bug report, explained in every detail what the bug is,
> provided a patch, and the end result is a situation that is worse than
> earlier.  I expect other bug reports from confused users,

We'll see. In my opinion, the situation isn't worse, but more
consistent, because there is no arbitrary filtering of method names
anymore (arbitrary in the eye of a user).

> and hope that you'll change your mind.

I will, when I'm convinced the current situation isn't acceptable. The
current situation (you must type a char in order to see the host name)
is described in the Tramp manual, and I haven't heard complaints about
since ever. (I know, nobody reads manuals ...)

> Closing.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 19:03:01 GMT) Full text and rfc822 format available.

Message #88 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 19:02:06 +0000
>
> I will, when I'm convinced the current situation isn't acceptable. The 
> current situation (you must type a char in order to see the host name) 
> is described in the Tramp manual, and I haven't heard complaints about 
> since ever.
>

That might be what the manual says, but it's not what the current 
situation actually is.  Type C-x C-f /scp TAB and you'll see scp: scpx:. 
Type C-x C-f /scp: TAB and you'll see scp:foo: scp:bar:.  This is 
coherent, ':' acts like a directory separator, like the '://' in URLs.

But for those who use the substring and flex completion styles, typing C-x 
C-f /scp TAB displays pscp: scp: scpx:.  Typing C-x C-f /scp: TAB still 
displays scp: scpx:.  This isn't at all coherent.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Tue, 07 Sep 2021 19:42:01 GMT) Full text and rfc822 format available.

Message #91 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Tue, 07 Sep 2021 19:41:44 +0000
[Message part 1 (text/plain, inline)]
>> I will, when I'm convinced the current situation isn't acceptable. The 
>> current situation (you must type a char in order to see the host name) 
>> is described in the Tramp manual, and I haven't heard complaints about 
>> since ever.
>
> That might be what the manual says
>

And in fact that's not what the manual says.  See (info "(tramp)File name 
completion"):

[After ‘/ssh:’,] typing ‘<TAB>’ shows host names TRAMP extracts from 
‘~/.ssh/config’ file, for example.

       ssh:127.0.0.1:                       ssh:192.168.0.1:
       ssh:[::1]:                           ssh:localhost:
       ssh:melancholia.danann.net:          ssh:melancholia:

Choose a host from the above list and then continue to complete file names 
on that host.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Wed, 08 Sep 2021 07:28:01 GMT) Full text and rfc822 format available.

Message #94 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Wed, 08 Sep 2021 09:26:54 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

>>
>> I will, when I'm convinced the current situation isn't
>> acceptable. The current situation (you must type a char in order to
>> see the host name) is described in the Tramp manual, and I haven't
>> heard complaints about since ever.
>>
>
> That might be what the manual says, but it's not what the current
> situation actually is.  Type C-x C-f /scp TAB and you'll see scp:
> scpx:.

Sure. Completion style `substring' is not active, and so we see in the
traces buffer

--8<---------------cut here---------------start------------->8---
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "scp" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("scp:" "scpx:")
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "scp" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("scp:" "scpx:")
--8<---------------cut here---------------end--------------->8---

See, how `tramp-completion-handle-file-name-all-completions' is invoked
differently.

> Type C-x C-f /scp: TAB and you'll see scp:foo: scp:bar:.  This
> is coherent, ':' acts like a directory separator, like the '://' in
> URLs.

The traces show us

--8<---------------cut here---------------start------------->8---
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "scp:" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("scp:test:" ... "scp:osboxes@")
======================================================================
1 -> (tramp-completion-handle-file-name-all-completions "scp:" "/")
1 <- tramp-completion-handle-file-name-all-completions: ("scp:test:" ... "scp:osboxes@")
--8<---------------cut here---------------end--------------->8---

(I've cut the result of the function, you don't want to see the zillions
of possible completions in my stanza :-) Again, see the arguments the
function is called with.

> But for those who use the substring and flex completion styles, typing
> C-x C-f /scp TAB displays pscp: scp: scpx:.  Typing C-x C-f /scp: TAB
> still displays scp: scpx:.  This isn't at all coherent.

I've said it several times: `tramp-completion-handle-file-name-all-completions'
is called with arguments, and it returns a corresponding result. It is
consistent. How completion styles interpret the result, is out of
Tramp's responsibility.

I don't say there's no bug. But as Tramp maintainer I believe there is
no bug in Tramp (anymore); I have no knowledge of completion styles in
order to help fixing it there.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Wed, 08 Sep 2021 07:30:02 GMT) Full text and rfc822 format available.

Message #97 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Wed, 08 Sep 2021 09:28:52 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

>>> I will, when I'm convinced the current situation isn't
>>> acceptable. The current situation (you must type a char in order to
>>> see the host name) is described in the Tramp manual, and I haven't
>>> heard complaints about since ever.
>>
>> That might be what the manual says
>>
>
> And in fact that's not what the manual says.  See (info "(tramp)File
> name completion"):

You're right, my answer was reckless. Sorry.

Best regards, Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Wed, 08 Sep 2021 07:58:01 GMT) Full text and rfc822 format available.

Message #100 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Gregory Heytings <gregory <at> heytings.org>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Wed, 08 Sep 2021 07:57:27 +0000
>
> But as Tramp maintainer I believe there is no bug in Tramp (anymore); I 
> have no knowledge of completion styles in order to help fixing it there.
>

There is a bug, because the return values provided by Tramp to the 
(substring and flex) completion mechanisms are not what these mechanisms 
expect to do their job.  Tramp should not return methods when 
(tramp-completion-handle-file-name-all-completions "" "/") is called, 
because there are no methods in the root directory, what the root 
directory contains is files.  If Tramp was using another character instead 
of "/" before methods, the problem would not exist because there would be 
a clear way to differentiate files and methods.

Anyway, I think I've now made my point as clear as possible, and I use the 
correct bugfix in my local Emacs, so I won't continue this discussion.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#50387; Package emacs. (Wed, 08 Sep 2021 14:26:02 GMT) Full text and rfc822 format available.

Message #103 received at 50387 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Gregory Heytings <gregory <at> heytings.org>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 50387 <at> debbugs.gnu.org
Subject: Re: bug#50387: Possible bug in Tramp or in completions
Date: Wed, 08 Sep 2021 16:25:06 +0200
Gregory Heytings <gregory <at> heytings.org> writes:

Hi Gregory,

> Tramp should not return methods when
> (tramp-completion-handle-file-name-all-completions "" "/") is called,
> because there are no methods in the root directory, what the root
> directory contains is files.  If Tramp was using another character
> instead of "/" before methods, the problem would not exist because
> there would be a clear way to differentiate files and methods.

FTR, this is simply wrong. Remote file names, starting with
"/<method>:", are first class Emacs citizens, designed that way more
than twenty years ago.

Completion styles have been added later.

> Anyway, I think I've now made my point as clear as possible, and I use
> the correct bugfix in my local Emacs, so I won't continue this
> discussion.

As you like. Until this problem has been fixed, I'll add a note to
Tramp's manual, that user and host name completion with the `substring'
or `flex' style require an initial letter or digit of the name.

Best regards, Michael.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 07 Oct 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.