From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams 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: Mon, 11 Mar 2019 18:10:01 -0700 (PDT) Message-ID: <06a2ade2-3dcf-4bff-9647-a49788b9ca0c@default> 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> <2733dee8-f5a6-396f-228a-84f225d43a1c@yandex.ru> <407232ad-b1ef-7338-5fd2-735da9721562@yandex.ru> <5c032aeb-c2a1-06cd-14bb-121b7116d713@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="255837"; mail-complaints-to="usenet@blaine.gmane.org" Cc: emacs-devel@gnu.org To: Dmitry Gutov , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 12 02:10:26 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 1h3Vvx-0014L2-OK for ged-emacs-devel@m.gmane.org; Tue, 12 Mar 2019 02:10:21 +0100 Original-Received: from localhost ([127.0.0.1]:42918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Vvw-0002ow-IR for ged-emacs-devel@m.gmane.org; Mon, 11 Mar 2019 21:10:20 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3Vvj-0002k8-V2 for emacs-devel@gnu.org; Mon, 11 Mar 2019 21:10:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3Vvi-0004Lm-S1 for emacs-devel@gnu.org; Mon, 11 Mar 2019 21:10:07 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:41422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3Vvi-0004Jy-HY for emacs-devel@gnu.org; Mon, 11 Mar 2019 21:10:06 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2C18xNW108031; Tue, 12 Mar 2019 01:10:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=WPvINSP1n9QBhv8dvI62QG1H3IEuLJu5EFkQz/JaZ4s=; b=20Jnhiq68FcKE6oKiuFZK7GOr/Yatn9b5gpGYesF5Izm0syS3jecuYedtuhy7keypT3E mszpyZOREIMjgtDADkymR+oLAplrjV74RAZ85Bk1XLy0KPtrO2R7bsMQ/0wQY5wDe8bn EFxD2cl8s+Kt75fFZvp02hbC7pTz24Qxhz3oASGvBHyR9FKRTbQrMIjTNR4lv50CuvD9 bRZVo5IzYYtR/1OHSfslu1xkQf/nTzPAN0PMfgAXflETJhtj3rFWB/z+IJFp+8GNoFYv OS989IwNKq8csTQveORBc0ZvJls76J9vDyUUke61OYfxB5BNrwV2d7b19AZdAfv2ZABi 6A== Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2r464r9kvb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Mar 2019 01:10:04 +0000 Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2C1A3A7001067 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Mar 2019 01:10:03 GMT Original-Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2C1A2hv022271; Tue, 12 Mar 2019 01:10:02 GMT In-Reply-To: <5c032aeb-c2a1-06cd-14bb-121b7116d713@yandex.ru> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4810.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9192 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903120006 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 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:234084 Archived-At: > While possible, I think in practice it will require using just one > combined sorting function, instead of passing the list of completions > though several independent sorting functions. Although please feel free > to prove me wrong, because I like the list-of-functions approach. (Caveat: I haven't been following this thread.) Just thought I'd mention how I like to handle a suite of sorting predicates for dealing with things, including completion candidates, that may or may not be comparable to varying degrees or in different ways. When two such cannot be compared using the preferred sorting predicate then the next-preferred predicate is tried, and so on. This page explains the approach: https://www.emacswiki.org/emacs/ApplesAndOranges The basic idea is to allow the use of both ordinary two-valued (true/false) predicates and three-valued (true/false/dunno) predicates, combining the latter in a chain. I use this in Bookmark+, for example, to sort candidates that are bookmarks of different kinds. Different kinds of bookmarks have different things in common - fields that can be compared, for example. They can also have fields that might not be comparable. Depending on the purpose of a given sort, users can want to use different comparison-predicate suites, that is, apply different sets of predicates in different orders of priority. Variable `bmkp-sort-comparer' holds the current comparison suite, which is used for sorting. The variable value is one of the following: * `nil', meaning no sorting; * an ordinary 2-valued predicate; or * a list of 3-valued predicates, optionally followed by a single 2-valued "fallback" predicate. If the first 3-valued predicate in the list can compare the two given bookmarks then it decides. If not then the second 3-valued predicate is tried, and so on. If none of the 3-valued predicates can decide then the fallback, 2-valued predicate decides. It's easy to combine 3-valued predicates They decide, themselves, whether they are applicable to their two given arguments. If not, they just opt out of the deciding. Variable `bkmp-sort-comparer' is described here: https://www.emacswiki.org/emacs/ApplesAndOranges#BmkpSortComparer