unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Mendler <mail@daniel-mendler.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [PATCH] `completing-read` - allow history=t, sorting improvements
Date: Mon, 19 Apr 2021 21:36:50 +0200	[thread overview]
Message-ID: <d99e7ed7-dc39-a7fe-d6a3-52fc5c4a9db1@daniel-mendler.de> (raw)
In-Reply-To: <jwvmttut90g.fsf-monnier+emacs@gnu.org>

Hi Stefan,

thank you for pushing. I will adjust the patches which are still 
relevant and resubmit them.

On 4/19/21 9:14 PM, Stefan Monnier wrote:
>> 1. Allow history=t to disable the `completing-read` history
> Thanks, pushed.
> I see that this was really just a bug fix: t already prevented adding
> the result to "the history", there was just one place where the code
> burped when encountering this special "history var".

Yes, also the documentation of `minibuffer-variable` specifies the 
meaning of `t`.

>> * minibuffer.el: Use completion--message consistently for the messages
>> "Incomplete", "Sole completion" and "No completions".
> I don't have a strong opinion on this patch, but I have the impression
> that there might have been a good reason for the difference (i.e. the
> above two cases could be considered "more serious" than those using
> `completion--message`).
> 
> I would personally gladly get rid of `completion-show-inline-help`, so
> I'm not the right person to judge if the above patch is doing the right
> thing or not.

For me the point was mostly to get this clarified, therefore I included 
it here. Note that the messages "Sole completion" and "No completions" 
are already shown at some other places via `completion--done` which uses 
`completion--message` itself, but on a different code path.

>> * lisp/minibuffer.el (completion-all-sorted-completions): When
>> building the hash of history positions drop the prefix as determined
>> by `completion-boundaries`. For file completions drop everything
>> behind the first "/".
> I think I'm fine with this patch, but at that point, this sorting code
> *really* needs to be moved out into a separate function (already the
> previous patch, which I just pushed, was borderline in this respect).
> Also, I think this should come with a test case.

Okay, I agree with splitting up the large function. I will add a test case.

 >> * lisp/minibuffer.el (completion-all-sorted-completions): Sort by
 >> history position, length and alphabetically.
 > I'd expect this will not make a big difference in most cases, but the
 > fact that it results in a more deterministic outcome is very welcome.
 > If you rebase this patch on top of the current minibuffer.el, I'll be
 > happy to push it.

I will send an updated patch.

>>  From 23f306510c4a00b539607b9e57486c7fb72f37bf Mon Sep 17 00:00:00 2001
>> From: Daniel Mendler <mail@daniel-mendler.de>
>> Date: Mon, 19 Apr 2021 13:17:23 +0200
>> Subject: [PATCH 5/6] completion-all-sorted-completions: Sort candidates in a
>>   single pass
> Does this result in a measurable difference?
> The assumptions about maximum size and length aren't ideal, so unless
> there's a clear performance argument, I think we're better off sticking
> to the multiple passes.

>> * lisp/minibuffer.el (completion-all-sorted-completions): Sort by
>> history position, length and alphabetically.
> Here also: have you compared the performance of multiple calls to `sort`
> vs a single call to sort with a more costly comparison function?
> I'd expect the difference to be negligible (and having a separate
> alphabetical sort at the beginning would save us from having to handle
> it twice (i.e. in the two different branches)).

Agree generally. It makes a difference if one uses car-less-than-car, 
since then the comparison function is fast. The difference is less 
pronounced if one includes the lambdas which sort alphabetically (this 
is on non-native, on native the picture could be different).

The important change is really the quadratic one. However in my Vertico 
package (and in other continuously updating UIs), the big bottleneck of 
the UI still is the sorting for many candidates, even when including 
optimizations. Therefore I am using a vertico-sort-threshold there. 
Maybe there are potential improvements on a lower level?

Daniel



  reply	other threads:[~2021-04-19 19:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 18:02 [PATCH] `completing-read` - allow history=t, sorting improvements Daniel Mendler
2021-04-19 19:14 ` Stefan Monnier
2021-04-19 19:36   ` Daniel Mendler [this message]
2021-04-19 20:15     ` Stefan Monnier
2021-04-19 20:44       ` Daniel Mendler
2021-04-19 21:52         ` Stefan Monnier
2021-04-19 22:29           ` Daniel Mendler
2021-04-19 22:55             ` Stefan Monnier
2021-04-19 23:47               ` Daniel Mendler
2021-04-20  1:55                 ` Stefan Monnier

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=d99e7ed7-dc39-a7fe-d6a3-52fc5c4a9db1@daniel-mendler.de \
    --to=mail@daniel-mendler.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).