From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: bug#47711: [PATCH] Add new `completion-filter-completions` API and deferred highlighting Date: Wed, 11 Aug 2021 17:17:07 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19648"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dmitry Gutov , "emacs-devel@gnu.org" , Stefan Monnier , 48841@debbugs.gnu.org, 47711@debbugs.gnu.org To: Daniel Mendler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 11 18:18:23 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 1mDqvv-0004up-42 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 18:18:23 +0200 Original-Received: from localhost ([::1]:33360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDqvt-0005wH-JT for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 12:18:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDqva-0005r5-UH for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 12:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDqva-0000Fn-MW for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 12:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDqva-0005pe-Do for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 12:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Aug 2021 16: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.162869864821766 (code B ref 47711); Wed, 11 Aug 2021 16:18:02 +0000 Original-Received: (at 47711) by debbugs.gnu.org; 11 Aug 2021 16:17:28 +0000 Original-Received: from localhost ([127.0.0.1]:36392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDqv1-0005ei-S7 for submit@debbugs.gnu.org; Wed, 11 Aug 2021 12:17:28 -0400 Original-Received: from mail-pj1-f52.google.com ([209.85.216.52]:42550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDquz-0005ZI-D2; Wed, 11 Aug 2021 12:17:26 -0400 Original-Received: by mail-pj1-f52.google.com with SMTP id mq2-20020a17090b3802b0290178911d298bso5839129pjb.1; Wed, 11 Aug 2021 09:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jA8E40VtlAuX0iMEkWlyJ13M+vYAfR9CULGNzYrMWuw=; b=nqcIq4vOrpqIwPVP+7LOt4OpWbiWWrogS1eHgcHDa+vtPH3Ha0L1qzKb8X4HN7V5s9 YZ0gwitcOOhmL8STj5M8Z+dbTpuziDlwrWH6eWNnp75JcAKnCAD+/Vh2y+yBNgzr3a10 YhROHr/KYUsOIcV/5Auj+FMbg2InwANm0FFPpUXlOktGbLo1376Vm2WL8kBg6PLjoUgX 3HEkWQg3QGPpF0tkSrmYTnchgUFZKmkaZOEXuJE/+qDE0cpoVjOaE2bzNLGJiX+iMQac lZNhoyzC7vgfvHed3pwZIAxGNM+hp5J29mlwnpKLsgpdGXVgOm2HtDlQonDhXSLUMuKs FduQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=jA8E40VtlAuX0iMEkWlyJ13M+vYAfR9CULGNzYrMWuw=; b=SOA8e6x4uRSrmAteCOOcUkm3Wc//TKG1aUAO0VpyNZo23J9oLGpXKmrO4CwiWzawqq oMzOmbDbZwvpxK2fht4BSlDfbVlMVT5A4ResIlgi9MokNykxQJ83ObqmYUSrUayD9B/1 QdNn1r9/JhDMqAJAxod8u10v4bpt4OUDSLg/pm6c8eM+2Ogj4psMkTdfGlAyzHABjrFx dhg1Dt0hGftCHeyZ5qtbYX1RWkZwGaQnBeboDpBmkG5kwEHn7jeUFpkH0VDD7wqtypWk tk1mkGfjpL16Yu398Z8Oi6jf0W/p87EmReZnuO1tJaflpo/nnWtaAHAXDM3p3gIhxXyj 3bIg== X-Gm-Message-State: AOAM533lMhyMxqZtgJ6+NSfSSwwNOHnH5JlHjTOqTWHT4jh7pBDSCOAJ urUK93eFKxO3eU+2okNK5X1/EUPTFArte+8c/rw= X-Google-Smtp-Source: ABdhPJyP0fKKy0TCf0MVCKV4sAlwqv6ZxwwQMS5d//O3nf4QoGUYY3eWz0YesAADm/rqyracNgAd497dBs1yi5ai1Rg= X-Received: by 2002:aa7:9050:0:b029:3af:7e99:f48f with SMTP id n16-20020aa790500000b02903af7e99f48fmr29318366pfo.2.1628698639473; Wed, 11 Aug 2021 09:17:19 -0700 (PDT) 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" Xref: news.gmane.io gmane.emacs.bugs:211613 gmane.emacs.devel:272326 Archived-At: Perhaps you should first provide a patch with these 2 "little effort" chang= es, (that are presumably also backward compatible and don't affect the API) by themselves. Reading about these complex ideas isn't as clear as seeing them in actual code. Then it'll be easier to evaluate the merits of the patch you proposed in your first email. Jo=C3=A3o On Wed, Aug 11, 2021 at 5:11 PM Daniel Mendler wro= te: > > 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 forwar= d > > 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 --=20 Jo=C3=A3o T=C3=A1vora