From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#47711: bug#48841: bug#47711: bug#48841: bug#47711: [PATCH VERSION 2] Add new `completion-filter-completions` API and deferred highlighting Date: Fri, 3 Nov 2023 02:16:23 +0200 Message-ID: References: <56ab18b1-4348-9b2c-85bb-af9b76cd429a@daniel-mendler.de> <328f87eb-6474-1442-e1ca-9ae8deb2a84a@yandex.ru> <83fsvcbio7.fsf@gnu.org> <9f432d18-e70f-54c1-0173-1899fb66d176@gutov.dev> <877cnafv39.fsf@gmail.com> <9447dde3-b8e7-2ec0-9a9c-72c4cf9d12a8@gutov.dev> <7d14bc13-4419-816c-5708-c42988c39c02@gutov.dev> <5d0a78cc-4fa0-ef04-3462-1826f17d7d56@gutov.dev> <1504b2e4-42d9-5d7b-eaa2-c7b7d5ca02ba@gutov.dev> <40ddec76-751a-36cd-7f45-34de2d9d9393@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39119"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: Daniel Mendler , Eli Zaretskii , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , 47711@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 03 01:17:42 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qyhsZ-0009sM-Rf for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 03 Nov 2023 01:17:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qyhsP-0008KM-Qz; Thu, 02 Nov 2023 20:17:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qyhsN-0008Ju-9n for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 20:17:27 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qyhsN-0000Rx-26 for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 20:17:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qyhsw-0007AO-7l for bug-gnu-emacs@gnu.org; Thu, 02 Nov 2023 20:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Nov 2023 00:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47711 X-GNU-PR-Package: emacs Original-Received: via spool by 47711-submit@debbugs.gnu.org id=B47711.169897063727425 (code B ref 47711); Fri, 03 Nov 2023 00:18:02 +0000 Original-Received: (at 47711) by debbugs.gnu.org; 3 Nov 2023 00:17:17 +0000 Original-Received: from localhost ([127.0.0.1]:56430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyhsD-00078G-6S for submit@debbugs.gnu.org; Thu, 02 Nov 2023 20:17:17 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:58245) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qyhs8-00077y-3L for 47711@debbugs.gnu.org; Thu, 02 Nov 2023 20:17:15 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7EAE15C00E0; Thu, 2 Nov 2023 20:16:31 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 02 Nov 2023 20:16:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1698970591; x=1699056991; bh=s9n3pn4qkdGfQy//OH5t25w2Sr9DY23Vj+H dT/mgek8=; b=HRsmk147LE8sXNuuOWhhsrdaRM3VjKTcbDZslECY+QxnvA99mCF pOQwYQPqspeLkLWTrZ6QFOoFZ4mVL90VcryUr3biDfr9ToR7XAquUSkYgbgAAf2z EroSCUQJmUbNE8JJCmctfkM4R10Ai8g8XsddlpwvJYS8yBV1zIiy/sUua/eOAhlb OHb3u2CWTy+F0voE6dNZ0LcfdYM5WlC2z/t2yKLIxUNQQNkAAoAJUFDv/aQYWIT0 xcmN6YJrjTzGInKxwI58xeNX6TaSSWno/mkViCEKLiicDudNbZomuRaA6wq+zbKY iYPLAesEn2n6QUt4weyFeodHjRfxN4aoQIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1698970591; x=1699056991; bh=s9n3pn4qkdGfQy//OH5t25w2Sr9DY23Vj+H dT/mgek8=; b=fZVcZw3ZUde0K5VJu3gLBSKBYYr4EOwmP7LRg8KX+P02svLRCPX 7H1fWU2bmNiGbsPtfvzAT0W6fliJ594MvbD7LorXKDB/aTSmOTaeOCGXGQWmGzKN qMhNqV2V8wIx63vqK8G0QrqucEJjSzGvWAowEWQx7ItmYgVqXl1au+plFsNutNGE WxobMtBtjAwS7tBZgxNKRBrQ/7lC4LDdgG60HAznCQSKJxu51oRGfkFraTr9NWUg XPSZRhtpmnuxJLgk4IIM7CnNTJkJgWSHP/phn8ZTFH2F0bNb8IOBmrjmpeCm4giT nZzyA1nPCI8bA7+bwHMMZzr43yy817+6CKA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddtjedgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 Nov 2023 20:16:27 -0400 (EDT) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273687 Archived-At: Hi Stefan, Sorry for the pause, let's continue this digression. Though perhaps it would be better moved to emacs-devel or somewhere else. ;-/ On 29/10/2023 06:41, Stefan Monnier wrote: >> FWIW, this neat structure might not help too much: the most popular external >> completion backend (the LSP language servers, collectively) don't accept >> regexps or globs, they just send you the lists of completions available at >> point. With the name matching method sometimes configurable per-server. > > Largely agreed. The main benefit tho is that you get just *one* > pattern, rather than three (one being the prefix argument, the second > being the `pred` arg which historically was so unused that it was abused > to hold the directory for file-name completion, so lots of tables don't > obey it, and the third being the `completion-regexp-list` that most coders > forget, and those who don't end up regretting not forgetting when it was > not meant for them), so it's much more clear. The motivation all makes sense. >> As such, the most useful methods currently are: 1) Emacs Regexp, 2) asking >> server for whatever it thinks is suitable (the "backend" completion style). > > For the backends: agreed. > For the frontends (i.e. `completion-styles`), `glob` is the more useful > one, I'd say (except for the "external" style, of course). > > We might also want support for things like `or` and `and` patterns, but > I haven't managed to fit them nicely in that structure :-( Possibly, but which code would produce such patterns? >> I would also probably want to standardize on the recommended type of TO >> anyway: some of them are likely going to result in better performance >> than others. > > The TO is chosen by the specific completion table, based on what it can > handle best. So it should always be "optimal". Sorry, I meant the recommended type of FROM. Because if the original caller passes an arbitrary regexp, it will often get turned into a pair with a predicate where the latter calls string-match-p. And if the type of FROM is standardized, there likely would be no need for a four-way bidirectional conversion. Maybe just a helper that converts from the original "main" type into any of the available that is currently required. >> So I guess it's also a way to make every completion table aware of PRED? > > Note also that these `pred` patterns are expected to be exclusively > looking at the string (they're used for `completion-styles` kind of > functionality), so nothing like `file-directory-p` or `fboundp` kind of > predicates here. Would we consider those pred's "fast enough"? I've done a little comparison of completion-regexp-list vs pred: (setq sss (cl-loop repeat 300000 collect (symbol-name (gensym "yoyo")))) (benchmark-run 10 (let* ((re "yo[^o]*o") (completion-regexp-list (list re))) (all-completions "" sss))) ;; => 0.60s (benchmark-run 10 (let* ((re "yo[^o]*o")) (all-completions "" sss (lambda (s) (string-match-p re s))))) ;; => 1.14s > The `pred`s used in things like `completing-read` and `read-file-name` > would be handled elsewhere such as `completion-table-with-predicate`. > This part is still up in the air, tho. > >> That should work; though it might be hard to reach the same raw performance >> as the current all-completions + completion-regexp-list. > > I don't see why: currently my code actually uses `all-completions` and > `completion-regexp-list`, so as long as the pattern can be turned into > a regexp without requiring an additional PRED (that's usually the case), <...> Right, I was talking about the possible exceptions.