GNU bug report logs - #53935
27.2; [PATCH] ecomplete.el: Auto-select when there is only a single option

Previous Next

Package: emacs;

Reported by: Phil Sainty <psainty <at> orcon.net.nz>

Date: Fri, 11 Feb 2022 02:48:01 UTC

Severity: wishlist

Tags: patch

Found in version 27.2

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.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 53935 in the body.
You can then email your comments to 53935 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#53935; Package emacs. (Fri, 11 Feb 2022 02:48:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Phil Sainty <psainty <at> orcon.net.nz>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 11 Feb 2022 02:48:01 GMT) Full text and rfc822 format available.

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

From: Phil Sainty <psainty <at> orcon.net.nz>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; [PATCH] ecomplete.el: Auto-select when there is only a single
 option
Date: Fri, 11 Feb 2022 15:47:14 +1300
[Message part 1 (text/plain, inline)]
I tried out ecomplete for email address completion today(*),
and I found it slightly annoying that when there was only a
single match for the text, I still have to firstly type M-n
to access the completion 'list', and then RET to select the
only available option.

Would the attached patch be a reasonable enhancement?


-Phil

(*) On account of 
https://www.reddit.com/r/emacs/comments/sl33w6/ecomplete_the_emacs_contact_manager_you_were/



In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, X toolkit, Xaw scroll 
bars)
 of 2021-07-12 built on phil-lp
Windowing system distributor 'The X.Org Foundation', version 
11.0.12008000
System Description: Ubuntu 18.04.6 LTS
[ecomplete-auto-select.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Fri, 11 Feb 2022 06:31:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Fri, 11 Feb 2022 07:30:03 +0100
Phil Sainty <psainty <at> orcon.net.nz> writes:

> I tried out ecomplete for email address completion today(*),
> and I found it slightly annoying that when there was only a
> single match for the text, I still have to firstly type M-n
> to access the completion 'list', and then RET to select the
> only available option.
>
> Would the attached patch be a reasonable enhancement?

ecomplete tries to emulate how these things work in major browsers, and
they do not work this way (autoselect when there's only one match) --
because the user may be typing to see what's available, and would then
remove some characters if they don't get the matches they're looking
for.

So if we're adding this, it should default to nil, but I'm a bit
sceptical that many people would want the auto-select behaviour in any
case.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Fri, 11 Feb 2022 08:29:02 GMT) Full text and rfc822 format available.

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

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Fri, 11 Feb 2022 21:28:16 +1300
On 2022-02-11 19:30, Lars Ingebrigtsen wrote:
> ecomplete tries to emulate how these things work in major browsers,
> and they do not work this way (autoselect when there's only one
> match) -- because the user may be typing to see what's available,
> and would then remove some characters if they don't get the matches
> they're looking for.

They can still do all of that, just as before.

The "automated" part of my patch happens *after* the user has finished
adding/removing characters, and has explicitly said (via M-n) that they
now wish to choose from one of the visible completion options.

The only difference between the old and new behaviour is that, in cases
where they'd filtered the completion options down to a single option,
they no longer have to additionally (and redundantly) type RET after
M-n to select the only thing that they could possibly select.

("M-n" acts like the sequence "M-n RET", in other words.)


-Phil





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Fri, 11 Feb 2022 10:25:01 GMT) Full text and rfc822 format available.

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

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Fri, 11 Feb 2022 23:24:15 +1300
[Message part 1 (text/plain, inline)]
I realised this would be better with some minor refactoring of
the existing code, so I'm attaching a new version of that patch.

