From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: handling many matches [was: [ELPA] New package: transient] Date: Fri, 1 May 2020 10:20:25 -0700 (PDT) Message-ID: <119c0543-387d-4fad-b7fe-b4e07a7be4f8@default> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="49719"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jonas Bernoulli , Emacs developers , Philippe Vaucher , Adam Porter , Kyle Meyer , Eli Zaretskii To: Dmitry Gutov , Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 01 19:22:22 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 1jUZMj-000CmA-Ou for ged-emacs-devel@m.gmane-mx.org; Fri, 01 May 2020 19:22:21 +0200 Original-Received: from localhost ([::1]:51316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jUZMi-0003TN-QE for ged-emacs-devel@m.gmane-mx.org; Fri, 01 May 2020 13:22:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUZLr-0002JN-Hd for emacs-devel@gnu.org; Fri, 01 May 2020 13:21:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jUZLq-0005nS-GQ for emacs-devel@gnu.org; Fri, 01 May 2020 13:21:27 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:47662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jUZL8-0002yu-Ct; Fri, 01 May 2020 13:20:42 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 041HJ2cK087804; Fri, 1 May 2020 17:20:32 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 : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=5rS9QHugtVaoJxyUX+6wMyeTTejT59vgjyxS1MyBUJU=; b=fCV9r1cuEAzoa1+/BcuwCza74bfRU32Sr7JXwjAJKxXUmrirAx/d3EoDDtEw3DtvRces /8JgqdoBwxKrS45NG5uMzboMXHYWkuEfHzwtUAkF0U9VFyfvmPxT0dGoZXpTBcSnRAkK Ny1DkESSHfuQuiXetnf0+hyEdnTdc6vJL5soZHU6ak890OnIE7/wlxmMalYBQAe588ie 4dnsRbE4p+RRtgNmnQe50v6lzmHGjaSiAy18L6AzgDzjjjDbUT8aQwqR0IGdjj7v2Peu EfhxOROgOYNAikLJ6XWw4/8E+iSZK+oDhkfGDxT0AloCEuTU4tE14rUUUgNDr3ICuzEP IQ== Original-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30r7f3k7ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 May 2020 17:20:32 +0000 Original-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 041HCKFS172486; Fri, 1 May 2020 17:20:31 GMT Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 30rbr5psgk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 May 2020 17:20:31 +0000 Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 041HKQQe016225; Fri, 1 May 2020 17:20:26 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4993.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9608 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005010132 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9608 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005010132 Received-SPF: pass client-ip=141.146.126.78; envelope-from=drew.adams@oracle.com; helo=aserp2120.oracle.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/01 13:20:39 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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:248319 Archived-At: > > But then you have the reverse problem: after typing `file-name` in > > fido-mode you get too many false-positive for functions which aren't > > "manipulating file names" but merely return a file-name. >=20 > That's a fair point, but still the discoverability is not too bad. > Given weighted sorting, the relevant functions are mostly at the top, > see the screenshot. >=20 > Although we might want to look into why backup-file-name-p is sorted > before file-name-quoted-p. A comment on the general situation here, hoping it helps - The problem of getting many matches is a general one, and one that's more prevalent when matching methods get extended or combined. Just extending from prefix to substring matching can increase the number of matches greatly. Fuzzy and regexp matching can both add to the problem and sometimes help reduce it. (The "problem" is also a helpful feature, and an opportunity, of course.) Icicles has had to deal with this inherent problem and opportunity longer than other completion frameworks, and a few of its features can really help to tame it. I mention them here because, regardless of how they might be implemented or presented to users (the UI), I think similar features could help Emacs. 1. Progressive matching, i.e., narrowing the set of candidates by matching another pattern. (Rinse and repeat.) Matching multiple simple patterns is both much easier and more flexible/powerful than trying to come up with a single complex pattern (or fewer but more complex patterns). 2. Pruning, by excluding matches. This builds on #1. You add another pattern to match (#1), then hit a key to subtract the resulting set of matches from the previous set. In your screenshot, for example, if you know you're not interested in the `tramp' matches, you just use #1 to add matching `tramp' as an additional requirement, then hit a key (`C-~' in Icicles) to prune those matches. Similarly for other, easy to recognize blocks of matches. It's very quick to filter matches this way, and it would be impossible, in the general case, to get the same result by any particular completion style/method. Only you know what it makes sense to prune, in any given context. At each step of additional matching (i.e. #1) you can hit a key (Icicles uses `C-g') to annul that match requirement. For example, after you match `tramp', if you hit `C-g' then the matches return to including `tramp'. (If you see that you want to keep some but not all of the `tramp' matches then you can just use #1 again to narrow further. 3. On-demand help on individual candidates. Be able to hit a help key to get a short or long description for a given candidate. This of course requires some way to indicate/pick a single candidate just for help. In Icicles there are several ways to do this, including (a) cycling among them and (b) #1 above, followed by a help key, followed by `C-g' - i.e., narrow to a single candidate, show its description, then widen back. This feature is not a way to add/subtract multiple matches all at once. It's more of a tell-me-more, to help you decide about further matching. In Icicles there are many more ways to manipulate a set of matches, to tame the plethora problem. But I wanted to mention those 3 - particularly the first 2. ___ Now a word about sorting in this context, since you mention it. Sorting is important for many reasons, especially, but not only, in a context where you can (or must) access candidates in order, e.g., cycle among them. You mention orders based on candidate scoring: "Given weighted sorting, the relevant functions are mostly at the top" That can be helpful, but I think it's often overrated. The view that it's important or very helpful can just be the result of making a virtue out of necessity: In contexts where the main or only candidate access is by cycling, it follows that order is very important - just for ease/speed of access. But when other powerful ways of accessing are available (e.g. easy narrowing - #1, #2), the sort order can serve various other, otherwise useful and interesting purposes than just accessing a candidate. Beyond just contrasting ease of access: Scoring tries to measure relevancy, but real candidate relevancy in many contexts can go beyond any what any name-matching regime can offer. Real relevancy can often be about matching things about candidates that aren't contained in their names. The PREDICATE arg for `completing-read', etc. makes it possible to match based on more than just candidate names. But unless some hoops are jumped through, candidate sorting is based only on names. PREDICATE constrains matches, but the result is a set of names, and those are what get scored. Which brings up a related point: the purpose of completion - showing matching candidates. If the only purpose is to choose a candidate, that colors what one thinks is important/helpful. Other purposes come from the value of seeing and manipulating a _set_ of things. And sort order fits in here: It can be useful to present a set of candidates in different ways, including different orders, for different purposes. It's not just about sequential order for accessing a candidate. Consequently, it can be helpful to be able to change the sort order on the fly (during completion/matching), in order to present the same set of matches in different ways. These 2 Icicles pages give an idea of other uses of sort orders. They describe or show orders that help you see relations among candidates in a given set of matches. (And yes, such sorts do often involve candidate info that goes beyond names.) https://www.emacswiki.org/emacs/Icicles_-_Sorting_Candidates#DifferentSorts= ForDifferentUses https://www.emacswiki.org/emacs/Icicles_-_Key_Completion#Sorting