From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: new-flex-completion-style Date: Wed, 13 Feb 2019 11:20:42 +0000 Message-ID: References: <20190202232827.27331.87300@vcs0.savannah.gnu.org> <20190202232828.4AE452159A@vcs0.savannah.gnu.org> <87lg2mynrg.fsf@gmail.com> <87wom5amkd.fsf@telefonica.net> <878sykzmrs.fsf@gmail.com> <87sgwsa5wk.fsf@telefonica.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="175348"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel To: =?UTF-8?Q?=C3=93scar_Fuentes?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 13 12:21:43 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtsbh-000jO7-SU for ged-emacs-devel@m.gmane.org; Wed, 13 Feb 2019 12:21:38 +0100 Original-Received: from localhost ([127.0.0.1]:55090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtsbg-0003t1-Rd for ged-emacs-devel@m.gmane.org; Wed, 13 Feb 2019 06:21:36 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtsb4-0003sj-4s for emacs-devel@gnu.org; Wed, 13 Feb 2019 06:20:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtsb2-0003fw-Da for emacs-devel@gnu.org; Wed, 13 Feb 2019 06:20:58 -0500 Original-Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:44480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gtsb2-0003di-8T for emacs-devel@gnu.org; Wed, 13 Feb 2019 06:20:56 -0500 Original-Received: by mail-qt1-x831.google.com with SMTP id n32so2029942qte.11 for ; Wed, 13 Feb 2019 03:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=43X1zoORnaBLTPuaZgcOcyXOaCLcnX6IX6IZfIMH32I=; b=IYy3+cMVhN9MVfp1PtSFHg3JxbqTu0MPoD3/PuFVrXnAlKqPrxnzpKAU51PBwt3Ohf rLL0RfebM7mSYcI/qce4M28DwhKb7pS6qkBos+lzqfU1mXcBGVEDTO5hXSOmS7xF+CC0 3hXCtKcxE1hnry+qkz+Mj8hVNieDoGm84VOam1GjniyqxpPi0FaUouhof854JZADGvPE AAy6sl6k5vUPMs/g1C5h2XiAQfiO673ZutYM3Mdd8XW4ZKUK8+BMBSoGQt1rnGsrgfOG AR3RnOTaNQrwmzVWXcVx70I5LPLvSwKZpFBmt1mXdl+ljAaKe38nOi2j9AAIJiz7XAV5 9dFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=43X1zoORnaBLTPuaZgcOcyXOaCLcnX6IX6IZfIMH32I=; b=WJZiXCc5468aujI385kftJzI/FOfL7AWgMy4FMMfRGOQJh1Kb3zcYSk/TrQ2A+ULDg 7y8obbgOusPcJwRImvm/Mz4Cpcxu7PuNdBjz6MbqkEGzV7STSbRXBmBVfnEtI/1r6XMp vstJmghURvh+8rSUo+/B2a//DoKu+f/yj8H7nPLoYVm6Bx7NEkVeklnzMvhpj1kjt/vy Tb1gZxBHFj9IJ1hmU7uSy0vUZBOONhY1Xt37MKiUTTNwqzx6NwAnaLhiJ/FnJ2jLi0/k brh6dSOtaTVzarTPrADlteYcNJu1mlbMQLI4SXoVQIM8vta32D3Z22WueZlbmvuzRHHs FBuQ== X-Gm-Message-State: AHQUAuaetbTU48/NjqB+aPhKMLAzOWBejZ7UJ3EQygTOv6kFUhyxuL7q NhN4HTG/G2YCWjGF8TCGuei/j0lVFCs2PWWx2Fk= X-Google-Smtp-Source: AHgI3Ia+qVHp/6xvMETEKjkSBRvzucOLbMSwAVsf/bAhHN+2f2i3DXn1K9CU41irEFmATA5X1XMeYSQGn0UDF9FQ5Cg= X-Received: by 2002:ac8:160d:: with SMTP id p13mr4755qtj.20.1550056854588; Wed, 13 Feb 2019 03:20:54 -0800 (PST) In-Reply-To: <87sgwsa5wk.fsf@telefonica.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::831 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:233269 Archived-At: On Wed, Feb 13, 2019 at 12:29 AM =C3=93scar Fuentes wrote: > > Jo=C3=A3o T=C3=A1vora writes: > > > =C3=93scar Fuentes writes: > > > >> Jo=C3=A3o T=C3=A1vora writes: > > > >> Do you know flx [1] ? Would it be possible to implement it on top of > >> your work by providing a score function and/or a sort function? > >> > >> 1. https://github.com/lewang/flx > > > > I remember looking at this a long time ago. It looked interesting, but > > is almost certainly more complex/featureful than my implementation, > > which is reasonably simple and tries to play along with the Emacs's > > completion style/table/UI framework, something which is still relativel= y > > fluid (as you can read in this thread). So I'd rather take it slowly > > before adding new features. > > > > But I don't know what features you are looking for exactly, can you be > > specific? > > Basically, flx takes an input string and a list of candidates, assigns > an score to each candidate and returns a filtered list of candidates > sorted by the score. > > This seems the same you described on your commit message. Indeed. I just had a look again. The engine itself it around 360 loc which should be 5-10x times longer than what I'm proposing. The scoring itself seems quite more intricate, with special cases and customization for word separators, a "heatmap", camel-case exceptions, and probably some I haven't understood. My implementation, on the other hand, takes advantage of the existing emacs PCM mechanism to generate a ".*.*.*" regex to do the matching. Importantly, it's agnostic to the type of thing represented by the string being matched. Scoring is hooked onto the existing logic for char highlighting. The formula is a simple ad-hoc thing that I invented and has been working OK. It's quotient of a running sum of a function of distances that are known when highlighting chars. Basically, it values "tighter" matches in short strings, so matching "bar" to "obarb" scores higher than matching it to "foobarbaz" which scores higher than matching it to "booazzraa". "Working OK" here means that the thing I meant is almost always in the first three or four candidates. Perhaps you should try it and confirm this, or show me cases where it isn't. But you didn't answer my question: what specific features of flx are you looking for? I'd be happy to implement them if I have the time, but I have to understand what they are. Jo=C3=A3o