From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Mendler Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: bug#48841: [PATCH] Add new `completion-filter-completions` API and deferred highlighting Date: Wed, 11 Aug 2021 18:11:21 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28228"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47711@debbugs.gnu.org, Stefan Monnier , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , 48841@debbugs.gnu.org, Dmitry Gutov To: "emacs-devel@gnu.org" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 11 18:12:21 2021 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 1mDqq5-00075x-6O for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 18:12:21 +0200 Original-Received: from localhost ([::1]:54716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDqq3-0001Bz-8S for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 12:12:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDqpm-0001BQ-HF for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 12:12:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53074) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDqpm-0004B5-BC for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 12:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDqpm-0003Vx-6n for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 12:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Aug 2021 16:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48841 X-GNU-PR-Package: emacs Original-Received: via spool by 48841-submit@debbugs.gnu.org id=B48841.162869829113453 (code B ref 48841); Wed, 11 Aug 2021 16:12:02 +0000 Original-Received: (at 48841) by debbugs.gnu.org; 11 Aug 2021 16:11:31 +0000 Original-Received: from localhost ([127.0.0.1]:36384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDqpG-0003Ut-SC for submit@debbugs.gnu.org; Wed, 11 Aug 2021 12:11:31 -0400 Original-Received: from server.qxqx.de ([178.63.65.180]:60351 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDqpF-0003UZ-3i; Wed, 11 Aug 2021 12:11:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:References:Cc:To:From:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=L9YD2Rbs2yUeev3cPOFCPRt64IqdN05dDBBAfML4R0Y=; b=PYVBp5sBBCAoJ4YvgPqbbwiiXL IuVLkgk+39f09D7qa9siQeSn5VpG+WNb4+9wvgzxTMubp8aXRfRL9GfhgFqd7ORoZhAwiv0T5G5KC i2ckBeXWHmESGnVZ3uZ7cQ/fP1vXU8fQja7S3gO1j634WEiBrgFDUNflZQz1n2BV8CGc=; In-Reply-To: Content-Language: en-US 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" Xref: news.gmane.io gmane.emacs.bugs:211612 gmane.emacs.devel:272325 Archived-At: On 8/11/21 4:16 PM, Daniel Mendler wrote: > I prepared a patch which provides the API > `completion-filter-completions`. This function supports deferred > highlighting and returns additional data with the list of matching > completion candidates. The API supersedes the existing function > `completion-all-completions`. > > The main goal of the new API is to avoid expensive string allocations > and highlighting during completion. This is particularly relevant for > continuously updating completion UIs like Icomplete or Vertico. > Furthermore the end position of the completion boundaries is returned > with the completion results. This information is not provided by the > existing `completion-all-completions` API. > > See also the relevant bugs bug#47711 and bug#48841. I am looking forward > to your feedback. Thank you! There are currently two issues with the patch with regards to backward compatibility. Fortunately they are fixable with a little effort. 1. I would like to deprecate `completion-score' or remove it altogether, but unfortunately `completion-score' is used in the wild. In order to preserve `completion-score', bind `completion--filter-completions' in the highlighting functions. Add `completion-score' in `completion-pcm--hilit-commonality' when `completion--filter-completions' is nil. 2. In `completion--nth-completion' set `completion--filter-completions' to nil, unless `(memq style '(emacs21 emacs22 basic partial-completion initials flex))' such that custom completion styles which wrap the completion functions don't see the new return value format, except if the custom style opts in explicitly by binding `completion--filter-completions'. An alternative criterion is `(memq fun '(completion-emacs22-all-completions) ...)'. Unfortunately this approach will still not work if the user has advised a `completion-x-all-completions' function. The only 100% safe approach seems to transparently redirect calls to `completion-x-all-completions' to `completion--x-filter-completions', which returns the results in the new format. With these changes the patch should be 100% backward compatible. Daniel