emacs-devel
[Top][All Lists]
Advanced

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

Re: Add user customization fido-completion-styles


From: João Távora
Subject: Re: Add user customization fido-completion-styles
Date: Tue, 02 Jun 2020 12:14:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux)

Andrew Schwartzmeyer <andrew@schwartzmeyer.com> writes:

> With just “flex” as the completion style, for some reason M-x with no
> input (from an emacs -q) presents the following candidates as the
> first:
>
> icomplete-fido-delete-char
> enable-theme
> url-setup-privacy-info
> dired-at-point
> tab-bar-select-tab

With no inputs to the flex completion style, it matches every candidate.

> I can’t see a pattern in these. If I then call a command, I’d
> want/expect (from experience with other completion frameworks) the
> next use of M-x to show it as the first candidate, but it doesn’t.

fido-mode (and I believe icomplete-mode, whereupon fido-mode is based)
do this for minibuffer-reading commands that have a "default", i.e. a
result that is returned immediately if the user "forces" the completion
with no input, regardless of whether the candidates are showing or not.

M-x, which maps to execute-extended-command, is not one of those
commands.

Regarding the pattern, there is none.  I believe that's the order of all
symbols as returned by the all-completions when called to return a list
of everything that is a command.  It doesn't waste any time sorting.

> Now if I use the aforementioned Orderless package and the minibuffer
> hook to use it as the completion style in fido, somehow it does some
> magic such that M-x (which is still bound to execute-extended-command)
> now has some history sorting! (Working for switch-to-buffer too. :)

You could do some sorting, but that is a a O(NlogN) operation (I think,
may be wrong, N is the number of commands times the number of elements
in the history).  It doesn't make much sense to invest in this sorting
because it is only useful if all the candidates have the same flex
score.  Which they do in the beginning situation, but that quickly
changes as the user inputs a pattern.

Alternatively, a dirty hack might be to exceptionally use the history
list itself -- and not all the candidates -- when the pattern is
empty. That'd probably fill in the space and wouldn't be functionally
wrong.

> So yeah, I’m off to look through Orderless to see what magic it does
> that sorts the candidates for M-x (without having do anything like
> what smex does!).

I haven't looked at Orderless yet.  For the empty pattern case, it might
be taking the shortcut I suggested.

But for non-empty patterns iss it doing what I think it is doing?  Will
typing the three letter pattern "foo" match "foobarbaz" "fabrobazo" and
"orzobafab"?  In which order will they be returned?

João







reply via email to

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