From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Andrew Schwartzmeyer Newsgroups: gmane.emacs.devel Subject: Re: Add user customization fido-completion-styles Date: Sun, 31 May 2020 17:37:14 -0700 Message-ID: References: <87r1uzn018.fsf@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_A556BCE1-67C1-4358-89BC-D0EDE527D366" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="39900"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jun 01 02:37:56 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jfYSi-000AGn-AE for ged-emacs-devel@m.gmane-mx.org; Mon, 01 Jun 2020 02:37:56 +0200 Original-Received: from localhost ([::1]:49696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfYSh-0003B8-CM for ged-emacs-devel@m.gmane-mx.org; Sun, 31 May 2020 20:37:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfYSC-0002cf-SK for emacs-devel@gnu.org; Sun, 31 May 2020 20:37:24 -0400 Original-Received: from mout02.posteo.de ([185.67.36.142]:58139) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfYSA-0007HK-GQ for emacs-devel@gnu.org; Sun, 31 May 2020 20:37:24 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id D42182400FB for ; Mon, 1 Jun 2020 02:37:19 +0200 (CEST) Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 49Zx8F5lTGz9rxL; Mon, 1 Jun 2020 02:37:17 +0200 (CEST) In-Reply-To: <87r1uzn018.fsf@gmail.com> X-Mailer: Apple Mail (2.3608.80.23.2.2) Received-SPF: pass client-ip=185.67.36.142; envelope-from=andrew@schwartzmeyer.com; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 20:37:20 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251705 Archived-At: --Apple-Mail=_A556BCE1-67C1-4358-89BC-D0EDE527D366 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Actually, it is, just not with custom. These two lines should do the = trick: >=20 > (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=E2=80=99t 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.=20 I agree, it felt weird writing it, but I didn=E2=80=99t 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.=20 > Also, "orderless" looks cool. Is it faster than flex? So far it seems very fast, but I haven=E2=80=99t 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 = =E2=80=9Cflex=E2=80=9D style doesn=E2=80=99t start with my historical = items, just seemingly random (but static) commands. It seems like = switching it to =E2=80=9Cinitials flex=E2=80=9D already pulls in my = history as default sort, but I need to investigate further and be sure = it isn=E2=80=99t 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=E2=80=A6). Thanks, Andy > On May 31, 2020, at 4:43 PM, Jo=C3=A3o T=C3=A1vora = wrote: >=20 > Andrew Schwartzmeyer writes: >=20 >> Hi, >>=20 >> 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. >>=20 >> For instance, I really like using the =E2=80=9Cinitials=E2=80=9D = style so =E2=80=9Cvlm=E2=80=9D >> 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. >=20 > Actually, it is, just not with custom. These two lines should do the = trick: >=20 > (add-hook 'icomplete-minibuffer-setup-hook 'my-flex-styles) > (defun my-flex-styles () (setq-local completion-styles '(initials = flex))) >=20 > Or just use a lambda, which is even shorter. I'd like to avoid a > duplicate version of completion-styles customization vars. =20 >=20 > 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. >=20 >> P.S. I wish =E2=80=9Cflex=E2=80=9D were a bit faster. On my circa = 2012 MacBook, M-x is >> noticeably slow with =E2=80=9Cflex=E2=80=9D for commands. >=20 > 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. >=20 > 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. >=20 >> Also, I don=E2=80=99t know what =E2=80=9C:version=E2=80=9D to put on = the defcustom, and the >> docs could be improved a bit. >=20 > 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. >=20 > Also, "orderless" looks cool. Is it faster than flex? >=20 > Jo=C3=A3o >=20 >=20 --Apple-Mail=_A556BCE1-67C1-4358-89BC-D0EDE527D366 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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=E2=80=99t 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=E2=80=99t 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=E2=80=99t used it long. Prescient is also fast, but ironically = this issue on GitHub https://github.com/raxod502/prescient.el/issues/58 wan= ts to use Orderless in Prescient to make it even faster.

Honestly, the strangest = thing in my experience so far is that M-x with =E2=80=9Cflex=E2=80=9D = style doesn=E2=80=99t start with my historical items, just seemingly = random (but static) commands. It seems like switching it to =E2=80=9Ciniti= als flex=E2=80=9D already pulls in my history as default sort, but I = need to investigate further and be sure it isn=E2=80=99t 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=E2=80=A6).

Thanks,

Andy

On May = 31, 2020, at 4:43 PM, Jo=C3=A3o T=C3=A1vora <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 =E2=80=9Cinitials=E2=80=9D style so =E2=80=9Cvlm=E2=80=9Dquickly 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 =E2=80=9Cflex=E2=80=9D were a bit faster. On my = circa 2012 MacBook, M-x is
noticeably slow with =E2=80=9Cfle= x=E2=80=9D 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=E2=80=99t know what =E2=80=9C:version=E2=80=9D 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=C3=A3o



= --Apple-Mail=_A556BCE1-67C1-4358-89BC-D0EDE527D366--