I've used "git diff --ignore-space-change" for clarity (hence the
indentation isn't correct).
[ecomplete-auto-select2.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Sat, 12 Feb 2022 06:50:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Sat, 12 Feb 2022 07:49:27 +0100
Phil Sainty <psainty <at> orcon.net.nz> writes:

> The "automated" part of my patch happens *after* the user has finished
> adding/removing characters, and has explicitly said (via M-n) that they
> now wish to choose from one of the visible completion options.
>
> The only difference between the old and new behaviour is that, in cases
> where they'd filtered the completion options down to a single option,
> they no longer have to additionally (and redundantly) type RET after
> M-n to select the only thing that they could possibly select.
>
> ("M-n" acts like the sequence "M-n RET", in other words.)

Ah, I see.  Well, that's a lot better.  But...  it seems like a lot of
stuff to just not have to hit RET when choosing an email address.  And
it makes the action of `M-n' less predicable -- sometimes it'll choose a
name, and sometimes not.

So I'm still not sure whether this makes sense for Emacs.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Sat, 12 Feb 2022 10:28:01 GMT) Full text and rfc822 format available.

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

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Sat, 12 Feb 2022 23:27:31 +1300
On 2022-02-12 19:49, Lars Ingebrigtsen wrote:
> Ah, I see.  Well, that's a lot better.  But...  it seems like a lot
> of stuff to just not have to hit RET when choosing an email address.

I thought that it was a small amount of stuff to prevent a noticeable
irritation.

I can see that you don't find the current behaviour to be irritating,
but "why can't I complete a singlular match with a single command?"
was one of my first questions upon trying ecomplete, so I'd be awfully
surprised if I was alone in that.


> And it makes the action of `M-n' less predicable -- sometimes it'll
> choose a name, and sometimes not.

I feel this is mitigated by the fact that the user sees in advance
what it's going to do (based on whether there's one match, or more
than one match, displayed in the echo area at the time).


> So I'm still not sure whether this makes sense for Emacs.

Having it as a user option is appropriate then, I think.  I'm in
favour of enabling the patched behaviour by default, but I don't mind
if it's opt-in.

I probably didn't pick a good name for the option, though.  In
hindsight something like `ecomplete-display-matches-auto-choose' is
probably better.  Or `ecomplete-display-matches-choose-dwim', given
that it's a DWIM-ish behaviour?


-Phil





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Sun, 13 Feb 2022 08:15:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Sun, 13 Feb 2022 09:14:12 +0100
Phil Sainty <psainty <at> orcon.net.nz> writes:

> I probably didn't pick a good name for the option, though.  In
> hindsight something like `ecomplete-display-matches-auto-choose' is
> probably better.  Or `ecomplete-display-matches-choose-dwim', given
> that it's a DWIM-ish behaviour?

The latter sounds better to me.

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Sun, 13 Feb 2022 17:25:01 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Phil Sainty <psainty <at> orcon.net.nz>
Cc: "53935 <at> debbugs.gnu.org" <53935 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select
 when there is only a single option
Date: Sun, 13 Feb 2022 17:24:18 +0000
> > I probably didn't pick a good name for the option, though.  In
> > hindsight something like `ecomplete-display-matches-auto-choose' is
> > probably better.  Or `ecomplete-display-matches-choose-dwim', given
> > that it's a DWIM-ish behaviour?
> 
> The latter sounds better to me.

FWIW:

1. Icicles has had such an option since 2007:
`icicle-top-level-when-sole-completion-flag'

 Non-nil means to return to top level if only
 one matching completion.  The sole completion
 is accepted.

And there's a companion option:
`icicle-top-level-when-sole-completion-delay'

 Number of secs to wait to return to top level
 if only one completion.  This has no effect if
 `icicle-top-level-when-sole-completion-flag' is
 nil.  Editing the completion (typing or deleting
 a character) before the delay expires prevents
 its automatic acceptance.

 Do not set this to 0.0.  Set it to slightly
 more than zero if you want instant action.

Maybe something like "accept-sole-completion"
would be a good name for your option?  (Emacs
no longer respects RMS's convention of `-flag'
for Boolean-valued vars).

2. Drop "-dwim-" from the name of your option.
That adds nothing but noise.  Meaningless, if
not misleading.

And does this really have anything to do with
_displaying matches_?  IIUC, it doesn't.

So far, the names proposed don't seem to
convey what (I think) this option does.




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sun, 19 Jun 2022 19:05:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53935; Package emacs. (Thu, 08 Sep 2022 12:54:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Phil Sainty <psainty <at> orcon.net.nz>
Cc: 53935 <at> debbugs.gnu.org
Subject: Re: bug#53935: 27.2; [PATCH] ecomplete.el: Auto-select when there
 is only a single option
Date: Thu, 08 Sep 2022 14:53:25 +0200
Phil Sainty <psainty <at> orcon.net.nz> writes:

> I realised this would be better with some minor refactoring of
> the existing code, so I'm attaching a new version of that patch.
>
> I've used "git diff --ignore-space-change" for clarity (hence the
> indentation isn't correct).

Thanks; I've now pushed this to Emacs 29 (with minor changes).




bug marked as fixed in version 29.1, send any further explanations to 53935 <at> debbugs.gnu.org and Phil Sainty <psainty <at> orcon.net.nz> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 08 Sep 2022 12:54:03 GMT) Full text and rfc822 format available.

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

This bug report was last modified 1 year 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.