From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Juri Linkov <juri@linkov.net>
Newsgroups: gmane.emacs.devel
Subject: Re: Updating *Completions* as you type
Date: Mon, 20 Nov 2023 19:47:12 +0200
Organization: LINKOV.NET
Message-ID: <86v89ws5t3.fsf@mail.linkov.net>
References: <87bkd3z9bi.fsf@catern.com> <86cyxjyr1y.fsf@mail.linkov.net>
 <ier34ye4a3x.fsf@janestreet.com> <86r0lxm7um.fsf@mail.linkov.net>
 <87sf6dx954.fsf@catern.com> <87ttqpwea9.fsf@catern.com>
 <86wmvlw178.fsf@mail.linkov.net> <87bkcwx3ft.fsf@catern.com>
 <86y1g076vh.fsf@mail.linkov.net> <87sf68unh1.fsf@catern.com>
 <86zg0fu99i.fsf@mail.linkov.net> <875y33v73h.fsf@catern.com>
 <87y1fztke8.fsf@catern.com> <86r0lrw17x.fsf@mail.linkov.net>
 <87il5xlf9b.fsf@catern.com> <86y1esuajx.fsf@mail.linkov.net>
 <ierleas4fcr.fsf@janestreet.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="9285"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
Cc: sbaugh@catern.com,  emacs-devel@gnu.org
To: Spencer Baugh <sbaugh@janestreet.com>
Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Nov 20 18:58:17 2023
Return-path: <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>
Envelope-to: ged-emacs-devel@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org>)
	id 1r58XI-0002Cx-Q3
	for ged-emacs-devel@m.gmane-mx.org; Mon, 20 Nov 2023 18:58:16 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-devel-bounces@gnu.org>)
	id 1r58WO-0005fh-Ik; Mon, 20 Nov 2023 12:57:20 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@linkov.net>) id 1r58WL-0005er-42
 for emacs-devel@gnu.org; Mon, 20 Nov 2023 12:57:18 -0500
Original-Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@linkov.net>) id 1r58WI-0000p4-Ma
 for emacs-devel@gnu.org; Mon, 20 Nov 2023 12:57:16 -0500
Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 7D711FF80E;
 Mon, 20 Nov 2023 17:57:09 +0000 (UTC)
In-Reply-To: <ierleas4fcr.fsf@janestreet.com> (Spencer Baugh's message of
 "Mon, 20 Nov 2023 10:24:52 -0500")
X-GND-Sasl: juri@linkov.net
Received-SPF: pass client-ip=2001:4b98:dc4:8::229;
 envelope-from=juri@linkov.net; helo=relay9-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-devel@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org
Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.devel:313064
Archived-At: <http://permalink.gmane.org/gmane.emacs.devel/313064>

> For buffers, for example, sorting by the buffer-list can be done by just
> setting display-sort-function to identity, but we probably shouldn't
> expose that fact to the user.  (We could expose a generic "sort by
> defaults" but that would be less efficient.)

It should be fine to use 'identity' as a value when the Customization UI
will show a more meaningful tag like "Unsorted".

> The sorting style might even require the sorting option to actually
> change the completion table's behavior.  File name completion could be
> sorted by mtime, for example, by having the completion table include
> mtime as a text property when read-file-name-sort=mtime, and then
> setting display-sort-function to something which reads that property.  I
> think that can only work if we have separate sorting options.

Also a separate option might be needed when a completion table
supports a non-standard sorting order such as
'mule--ucs-names-sort-by-code' when 'read-char-by-name-sort'
is customized to 'code'.  But the users still should have freedom
to override all metadata: display-sort-function, affixation-function,
group-function, etc.

>>   (setopt completion-category-overrides
>>     '((buffer (display-sort-function . minibuffer-sort-by-history))
>>       (project-file (display-sort-function . minibuffer-sort-by-history))
>>
>> And default values could be specified in completion-category-defaults.
>
> I think the default values would be part of the completion table itself;
> a completion table can just set display-sort-function itself, it doesn't
> need completion-category-defaults to do that.

OTOH, the completion table needs only to return its category in metadata.
Otherwise every completion table of the same category would need to
duplicate display-sort-function in its completing-read.

> Maybe we should decide what things are supposed to be configured by
> category and what things are supposed to be configured by the table
> itself.  Because in theory we could allow setting completion-styles and
> completion-cycle-threshold with completion table metadata, and I'm not
> sure why we didn't do it that way - it could even be nice to have a
> completion style which is specific to an individual completion table.

I guess when an individual completion table needs to use metadata
slightly different from other similar cases then it should provide
a different category/subcategory.