[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] `completing-read`: Add `group-function` support to completio

From: Daniel Mendler
Subject: Re: [PATCH] `completing-read`: Add `group-function` support to completion metadata (REVISED PATCH VERSION 2)
Date: Fri, 7 May 2021 19:55:19 +0200

On 5/7/21 7:03 PM, Juri Linkov wrote:
> I tried to remove `read-char-by-name-group`, but it has a feature
> currently not supported by `group-function`:
>   (defcustom read-char-by-name-group nil
>     "How to group characters for `read-char-by-name' completion.
>   When t, split characters to sections of Unicode blocks
>   sorted alphabetically."
>   =====================
> It seems a new function is needed to sort groups, e.g. `group-sort-function`.
> Maybe better to push your current patches, so it would be easier
> to base the next patches on master?

My original thoughts for a `group-function` proposal were such that the
`group-function` had the capability to sort the groups. During the
previous discussion with Stefan and Dmitry we somehow agreed that it is
better to keep things simple and to not allow the `group-function` to
sort the groups. Instead, sorting should only be provided by the

For context, you can find the previous discussion at
https://github.com/minad/consult/issues/283. See in particular comment
https://github.com/minad/consult/issues/283#issuecomment-825749551. (I
would have pinged you there if I would have known that you are
interested in that functionality. I was not aware that
`read-char-by-name-group` had recently been added to Emacs master.)

I suggest to add a special `cycle/display-sort-function` to the
completion table if `read-char-by-name-group` is non-nil, which sorts
the candidates such that you achieve the desired group order. I would
avoid adding a separate `group-sort-function`.

Alternatively one may consider to give up the sorting as is present in
the current `read-char-by-name-group` functionality. From my perspective
that would be okay. The behavior is more predictable if sorting is only
performed by the `cycle/display-sort-function` and not by some
additional sorting function.

I believe I've also read some critical comments on the mailing list
before regarding the existence of `cycle/display-sort-functions` in
completion tables. The argument was that sorting should be provided
mostly by the completion UI and the completion style as configured by
the user externally from the completion table. This reflects my
experience - I am often happy with the default sorting as provided by
the completion UI (for example by history position, length and
alphabetically) or by the sorting as provided by the flex completion style.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]