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 12:57:10 +0000 Message-ID: <87r1najdg9.fsf@gmail.com> References: <87sgbsv7gg.fsf@gmail.com> <871rfal18a.fsf@gmail.com> <87wnx2jh98.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="15768"; 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 Mon Dec 28 13:58:10 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 1kts6D-0003zm-Vc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Dec 2020 13:58:10 +0100 Original-Received: from localhost ([::1]:44694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kts6D-0000xc-03 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Dec 2020 07:58:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kts66-0000wG-Fp for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 07:58:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kts66-0007a1-7v for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 07:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kts66-0004Bg-7D for bug-gnu-emacs@gnu.org; Mon, 28 Dec 2020 07:58: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 12:58: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.160916024116049 (code B ref 42149); Mon, 28 Dec 2020 12:58:02 +0000 Original-Received: (at 42149) by debbugs.gnu.org; 28 Dec 2020 12:57:21 +0000 Original-Received: from localhost ([127.0.0.1]:34574 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kts5R-0004An-3N for submit@debbugs.gnu.org; Mon, 28 Dec 2020 07:57:21 -0500 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:38186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kts5P-0004AX-78 for 42149@debbugs.gnu.org; Mon, 28 Dec 2020 07:57:19 -0500 Original-Received: by mail-wm1-f45.google.com with SMTP id g185so9735439wmf.3 for <42149@debbugs.gnu.org>; Mon, 28 Dec 2020 04:57:19 -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=Uth/5Ngv+mPEVysyPSXscX0nLbJV9tWJ0YZMEEk6R94=; b=sawk//tfW+aZElLyUTwxE26hfRc9OFW3wPC1w4YDz92rL1+CtVkI0H9kby2LsSf2xJ nYu6EAQ3j+opVvTkenGKs0pj6seeKnl5qYzGtf625ZH5yzhe7Lh+c7vEGNGnfSTM5KSh VnUMGPh08cF9RkHOmjsypDsHReLsURb8ohTNsIUD4uwl39+w27WKfpafw9ZVNFDPF58b J9yHkVWBABPVi8qVITsz5eqyBJbyIoRcSa01eDUwks2FwvSfFRcLoiHYx+EIEpnoGd94 mOWI970w36CHwd5yZPcLnDTjUh+OI+P0xuCrMr+PMcfZgtBR5tSwuAQyfQ6xvoi9k8Bd KMWg== 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=Uth/5Ngv+mPEVysyPSXscX0nLbJV9tWJ0YZMEEk6R94=; b=oktFs1q3o2kp8JjNVvZR8mUoCFls5czSlxAXow3KcEZKM3hQQ+C6Ud7MB7I15oy+LL 8Lg7xNLww2RS6RKCfMMzvuuUx6e/8otw6u4sswLCiH0r1GGf6zgbGzWB4xlfDHoJJSB1 cKj2n9enoCnqetVO35EkHeRJ6NeFE13AVwIuB+d+tnkc4nW1yJjycTOTLGaVk2BkcVNj uYcwn7loBM2wYVT3+9XFlBcDgwtn65r3L7bxY6n7+voivvDsimGSHOOxanafIvKIw1oI 6CHqiAt0KNdTzbMeefwNRGQfQE38kP8kX9OFMIR5m+K3FS/jTUZnkIisMbgKeUr00um0 apcw== X-Gm-Message-State: AOAM531/wEz9RrgPvmxZRpH+WFPK8pHAekU7T2Wt9+4imPPwbLztM7h2 WTKHAWLrAtDsocLx5A4FAwYtOr3D0As= X-Google-Smtp-Source: ABdhPJwj1/OShayVLKfMdxnz7PVihblowZY7o3k4+NRxk4KgBNEuriwF8tIZAg/HFor921lvCiz/Mw== X-Received: by 2002:a1c:b7d4:: with SMTP id h203mr20593589wmf.59.1609160232931; Mon, 28 Dec 2020 04:57:12 -0800 (PST) Original-Received: from krug (222.201.137.78.rev.vodafone.pt. [78.137.201.222]) by smtp.gmail.com with ESMTPSA id h3sm20245762wmm.4.2020.12.28.04.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Dec 2020 04:57:11 -0800 (PST) In-Reply-To: (Dario Gjorgjevski's message of "Mon, 28 Dec 2020 12:48:28 +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:196866 Archived-At: Dario Gjorgjevski writes: >> For now, I believe the original problem that started this bug report, >> which dealt with flex and substring completion, is fixed by my patch. >> Your failed user experience of typing "R" to perform "M-x R" should now >> be correct, as far as I can tell. > > Sorry, but the branch bug-42149-funny-pcm-completion-scores doesn=E2=80= =99t fix > any of that problem. > > (completion-flex-all-completions "R" '("R" "something-else-with-an-R") > nil 1) > > Will make both "R" and "something-else-with-an-R" get a completion-score > of 0, which is definitely not helping anything. You're right. I was a little too eager, and reported results on a version that had another fix built it (a fix that is also simple and reasonable, but which I haven't shown since it conses a little bit). Anyway, the patch after my sig should fix it. I'll push it later with better comments, but it correctly identifies the presence or absence of a trailing 'any in terms of the match-data, and corrects accordingly, in terms of scoring. It also fixes another one (I don't know which) of your tests. Now only two tests fail: F completion-pcm-test-5 F completion-substring-test-4 I think we should focus on the meaning of these tests from here on. Thanks, Jo=C3=A3o diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 4c912b5a34..eec0b3e09e 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3263,9 +3263,9 @@ completion-pcm--hilit-commonality (error "Internal error: %s does not match %s" re str)) (let* ((pos (if point-idx (match-beginning point-idx) (match-end = 0))) (md (cddr (match-data))) + (match-end (cadr (match-data))) (start 0) - (len (length str)) - (end len) + (end (length str)) ;; To understand how this works, consider these bad ;; ascii(tm) diagrams showing how the pattern "foo" ;; flex-matches "fabrobazo", "fbarbazoo" and @@ -3326,6 +3326,8 @@ completion-pcm--hilit-commonality 'completions-common-part nil str) (setq start (pop md))) + (unless (=3D start match-end) ; ... which is t if we have trail= ing 'any + (funcall update-score start match-end)) (add-face-text-property start end 'completions-common-part @@ -3338,7 +3340,7 @@ completion-pcm--hilit-commonality (unless (zerop (length str)) (put-text-property 0 1 'completion-score - (/ score-numerator (* len (1+ score-denominator)) 1.0) str))) + (/ score-numerator (* end (1+ score-denominator)) 1.0) str))) str) completions))))