unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
To: "João Távora" <joaotavora@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Add user customization fido-completion-styles
Date: Sun, 31 May 2020 17:37:14 -0700	[thread overview]
Message-ID: <F4A31A50-D008-48AF-BDDA-5A37D9AC67BF@schwartzmeyer.com> (raw)
In-Reply-To: <87r1uzn018.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4719 bytes --]

> 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 <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
> 
> 


[-- Attachment #2: Type: text/html, Size: 6743 bytes --]

  parent reply	other threads:[~2020-06-01  0:37 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 [this message]
2020-06-01  4:37     ` Andrew Schwartzmeyer
2020-06-02 11:14       ` João Távora
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=F4A31A50-D008-48AF-BDDA-5A37D9AC67BF@schwartzmeyer.com \
    --to=andrew@schwartzmeyer.com \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    /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).