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:08:04 +0000 Message-ID: <874kk7107v.fsf@gmail.com> References: <87sgbsv7gg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37481"; 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, 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:09:24 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 1ktcLz-0009bd-6L for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 21:09:23 +0100 Original-Received: from localhost ([::1]:52124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktcLx-0004fJ-KS for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 15:09:21 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktcLf-0004fA-69 for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 15:09:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktcLe-0004ZB-NR for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 15:09:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ktcLe-0004cP-HI for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 15:09: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:09: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.160909969717701 (code B ref 42149); Sun, 27 Dec 2020 20:09:02 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 27 Dec 2020 20:08:17 +0000 Original-Received: from localhost ([127.0.0.1]:33609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcKu-0004bQ-VY for submit@debbugs.gnu.org; Sun, 27 Dec 2020 15:08:17 -0500 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:46097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktcKs-0004bC-1l for 42149@debbugs.gnu.org; Sun, 27 Dec 2020 15:08:15 -0500 Original-Received: by mail-wr1-f43.google.com with SMTP id d13so8789193wrc.13 for <42149@debbugs.gnu.org>; Sun, 27 Dec 2020 12:08:14 -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; bh=kuXDCwlHxICb9cVqSsci+N7jumVvN5yTexi6heah2hU=; b=g5vIA8FzW0bFoDlbT5LmCaXu/BwMXXq6akjz2D9DP/m/VHFcwckcstvfCZNWVKAk7H YeBdeEHvZ9JFna8942ehFbgsZjLBYwikpnhWmUo5GIPTLBQ2G+QBY+ijjPzEggJR48wu Y6pCpMFtf5oiEpJ8lcFUvu9/9stf8SCo5Gu2JBm/K7kxw4LD0vbqCyIclJB5aDig7pXT v/YwqAKBYKhjgugT2c49nYwbrhOgyxPPmStazQQDoxINMTDHHUKT40FxM9JVZM1kE8Fg E30S1oFH1eGprOoJFONR57D0GxjaLOuoUvkkg8zc+ZC5nWQjAKAlIct8tfrtbizBg5Ke OO1w== 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; bh=kuXDCwlHxICb9cVqSsci+N7jumVvN5yTexi6heah2hU=; b=DG0y0wqzYr47qGjN5NxKGjLvnnIP8L8/2uXLOwQXFLorxzFKgLohK0Xb9n2XkoibC/ AkdLmOtmaYQJ5BvKrddBEdKvE6PzEYrLHWrYtrgsTGKKzhEnFmn2uS+urlPg4kR1mF+8 ZfbcTV7ZSftoAr/C+R6NvV8H45NDBFWAeIpLtHS9UBbKkUI6UlTdNFvbCcofH6MFHTWT pfRhXNLHuK3cEzRDhcnHIesC51hWZARTMqFk1O7hTs1zure8CXueyIVLkWdd8oKTyaD4 TxdmvA62ObnCm14ieuju4RCHqSz8TsiJVsg7941dVZgiadUHHrt7zZnoxnNZwtmA/YvK jO0w== X-Gm-Message-State: AOAM531vkYeDxaGFV0baLjZIJ8mAvuxkmlQY+J0spO0nF1ti7Ges7Y1T wGnpgLt/rewMXGr6jAFrTREdZqoxBFA= X-Google-Smtp-Source: ABdhPJwmwr3eAjKTF6OZsLtOSLHQF1EEVMNV5+lDEuIHtd7/NxMO3ZChY/zB2AKwFmjf4fm14pwmew== X-Received: by 2002:adf:ef51:: with SMTP id c17mr38005610wrp.101.1609099687974; Sun, 27 Dec 2020 12:08:07 -0800 (PST) Original-Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id r82sm16941427wma.18.2020.12.27.12.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Dec 2020 12:08:07 -0800 (PST) In-Reply-To: (Dario Gjorgjevski's message of "Wed, 23 Dec 2020 10:41:42 +0100") 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:196824 Archived-At: 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