GNU bug report logs - #53362
29.0.50; [PATCH] Make Completions sorting a user option

Previous Next

Package: emacs;

Reported by: Protesilaos Stavrou <info <at> protesilaos.com>

Date: Wed, 19 Jan 2022 12:28:01 UTC

Severity: normal

Tags: patch

Found in version 29.0.50

Done: Eli Zaretskii <eliz <at> gnu.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 53362 in the body.
You can then email your comments to 53362 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#53362; Package emacs. (Wed, 19 Jan 2022 12:28:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Protesilaos Stavrou <info <at> protesilaos.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 19 Jan 2022 12:28:01 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Wed, 19 Jan 2022 14:26:47 +0200
[Message part 1 (text/plain, inline)]
Dear maintainers,

I was wondering whether we could make the sorting of candidates in the
Completions' buffer subject to a user option.

See the attached patch for a possible implementation.  I have kept it
backward-compatible by making string-lessp the default sort function.

All the best,
Protesilaos

-- 
Protesilaos Stavrou
https://protesilaos.com
[0001-Make-Completions-sorting-a-user-option.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Wed, 19 Jan 2022 12:58:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: 53362 <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Wed, 19 Jan 2022 14:56:56 +0200
> From: Protesilaos Stavrou <info <at> protesilaos.com>
> Date: Wed, 19 Jan 2022 14:26:47 +0200
> 
> +(defcustom completions-sort 'lexicographic
> +  "Sort candidates in the *Completions* buffer.
> +
> +The value can be nil to disable sorting altogether,
> +`alphabetical' for alphabetical sorting, `lexicographic' for
> +lexicographic sorting

Here you expect everyone to understand the subtle difference between
these two sorting orders.  I don't think this expectation is
reasonable.

> +                                            ('alphabetical (sort completions #'string-version-lessp))

Doesn't string-version-lessp do stuff that is only appropriate with
version numbers like 1.2.3beta?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Wed, 19 Jan 2022 13:18:02 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 53362 <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Wed, 19 Jan 2022 15:17:13 +0200
On 2022-01-19, 14:56 +0200, Eli Zaretskii <eliz <at> gnu.org> wrote:

>> From: Protesilaos Stavrou <info <at> protesilaos.com>
>> Date: Wed, 19 Jan 2022 14:26:47 +0200
>> 
>> +(defcustom completions-sort 'lexicographic
>> +  "Sort candidates in the *Completions* buffer.
>> +
>> +The value can be nil to disable sorting altogether,
>> +`alphabetical' for alphabetical sorting, `lexicographic' for
>> +lexicographic sorting
>
> Here you expect everyone to understand the subtle difference between
> these two sorting orders.  I don't think this expectation is
> reasonable.

Perhaps it is better to reference string-lessp and string-version-lessp
directly?

>> +                                            ('alphabetical (sort completions #'string-version-lessp))
>
> Doesn't string-version-lessp do stuff that is only appropriate with
> version numbers like 1.2.3beta?

It also helps when the string starts with a number:

    (sort '("1 test" "21 test" "11 test" "2 test") #'string-lessp)
    ;; => ("1 test" "11 test" "2 test" "21 test")

    (sort '("1 test" "21 test" "11 test" "2 test") #'string-version-lessp)
    ;; => ("1 test" "2 test" "11 test" "21 test")


-- 
Protesilaos Stavrou
https://protesilaos.com




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Wed, 19 Jan 2022 13:28:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: 53362 <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Wed, 19 Jan 2022 15:27:38 +0200
> From: Protesilaos Stavrou <info <at> protesilaos.com>
> Cc: 53362 <at> debbugs.gnu.org
> Date: Wed, 19 Jan 2022 15:17:13 +0200
> 
> >> +(defcustom completions-sort 'lexicographic
> >> +  "Sort candidates in the *Completions* buffer.
> >> +
> >> +The value can be nil to disable sorting altogether,
> >> +`alphabetical' for alphabetical sorting, `lexicographic' for
> >> +lexicographic sorting
> >
> > Here you expect everyone to understand the subtle difference between
> > these two sorting orders.  I don't think this expectation is
> > reasonable.
> 
> Perhaps it is better to reference string-lessp and string-version-lessp
> directly?

That'd be a step backward, IMO.

> > Doesn't string-version-lessp do stuff that is only appropriate with
> > version numbers like 1.2.3beta?
> 
> It also helps when the string starts with a number:
> 
>     (sort '("1 test" "21 test" "11 test" "2 test") #'string-lessp)
>     ;; => ("1 test" "11 test" "2 test" "21 test")

Yes, and how does that match the "alphabetical order" description?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Wed, 19 Jan 2022 14:10:02 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 53362 <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Wed, 19 Jan 2022 16:09:05 +0200
[Message part 1 (text/plain, inline)]
On 2022-01-19, 15:27 +0200, Eli Zaretskii <eliz <at> gnu.org> wrote:

>> From: Protesilaos Stavrou <info <at> protesilaos.com>
>> Cc: 53362 <at> debbugs.gnu.org
>> Date: Wed, 19 Jan 2022 15:17:13 +0200
>> 
>> >> +(defcustom completions-sort 'lexicographic
>> >> +  "Sort candidates in the *Completions* buffer.
>> >> +
>> >> +The value can be nil to disable sorting altogether,
>> >> +`alphabetical' for alphabetical sorting, `lexicographic' for
>> >> +lexicographic sorting
>> >
>> > Here you expect everyone to understand the subtle difference between
>> > these two sorting orders.  I don't think this expectation is
>> > reasonable.
>> 
>> Perhaps it is better to reference string-lessp and string-version-lessp
>> directly?
>
> That'd be a step backward, IMO.
>
>> > Doesn't string-version-lessp do stuff that is only appropriate with
>> > version numbers like 1.2.3beta?
>> 
>> It also helps when the string starts with a number:
>> 
>>     (sort '("1 test" "21 test" "11 test" "2 test") #'string-lessp)
>>     ;; => ("1 test" "11 test" "2 test" "21 test")
>
> Yes, and how does that match the "alphabetical order" description?

In the revised patch (see attached), I follow the example of
completions-group-sort.

-- 
Protesilaos Stavrou
https://protesilaos.com
[0001-Make-Completions-sorting-a-user-option.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Wed, 19 Jan 2022 16:11:02 GMT) Full text and rfc822 format available.

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

From: Drew Adams <drew.adams <at> oracle.com>
To: Protesilaos Stavrou <info <at> protesilaos.com>, "53362 <at> debbugs.gnu.org"
 <53362 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#53362: 29.0.50; [PATCH] Make Completions sorting
 a user option
Date: Wed, 19 Jan 2022 16:10:13 +0000
See library sortie.el.

* Description: https://www.emacswiki.org/emacs/Sortie

* Code: https://www.emacswiki.org/emacs/download/sortie.el

You can define sort orders and choose among them on the fly.

Different sort orders are appropriate for different operations, different sets of completion candidates, and different use cases/contexts and users.

A user option to choose a preferred sort order is at best appropriate for an overall _default_ sort order.

It could also be a place to hold a set of sort orders, including orders defined by a user.  But on its own, it can't deal with the need to be able to change sort orders anytime.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Wed, 19 Jan 2022 17:18:01 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 53362 <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Wed, 19 Jan 2022 19:16:57 +0200
[Message part 1 (text/plain, inline)]
On 2022-01-19, 16:09 +0200, Protesilaos Stavrou <info <at> protesilaos.com> wrote:

> In the revised patch (see attached), I follow the example of
> completions-group-sort.

I sent a faulty patch.  Sorry!  Attached is the one that should work as intended.

-- 
Protesilaos Stavrou
https://protesilaos.com
[0001-Make-Completions-sorting-a-user-option.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53362; Package emacs. (Thu, 20 Jan 2022 05:34:02 GMT) Full text and rfc822 format available.

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

From: Protesilaos Stavrou <info <at> protesilaos.com>
To: 53362 <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Thu, 20 Jan 2022 07:33:38 +0200
[Message part 1 (text/plain, inline)]
On 2022-01-19, 19:16 +0200, Protesilaos Stavrou <info <at> protesilaos.com> wrote:

> On 2022-01-19, 16:09 +0200, Protesilaos Stavrou <info <at> protesilaos.com> wrote:
>
>> In the revised patch (see attached), I follow the example of
>> completions-group-sort.
>
> I sent a faulty patch.  Sorry!  Attached is the one that should work as intended.

This is awkward: I sent the wrong file twice.

If you are still reading this, I attach the definitive patch.

-- 
Protesilaos Stavrou
https://protesilaos.com
[0001-Make-Completions-sorting-a-user-option.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Mon, 24 Jan 2022 13:39:02 GMT) Full text and rfc822 format available.

Notification sent to Protesilaos Stavrou <info <at> protesilaos.com>:
bug acknowledged by developer. (Mon, 24 Jan 2022 13:39:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Protesilaos Stavrou <info <at> protesilaos.com>
Cc: 53362-done <at> debbugs.gnu.org
Subject: Re: bug#53362: 29.0.50; [PATCH] Make Completions sorting a user option
Date: Mon, 24 Jan 2022 15:37:58 +0200
> From: Protesilaos Stavrou <info <at> protesilaos.com>
> Date: Thu, 20 Jan 2022 07:33:38 +0200
> 
> If you are still reading this, I attach the definitive patch.

Thanks, now installed on master.




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

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

Previous Next


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