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: [Emacs-diffs] scratch/new-flex-completion-style 2c75775 2/2: Score, sort and annotate flex-style completions according to match tightness Date: Wed, 06 Feb 2019 10:09:31 +0000 Message-ID: <87va1xw7ms.fsf@gmail.com> References: <20190202232827.27331.87300@vcs0.savannah.gnu.org> <20190202232828.4AE452159A@vcs0.savannah.gnu.org> <556bfb2e-4720-c86a-c964-f057b50041b6@yandex.ru> 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="114459"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 06 11:09:49 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 1grK9N-000TfG-GY for ged-emacs-devel@m.gmane.org; Wed, 06 Feb 2019 11:09:49 +0100 Original-Received: from localhost ([127.0.0.1]:47899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grK9M-0003Zq-EW for ged-emacs-devel@m.gmane.org; Wed, 06 Feb 2019 05:09:48 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1grK9F-0003ZY-Sv for emacs-devel@gnu.org; Wed, 06 Feb 2019 05:09:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1grK9E-0004pX-9j for emacs-devel@gnu.org; Wed, 06 Feb 2019 05:09:41 -0500 Original-Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:52393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1grK9E-0004ok-3v for emacs-devel@gnu.org; Wed, 06 Feb 2019 05:09:40 -0500 Original-Received: by mail-wm1-x32a.google.com with SMTP id m1so1814771wml.2 for ; Wed, 06 Feb 2019 02:09:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-transfer-encoding; bh=ks4KJ8n5UyE0RKkng5QPl1ExED/yIJb5XLvOT7bbgbM=; b=nSToScahegcPlypROkD9MwbHO6Rb1Jb/etg38A0eGD9ebtKOVSVMEg9djJAElQeWws Q5yte6yMfFE/gDG4Vp7sGYODPoEbRCn29zg1E3neVh52NvZp/e2eVYMXsSVFqOqVv5eI F2gt0WKrTGt5g/PsiJxMfbpN72HvCHNqUFpi2/YCNsOWTTx2bMN5w+zLBQCpQKIv1YKU skW4fBZ4FnkMaIcG1l3n6NPPxGXd/pvZInN9KAUWYDolp/RzlHx27GOV3JBJpSFa8LYO AkOqFVnJqhhpDjcq2y6eL7+6FovY2xs4BdyLvEfMjFj84a/ncSZh8I7d7i+/RErHredu Cerw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=ks4KJ8n5UyE0RKkng5QPl1ExED/yIJb5XLvOT7bbgbM=; b=Y6lovPZbh7DNKpnX8+/bT2RGvGyqPKdTRh8P/jAdwmiY4AFo3Z93tdtgeLgVSHTmNv O/qlTXrQt6J12NlJqycWY0UFeTyONYZmNWn76cIXV1lsB0J3q10o9hMlGMONVPlnclyd dhd67IpyIieEammDb0AWHkAeRRDpfgwqaLXP7zcq43jwqVjKPbA4dB+9rCVbI/j/qaU3 x25dhKC8ZOHuCKebRo9huGR8XtKHMkhJujP2r5IREXpu37MPgqaI3CulfpcH+zPEdO1C hanuTxNbEke4AeGBjKyonJrzU2J0EtTrgrBS5Kr3WivgnOGbbnuhV/IE1KZsKfFE8xtd 0OMQ== X-Gm-Message-State: AHQUAuZHneBZH2jGRp+S0Zz62RPj13UL9VrCHXfJLD4Nx+nbe1jGVROC I/MdakxgNQdr79aiPxdzHltbomxu X-Google-Smtp-Source: AHgI3IattL/qzVLCZl9h9IiD4uuIh8ubHn9Mqt/02NzVPvYpRnD+RTv+2ueDxfFl4TDANJpQDUdlTw== X-Received: by 2002:a7b:c405:: with SMTP id k5mr2463687wmi.2.1549447774540; Wed, 06 Feb 2019 02:09:34 -0800 (PST) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id h62sm19099940wmf.11.2019.02.06.02.09.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 02:09:33 -0800 (PST) In-Reply-To: <556bfb2e-4720-c86a-c964-f057b50041b6@yandex.ru> (Dmitry Gutov's message of "Wed, 6 Feb 2019 06:11:25 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a 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:233038 Archived-At: Dmitry Gutov writes: > On 03.02.2019 02:28, Jo=EF=BF=BDo T=EF=BF=BDvora wrote: >> + ;; Sort again in case the completion style has propertized >> + ;; completions with a 'completion-style-sort-order. >> + (setq completions >> + (sort completions >> + (lambda (a b) >> + (let ((va (get-text-property 0 'completion-styl= e-sort-order a)) >> + (vb (get-text-property 0 'completion-styl= e-sort-order b))) > > Shouldn't we be concerned that this overrides display-sort-function > returned by the completion table? Perhaps. But it only does so when the completion style explicitly wanted it. And even so, the sort order should be stable, i.e. if the completion style puts numerically equal values in two completions, they should retain the backend's order. And, obviously, it it doesn't put any values in that property, then the backend's order is also retained. In my experience, at least for the "flex" (also called "scatter", by the way) completion style, the frontend's sorting takes precedence > Maybe some sort of customizable mechanism is in order, similar to > completion-styles. It is already customizable: you don't have to use "flex" completion style. Let's first try it out and then see if we need _more_ customization. > Or more simply, we just leave it to the completion table's author to > set display-sort-function to a special value that makes use of these > properties. It's not like setting it to a different value is going to > make sense in this case. > >> + ;; Annotate completions with <...> >> + ;; the completion style annotation. > > Is this for debugging? At the moment, yes mostly. But it could not be. In SLY, I give users an indication of how the scoring algorithm is working. See it in action: https://raw.githubusercontent.com/joaotavora/sly/master/doc/animations/comp= any-flex-completion.gif Jo=C3=A3o