unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "João Távora" <joaotavora@gmail.com>
To: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
Cc: emacs-devel@gnu.org
Subject: Re: Add user customization fido-completion-styles
Date: Tue, 02 Jun 2020 12:14:18 +0100	[thread overview]
Message-ID: <877dwpn2id.fsf@gmail.com> (raw)
In-Reply-To: <953E1512-6420-4AE8-AF29-15AB151B6344@schwartzmeyer.com> (Andrew Schwartzmeyer's message of "Sun, 31 May 2020 21:37:23 -0700")

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	other threads:[~2020-06-02 11:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-31 21:02 Add user customization fido-completion-styles Andrew Schwartzmeyer
2020-05-31 23:43 ` João Távora
2020-05-31 23:59   ` Dmitry Gutov
2020-06-01  0:21     ` João Távora
2020-06-01  0:37   ` Andrew Schwartzmeyer
2020-06-01  4:37     ` Andrew Schwartzmeyer
2020-06-02 11:14       ` João Távora [this message]
2020-06-02 16:14         ` Drew Adams
2020-06-02 17:51           ` João Távora
2020-06-02 18:11             ` Eli Zaretskii
2020-06-02 18:24               ` João Távora
2020-06-02 18:35                 ` Eli Zaretskii
2020-06-02 19:11                   ` João Távora
2020-06-02 19:25                     ` Eli Zaretskii
2020-06-02 20:00                       ` João Távora
2020-06-02 20:51             ` Drew Adams
2020-06-02 15:40   ` Tassilo Horn
2020-06-02 15:55     ` João Távora
2020-06-02 16:47       ` Tassilo Horn
2020-06-02 17:03         ` João Távora
2020-06-02 18:05           ` Tassilo Horn
2020-06-02 17:10         ` Tassilo Horn
2020-06-02 19:28           ` João Távora

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=877dwpn2id.fsf@gmail.com \
    --to=joaotavora@gmail.com \
    --cc=andrew@schwartzmeyer.com \
    --cc=emacs-devel@gnu.org \
    /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).