From: Spencer Baugh <sbaugh@janestreet.com>
To: Juri Linkov <juri@linkov.net>
Cc: sbaugh@catern.com, emacs-devel@gnu.org
Subject: Re: Updating *Completions* as you type
Date: Tue, 21 Nov 2023 15:45:20 -0500 [thread overview]
Message-ID: <ier1qcin8db.fsf@janestreet.com> (raw)
In-Reply-To: <861qcjw3ch.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 21 Nov 2023 19:09:02 +0200")
Juri Linkov <juri@linkov.net> writes:
>>>> (or
>>>> (alist-get 'display-sort-function (alist-get category completion-category-overrides))
>>>> (alist-get 'display-sort-function metadata)
>>>> (alist-get 'display-sort-function (alist-get category completion-category-defaults))
>>>> completions-sort)
>>>
>>> 1. display-buffer-overriding-action
>>> 2. display-buffer-alist
>>> 3. function call arguments that correspond to completion metadata
>>> 4. display-buffer-base-action
>>> 5. display-buffer-fallback-action
>>
>> A few points in favor of
>>
>> (alist-get 'display-sort-function metadata)
>> (alist-get 'display-sort-function (alist-get category completion-category-overrides))
>>
>> instead:
>>
>> - Again, the user is still able to configure the display-sort-function
>> by configuring the individual completion table.
>
> Does this mean that every individual completion table should have
> a separate user option?
No: only the completion tables which specify a display-sort-function in
their metadata. All such completion tables should have a user option to
configure that display-sort-function.
>> That's not true with display-buffer. The only configuration
>> mechanism is display-buffer-alist.
>
> Actually several user options already exist for display-buffer such as
> display-comint-buffer-action and display-tex-shell-buffer-action.
> They cover a whole category of display-buffer calls that display
> all types of comint buffers, etc. So these options correspond
> to completion categories, not to individual completion tables.
Interesting.
It looks like those user options configure a broad category, as you say,
and they do this by changing the ACTION function call argument in
various places.
So, those user options configure a broad category, and then more
specific configuration overrides that broad category. I suppose that's
what I also suggest for completion sorting.
>> - Given that the user can still configure the display-sort-function, I
>> don't see any use case where the user should override it. (A buggy
>> completion table that returns the wrong display-sort-function? But
>> that should just be fixed.)
>
> I don't understand how the user can configure the display-sort-function,
> please elaborate.
If a completion table specifies a display-sort-function in its metadata,
it should have a user option to configure that display-sort-function.
>> - display-buffer-alist is driven purely by buffer-match-p conditions, so
>> there's a linear sequence of overriding. The display-sort-function
>> has two levels: the completion table and the completion category.
>> Since the table is more specific than the category, it should override
>> the category.
>
> Agreed. But this means only one thing that a user option
> for an individual completion table should take precedence
> over completion-category-overrides.
Well, yes. So then we agree that a user option for an individual
completion table, if it exists, should take precedence over
completion-category-overrides? So then we're only disagreeing over
whether such options should exist?
>> - As a minor point, I, and many other Emacs users IME, find the
>> display-buffer configuration to be complex and hard to use, so I don't
>> think we should try to emulate it too much.
>
> What is an alternative? A myriad of individual options?
For display-buffer configuration? I'm not sure, I don't want to get
into it too much.
For completion sorting configuration, though, I'm not suggesting adding
many individual options. I'm quite happy with the proposal of,
"categories can determine the display-sort-function, and then options
for individual completion tables will override that".
In that world, there would be a read-buffer-sort option - but it would
be nil by default, so the read-buffer completion table by default
wouldn't specify a display-sort-function. And the user could configure
read-buffer completion sorting using completion-category-overrides
however they like; and if they set read-buffer-sort to something else,
then it will in turn override the category-based configuration.
These individual options would also provide a natural place to document
behavior like "if you configure the display-sort-function for buffer
completion to 'identity, then the buffer sort order will match
(buffer-list)". But the user could still make use of that information
by configuring the category.
>> Alternatively, could we just add support for configuring the individual
>> table now, and add category-based configuration later? We don't need to
>> add everything all at once, and that will give us valuable user
>> feedback.
>
> I see no need to add individual options as all. Every completion table
> that significantly differs from other tables so that it needs a separate
> display-sort-function, could provide a separate category. For example,
> there is a category 'buffer'. If 'switch-to-buffer' needs another
> display-sort-function it could provide a category 'buffer-for-switching'.
That won't work with the scenario I described before with sorting
file-name completion by mtime, where changing the sorting requires also
changing the completion table.
Also, this would require adding a category for essentially every
completion table. For example, I see that read-from-kill-ring specifies
a display-sort-function, currently set to 'identity. If we wanted to
make that configurable, it seems much easier to just do
(if (eq action 'metadata)
;; Keep sorted by recency
- '(metadata (display-sort-function . identity))
+ `(metadata (display-sort-function . ,read-from-kill-ring-sort))
(complete-with-action action completions string pred)))
instead of adding a category 'kill-ring and sticking that into
completion-category-defaults.
next prev parent reply other threads:[~2023-11-21 20:45 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-12 23:53 Updating *Completions* as you type sbaugh
2023-10-13 6:31 ` Eli Zaretskii
2023-10-13 18:01 ` Spencer Baugh
2023-10-14 7:09 ` Eli Zaretskii
2023-10-14 19:26 ` Björn Bidar
[not found] ` <874jit2ef7.fsf@>
2023-10-14 19:38 ` Eli Zaretskii
2023-10-14 16:51 ` Juri Linkov
2023-10-14 17:56 ` sbaugh
2023-10-14 19:51 ` Dmitry Gutov
2023-10-13 6:34 ` Juri Linkov
2023-10-13 19:04 ` Spencer Baugh
2023-10-14 16:58 ` Juri Linkov
2023-10-14 20:05 ` sbaugh
2023-10-15 6:06 ` Eli Zaretskii
2023-10-15 15:55 ` sbaugh
2023-10-16 11:38 ` Eli Zaretskii
2023-10-16 14:50 ` Michael Albinus
2023-10-16 15:58 ` [External] : " Drew Adams
2023-10-16 12:16 ` sbaugh
2023-10-17 18:23 ` Juri Linkov
2023-10-18 23:27 ` Spencer Baugh
2023-10-15 7:32 ` Juri Linkov
2023-10-16 19:28 ` Rudolf Adamkovič
2023-10-17 18:38 ` Juri Linkov
2023-10-15 20:31 ` Eshel Yaron
2023-10-16 3:18 ` [External] : " Drew Adams
2023-10-16 16:54 ` Juri Linkov
2023-10-17 13:48 ` sbaugh
2023-10-17 18:35 ` Juri Linkov
2023-10-17 22:57 ` Spencer Baugh
2023-10-18 3:04 ` [External] : " Drew Adams
2023-10-18 6:56 ` Juri Linkov
2023-10-18 12:25 ` Spencer Baugh
2023-10-18 17:32 ` Juri Linkov
2023-10-18 23:33 ` Spencer Baugh
2023-10-19 2:29 ` Spencer Baugh
2023-10-19 6:55 ` Juri Linkov
2023-11-19 19:22 ` sbaugh
2023-11-20 7:51 ` Juri Linkov
2023-11-20 15:24 ` Spencer Baugh
2023-11-20 17:47 ` Juri Linkov
2023-11-20 18:50 ` Spencer Baugh
2023-11-21 7:58 ` Juri Linkov
2023-11-21 12:40 ` sbaugh
2023-11-21 17:09 ` Juri Linkov
2023-11-21 20:45 ` Spencer Baugh [this message]
2023-11-22 7:51 ` Juri Linkov
2023-11-22 16:11 ` Spencer Baugh
2023-11-23 7:58 ` Juri Linkov
2023-11-23 12:36 ` sbaugh
2023-11-24 7:58 ` Juri Linkov
2023-11-25 16:44 ` Spencer Baugh
2023-11-25 18:31 ` Juri Linkov
2023-11-26 13:33 ` sbaugh
2023-11-27 7:28 ` Juri Linkov
2023-11-28 14:38 ` Spencer Baugh
2023-11-28 15:03 ` Eli Zaretskii
2023-11-28 17:13 ` Juri Linkov
2023-11-28 17:36 ` Eli Zaretskii
2023-11-29 7:11 ` Juri Linkov
2023-11-29 13:09 ` Eli Zaretskii
2023-11-29 14:14 ` Spencer Baugh
2023-11-29 14:54 ` Eli Zaretskii
2023-11-29 15:21 ` Spencer Baugh
2023-11-29 15:52 ` Eli Zaretskii
2023-11-29 19:17 ` Spencer Baugh
2023-11-30 6:12 ` Eli Zaretskii
2023-11-30 12:33 ` Spencer Baugh
2023-11-30 14:10 ` Eli Zaretskii
2023-11-28 23:56 ` Spencer Baugh
2023-11-29 3:33 ` Eli Zaretskii
2023-12-03 17:25 ` Juri Linkov
2023-12-03 17:56 ` Eli Zaretskii
2023-12-06 17:17 ` Juri Linkov
2023-11-28 17:16 ` Juri Linkov
2023-11-28 23:36 ` Turning completion table lambdas into symbols Spencer Baugh
2023-11-28 23:51 ` Dmitry Gutov
2023-11-29 19:26 ` Spencer Baugh
2023-12-01 0:36 ` Dmitry Gutov
2023-11-29 7:18 ` Juri Linkov
2023-11-21 12:54 ` Updating *Completions* as you type John Yates
2023-11-21 17:03 ` Juri Linkov
2023-11-21 22:27 ` John Yates
2023-10-20 6:49 ` Juri Linkov
2023-10-17 15:01 ` sbaugh
2023-10-17 18:20 ` Juri Linkov
2023-10-17 23:37 ` Spencer Baugh
2023-10-17 23:44 ` Spencer Baugh
2023-10-18 6:51 ` Juri Linkov
2023-10-18 12:47 ` Spencer Baugh
2023-10-18 17:28 ` Juri Linkov
2023-10-18 23:32 ` Spencer Baugh
2023-10-16 3:19 ` [External] : " Drew Adams
2023-10-20 9:35 ` zcomplete Philip Kaludercic
2023-10-22 17:28 ` zcomplete Juri Linkov
2023-10-23 5:00 ` zcomplete Protesilaos Stavrou
2023-10-23 6:45 ` zcomplete Juri Linkov
2023-10-13 18:11 ` Updating *Completions* as you type Daniel Semyonov
2023-10-13 18:48 ` Spencer Baugh
2023-10-16 3:16 ` [External] : " Drew Adams
2023-10-16 9:25 ` Philip Kaludercic
2023-10-16 16:03 ` Drew Adams
2023-10-20 7:45 ` Philip Kaludercic
2023-10-20 16:10 ` Drew Adams
2023-10-16 22:55 ` Emanuel Berg
2023-10-17 6:09 ` Emanuel Berg
2023-10-17 0:44 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ier1qcin8db.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
--cc=sbaugh@catern.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).