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 Subject: bug#42149: Substring and flex completion ignore implicit trailing =?UTF-8?Q?=E2=80=98any=E2=80=99?= Date: Sun, 27 Dec 2020 20:23:28 +0000 Message-ID: References: <87sgbsv7gg.fsf@gmail.com> <874kk7107v.fsf@gmail.com> 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="17985"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42149@debbugs.gnu.org, Stefan Monnier To: Dario Gjorgjevski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 27 21:24:11 2020 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 1ktcaI-0004Xw-HB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 21:24:10 +0100 Original-Received: from localhost ([::1]:55782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktcaG-0006yB-T9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 15:24:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktcaA-0006y4-Gv for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 15:24:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktcaA-0001BV-9i for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 15:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ktcaA-000506-5o for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 15:24:02 -0500 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: Sun, 27 Dec 2020 20:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42149 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 42149-submit@debbugs.gnu.org id=B42149.160910062719201 (code B ref 42149); Sun, 27 Dec 2020 20:24:02 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 20:23:47 +0000 Original-Received: from localhost ([127.0.0.1]:33645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcZv-0004zc-3B for submit@debbugs.gnu.org; Sun, 27 Dec 2020 15:23:47 -0500 Original-Received: from mail-il1-f180.google.com ([209.85.166.180]:39700) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcZt-0004zN-Px for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 15:23:46 -0500 Original-Received: by mail-il1-f180.google.com with SMTP id q1so7916861ilt.6 for <42149@debbugs.gnu.org>; Sun, 27 Dec 2020 12:23:45 -0800 (PST) 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=b2nEiuewuIOm04gnni5OMU133fzw11mNOSEs9ho4OWs=; b=YxIvJYMuI1+K+sfBmCSYw1BL9MiL1LsJRIL+I2vEStYGfZ9cnY1A5Pr+eXb6nN47W/ uqh2ts+LoFFV4XdzOH+uMA4puDWi/8UGJ0LBOJX+xWxPfu8jGCrFQODeil3oSaMPE8Pk 10ORtgbnwAKLK2xnhwHMAe1XvdX9UEl77kspAO/in/3FjXHuBRdI5yyKxBF+nnmHqLc8 RdH7mmEUOyGv1xttRbj9qxoh0DLdUOvXCdrD6PO7Lehrz+ha0pmlJJCQHa7B+TDXyrNM AQ6r3UHda5FEx5viJPtR1i97AnguA7y8ILT6SXFlB8TZEUHjh4qHkHKn2oJIeoiMmeQv X+kA== 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=b2nEiuewuIOm04gnni5OMU133fzw11mNOSEs9ho4OWs=; b=Vp4Xb+hQP4caKjInYDo6WF6J3HOOj+M0LeD0yEGNXJq4R1HSL7CcqlAkEKfzQTwGtZ 7fbS0BvTrpFdGadwF9V/ofbKBETpjCTgIUcfF21KFmyDMppNCLZ73qCAiZGig/ND/vLB RjpSIdKEfUkPmsyrI+9+Nr9WRnkQQew8FcWu3njYSu79Y3F0vyA4ipT9l3PTVv2xdKO8 iWAJpkhHZJT6S2WKXj5Fq1+fEe+Ch83utsdOAH78UPMM+Qz3/FUTk2bgwS4IXOT9Hqw3 IT2yx6ZREkrtWpFsQxoEGo225+tuphZuZGrl+0/iN55T26PMNaTidYIGnwn20Cs9NJKZ y3PA== X-Gm-Message-State: AOAM532QD+va9g9I1T5Kc/VjuMl3/r+bkJPFYpKiL6+1xYf3vYsPGADD OW3cNPeBgWC8WrkYvLtvdsKnUWudiGkzRD8cSno= X-Google-Smtp-Source: ABdhPJyCx9xD8mCMpvkenGzJEbpPZsYJvMdVtLOIoj0+lJ2X8GPyOGQU+mmfAXrrXbDXDwJLYLorkVlgLE7BlXxFW80= X-Received: by 2002:a92:4089:: with SMTP id d9mr36836550ill.199.1609100620191; Sun, 27 Dec 2020 12:23:40 -0800 (PST) In-Reply-To: <874kk7107v.fsf@gmail.com> 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:196826 Archived-At: I'm sorry, I seem to have sent the previous reply prematurely. However, there was not much more to add except my signature and some more reporting on test results. Thanks, Jo=C3=A3o On Sun, Dec 27, 2020 at 8:08 PM Jo=C3=A3o T=C3=A1vora wrote: > > Dario Gjorgjevski writes: > > > Hi, > > > > Has anyone had the time to look into this? > > > > Best regards, > > Dario > > Hi Dario, > > After a long long delay, I've now looked at this in earnest. > > I can report that I think the problem lies somewhere completely > different than what I think you patch addresses. Instead of reworking > > completion-pcm--hilit-commonality [1] > > I think we should take a better look at > completion-pcm--optimize-pattern. In its current form, it will thus > "optimize" the pcm patterns like so: > > 1 -> (completion-pcm--optimize-pattern (prefix "f" any point)) > 1 <- completion-pcm--optimize-pattern: (prefix "f") > > whereas I think it shouldn't be optimizing away the "any". When I make > it keep the any with this simple patch, _most_ of your tests start > passing becasue completion-pcm--hilit-commonality starts doing the right > thing, i.e. it starts working the way it was intented to work, > considering a (potentially empty) hole in the back of the pattern form. > > This is that simple patch: > > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index 7d05f7704e..637a29eaa0 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3165,7 +3165,7 @@ completion-pcm--optimize-pattern > ;; the final position of point (because `point' gets turned > ;; into a non-greedy ".*?" regexp whereas we need it to be > ;; greedy when it's at the end, see bug#38458). > - (`(point) (setq p nil)) ;Implicit terminating `any'. > + (`(point) (setq p '(any))) ;Implicit terminating `any'. > (_ (push (pop p) n)))) > (nreverse n))) > > However, I'm pretty sure Stefan will tell us to hold our horses with any > changes to this, since it's used in many more mysterious ways that I > can't fathom. > > So, maybe this is a smaller, safer change: > > diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el > index 7d05f7704e..cc2573db19 100644 > --- a/lisp/minibuffer.el > +++ b/lisp/minibuffer.el > @@ -3245,6 +3245,8 @@ flex-score-match-tightness > > (defun completion-pcm--hilit-commonality (pattern completions) > (when completions > + (unless (eq (car (last pattern)) 'any) > + (setq pattern (append pattern '(any)))) > (let* ((re (completion-pcm--pattern->regex pattern 'group)) > (point-idx (completion-pcm--pattern-point-idx pattern)) > (case-fold-search completion-ignore-case)) > > [1]: completion-pcm--hilit-commonality, which does seem to have a couple > of superflous calls to the update-score local function) > > [2]: please Stefan: remind me for the 1000th time what "pcm" stands for --=20 Jo=C3=A3o T=C3=A1vora