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: Mon, 28 Dec 2020 09:30:33 +0000 Message-ID: <875z4ml1l2.fsf@gmail.com> 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="3913"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 42149@debbugs.gnu.org, Dario Gjorgjevski To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 28 10:33:25 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 1ktou5-0000wC-OZ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Dec 2020 10:33:25 +0100 Original-Received: from localhost ([::1]:53898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktou4-0006h1-N4 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Dec 2020 04:33:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktorn-0005mR-CX for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 04:31:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50899) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktorm-0006PJ-DA for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 04:31:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ktorm-00056u-9g for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 04:31: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: Mon, 28 Dec 2020 09:31: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.160914784519621 (code B ref 42149); Mon, 28 Dec 2020 09:31:02 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 09:30:45 +0000 Original-Received: from localhost ([127.0.0.1]:34212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktorV-00056P-0N for submit@debbugs.gnu.org; Mon, 28 Dec 2020 04:30:45 -0500 Original-Received: from mail-wr1-f49.google.com ([209.85.221.49]:46057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktorT-000566-0B for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 04:30:43 -0500 Original-Received: by mail-wr1-f49.google.com with SMTP id d26so10745289wrb.12 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 01:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=AmRGFeuGm8FWYyxk6XA3Lv/Wv5vpX46Pml+sbB8gtPI=; b=MnBJjBZgqg2GZCJmFdwR1n79AZgcvAND2XOm1fkeD0ITImj30TyI/ietSHco3eadwf W1u58Iw3WDkpRqzNYLgTzFazC/rHVBwzWtTEAaAlkLomS9uxMt34jj0fdqmTI1iS8xWx p1wOHFQ/21HGvjiYXLnHGeI+VvMUOKSEpJN8rytxIqaVa4/cfbd1KQuVXw5LK9lNH0G9 34DOYxIWcsc4dLwyhIMEhk+huE5uV4ztFJMpAlMnSuSjWRW7n/M03QTc66s13g3UjJ+M N6dEQvJLC5/HEGXBtamKzMfod4D5zc48SUGoWqVLgnX48ArxLOxeAChRTGN03aIpGzU+ 1CaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=AmRGFeuGm8FWYyxk6XA3Lv/Wv5vpX46Pml+sbB8gtPI=; b=R4wwXUCtz4HpjxL9/W+pmJvD7IoYdvC+kpAZnWeNC7w7G1ybHQrBGF2AUlHCog1ejm 9c0uScPW52Jt/sUL4bECEKnYOji2uctXCELMN6XzfvivuIJfcsDcEquvvTcviMhG4ALo F9N+gNoMuw+QT8qTEkuFWFvYk4V2lNyijV5qCiBUa3UnxFrIqOauCLvFgQu1ryp7BXcn amyLUCAAa5KrwQkSYPjCKFCaaRs1I+7tYZTZOzi+PfljG6T3+V2rJuy7kQAulUzkpc6m qVVg6W7KUNURbRW1HUXz2lD8V47cggTFaFVHFEvMc+T9AdzESeTqaAOpkkw1AFfoXlTW KBmw== X-Gm-Message-State: AOAM531Hkdjqaa9CGy13lZn6SejWNDjjjqdFCOCDWdGc64fePm/n7E3h mMgm7AVrbMO10m3yzu+IfJ780MuarCY= X-Google-Smtp-Source: ABdhPJx+rJTiIljErxcuBPTUHGqvw95RAxoUQFjXWollTj8hmMQw4WJ/v+JCDiHU2HP5v2gqxV9v8g== X-Received: by 2002:adf:e64b:: with SMTP id b11mr49842101wrn.257.1609147836688; Mon, 28 Dec 2020 01:30:36 -0800 (PST) Original-Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id u13sm55030417wrw.11.2020.12.28.01.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 01:30:35 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Sun, 27 Dec 2020 16:20:49 -0500") 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:196853 Archived-At: Stefan Monnier writes: >> @@ -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'. > > There is always an implicit terminating `any`, and I'd really prefer to > keep it implicit. OK, but can you elaborate on why that is? Regardless, if you don't want to touch that funciton, I understand, it is used in more places than just completion-pcm--hilit-commonality, which really should be called completion--given-that-we-know-this-matches-tell-me-where-and-how-well (or maybe it should have a docstring, which I've done just now). I propose something around this simpler patch. diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7d05f7704e..df4ec67e35 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3255,10 +3255,10 @@ completion-pcm--hilit-commonality (unless (string-match re str) (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) - (md (match-data)) - (start (pop md)) - (end (pop md)) + (md (cddr (match-data))) + (start 0) (len (length str)) + (end len) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" ;; flex-matches "fabrobazo", "fbarbazoo" and It seems to be passing your original report, but still failing some of your test assertions. However, i don't know if I agree with those test assertions. This is one of them. (ert-deftest completion-pcm-test-3 () ;; Full match! (should (eql (completion--pcm-score (car (completion-pcm-all-completions "R" '("R" "hello") nil 1))) 1.0))) I still don't know why this misses, but I do know that the scoring part of completion-pcm--hilit-commonality is not meant for the "bare" pcm completion style or substring completion style. It could, though. I'll take a better look at those cases. Anyway, I've pushed this simple fix (and some another fix to the test cases) to the working branch: scratch/bug-42149-funny-pcm-completion-scores which I've also rebased on top of origin/master by deleting/recreating. Jo=C3=A3o