From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier 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: Tue, 12 Feb 2019 08:19:16 -0500 Message-ID: References: <20190202232827.27331.87300@vcs0.savannah.gnu.org> <20190202232828.4AE452159A@vcs0.savannah.gnu.org> <556bfb2e-4720-c86a-c964-f057b50041b6@yandex.ru> <87va1xw7ms.fsf@gmail.com> <212f7cc9-c0c6-bcf8-f200-ea74db261dc3@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="154521"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 12 14:33:35 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 1gtYBq-000e39-Bi for ged-emacs-devel@m.gmane.org; Tue, 12 Feb 2019 14:33:34 +0100 Original-Received: from localhost ([127.0.0.1]:39616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtYBp-0006qP-D2 for ged-emacs-devel@m.gmane.org; Tue, 12 Feb 2019 08:33:33 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtY7N-0004Ln-Qt for emacs-devel@gnu.org; Tue, 12 Feb 2019 08:29:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtXy9-0002tH-I2 for emacs-devel@gnu.org; Tue, 12 Feb 2019 08:19:26 -0500 Original-Received: from [195.159.176.226] (port=45348 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtXy9-0002s3-AK for emacs-devel@gnu.org; Tue, 12 Feb 2019 08:19:25 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1gtXy7-000NVi-4e for emacs-devel@gnu.org; Tue, 12 Feb 2019 14:19:23 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:P3Y82R7LQgO3io8oKpUJpph0xXI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 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:233252 Archived-At: > See completion--metadata and completion-extra-properties. But a completion style like `flex` can't affect either of those. And I expect some people will want to put in their `completion-styles`, so `flex` should work well for all/most completion tables and all/most completion-at-point-functions (and calls to completing-read). > I dunno, sorting takes CPU time anyways. Not sure a combination of several > sorting functions will frequently give a better result than just one > of them. I think I agree here: the stability of the `flex` sort is likely to make little difference in practice (more specifically, the sets of matches which share the same flex-score will be sufficiently numerous and small that the sorting within them is not significant). > But then, if you enable company-sort-by-occurrence via company-transformers, > the completion style's sorting won't be visible anymore anyway. I think this is OK: the front-end can indeed override the sorting chosen by the completion-style and the completion-table. If the result is poor, it's the front-end's problem and it is in a position to fix it. > It's a question whether any other sorting approaches end up being helpful, > but maybe some hybrid functions will work, where both occurrences and flex > score are taken into account. Not sure how that can be done in a modular way: how can we specify an API where `flex` can provide its scores, `sort-by-occurrence` can specify its scores, they don't know about each other, and yet the two sets of scores get mixed in a useful way? Stefan