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: Andrew Schwartzmeyer
Subject: Re: Add user customization fido-completion-styles
Date: Sun, 31 May 2020 17:37:14 -0700

Actually, it is, just not with custom.  These two lines should do the trick:

 (add-hook 'icomplete-minibuffer-setup-hook 'my-flex-styles)
 (defun my-flex-styles () (setq-local completion-styles '(initials flex)))

Ah! Thank you so much! I didn’t realize the ordering would work out such that this would override the setq-local in icomplete--fido-mode-setup.

Or just use a lambda, which is even shorter.  I'd like to avoid a
duplicate version of completion-styles customization vars. 

I agree, it felt weird writing it, but I didn’t know the above trick. So thanks for that! I think we can not patch this until we come up with a cohesive customization (and documentation!) story.

Or we could even think about
making two styles merge "sooner", since currently we skip to the next
one only once the previous no longer matches anything.

This seems like it would be really nice. There are a lot of good (and bad) filtering algorithms out there. Flx, Orderless, Prescient are all things to learn from. 

Also, "orderless" looks cool.  Is it faster than flex?

So far it seems very fast, but I haven’t used it long. Prescient is also fast, but ironically this issue on GitHub https://github.com/raxod502/prescient.el/issues/58 wants to use Orderless in Prescient to make it even faster.

Honestly, the strangest thing in my experience so far is that M-x with “flex” style doesn’t start with my historical items, just seemingly random (but static) commands. It seems like switching it to “initials flex” already pulls in my history as default sort, but I need to investigate further and be sure it isn’t something else. I think an integral part to any completion framework is for the initial suggestions to follow frequency/recency, to provide good context with no input, and allow immediate selection of frequently/recently used commands (buffers, files…).

Thanks,

Andy

On May 31, 2020, at 4:43 PM, João Távora <joaotavora@gmail.com> wrote:

Andrew Schwartzmeyer <andrew@schwartzmeyer.com> writes:

Hi,

Users of fido-mode (like me) may want to customize the completion style it uses, so add a variable to allow them to
do so.

For instance, I really like using the “initials” style so “vlm”
quickly completes visual-line-mode, and then falling back to
flex. There are also neat packages like orderless
(https://github.com/oantolin/orderless) which add a new
completion-style, which folks may want to plug-in and use. Anyway, it
seems like it ought to be customizable.

Actually, it is, just not with custom.  These two lines should do the trick:

 (add-hook 'icomplete-minibuffer-setup-hook 'my-flex-styles)
 (defun my-flex-styles () (setq-local completion-styles '(initials flex)))

Or just use a lambda, which is even shorter.  I'd like to avoid a
duplicate version of completion-styles customization vars.  

I am however, receptive to customizing the default styles used in fido
mode.  We could come up with a "smarter" flex that values matches
following "-" a bit more.  Or maybe '(initials flex) is a good fit
already, I'll play around a bit with it.  Or we could even think about
making two styles merge "sooner", since currently we skip to the next
one only once the previous no longer matches anything.  Maybe that could
be changed, i.e. adding the matches of the secondary style once the
first one only has two or three matches.

P.S. I wish “flex” were a bit faster. On my circa 2012 MacBook, M-x is
noticeably slow with “flex” for commands.

Yes, flex isn't blazing fast, particularly with short patterns.  The
solution is (likely) to port parts of it in C, which isn't particularly
hard, just a bit tedious.

However, the slowness of flex shouldn't affect the ability to type fast
after M-x, since very new character typed should interrupt the lenghty
calculation.  Let me know if that is somehow not the case with your
completion experience.

Also, I don’t know what “:version” to put on the defcustom, and the
docs could be improved a bit.

That would depend on what version you intend the patch to target.  Since
fido-mode is a new thing in Emacs 27.1, it is my understanding (from
earlier feedback of Eli) that we can to push to emacs-27, since we
won't, by definition, introduce regressions.  But I would refrain from
doing so this late in the game, unless we are fixing severe
misbehaviour.

Also, "orderless" looks cool.  Is it faster than flex?

João




reply via email to

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