emacs-devel
[Top][All Lists]
Advanced

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

Re: Sorting command completions by recency


From: Juri Linkov
Subject: Re: Sorting command completions by recency
Date: Wed, 17 Feb 2021 22:09:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> This code puts the recent commands at the top as well,
>>> but probably it needs to be opt-in:
>> Makes sense to me, and, yes.
>
> FWIW, the minibuffer.el code already uses this kind of sorting for the
> list of completions used in things like `icomplete` and
> `completion-cycle-threshold`.

I stole code from `completion-all-sorted-completions' used by `icomplete`,
but see no way to call it directly.

> For *Completions* the sort was kept alphabetical so far because that's
> also useful (for example in the case of M-x completion, it makes it
> easier to skip over blocs of commands sharing the same prefix).
>
> So, while I think it can be useful to sort by some kind of "guessed
> usefulness" such as presence in the history, I don't think this should
> be forced by the completion table of commands.

Maybe a new option should allow switching the sorting order.
Perhaps, it should have a form of an alist:

  '(("alphabetical" . identity)
    ("by recency" . (lambda (commands)
                      (if (minibufferp)
                          ;; Prefer recently used completions and put the 
default,
                          ;; if it exists, on top.
                          (let ((hist (symbol-value 
minibuffer-history-variable)))
                            (sort commands
  ...



reply via email to

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