GNU bug report logs - #65137
29.1; completion-substring-try-completion doesn't return the longest common substring

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Spencer Baugh <sbaugh@HIDDEN>; dated Mon, 7 Aug 2023 23:25:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 6 Sep 2023 11:00:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 06 07:00:48 2023
Received: from localhost ([127.0.0.1]:33082 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qdqH9-0003YP-Rx
	for submit <at> debbugs.gnu.org; Wed, 06 Sep 2023 07:00:48 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:53736)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1qdqH7-0003YC-5L
 for 65137 <at> debbugs.gnu.org; Wed, 06 Sep 2023 07:00:46 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qdqH0-0001cy-HA; Wed, 06 Sep 2023 07:00:38 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=46QUQdsE7LhR9rizBR55NjL4Oj/NwSXyEUAWW45PWLY=; b=rDjIufuDCpMr
 iUeg51N/aa0kz6a9m2KsxiCbO0dVtONj1wLX/yRV4+qL1F8A7/7F4s6xfKOoRVPDasJu7vTbW9tub
 Gr8g0uXfKXumhhozYDuNfRYS0yK8z+7iLX2kdhDIL2eh+i/wTXAjiAGPEN+NNcOKxWivNLmq1oDiG
 WP2+orgY1TY2wXX9zxY2m/nZShxt27pr1Ed5sAXIn7tQO5sgss/oSyH3ES+aoC/G60pyTTPXYAK8g
 eDDBN/d3fYNyycSlxHSMxJLzoNeyV4GGmm4HDtbk9gLH3AIKCZqYkz2p70wfk8ZnMQQUVUBcuGLiZ
 hHSZsn/HdECs9X7AIy+lOg==;
Date: Wed, 06 Sep 2023 14:00:24 +0300
Message-Id: <83tts736t3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
In-Reply-To: <iersf7smma5.fsf@HIDDEN> (message from Spencer Baugh on
 Tue, 05 Sep 2023 15:51:14 -0400)
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
References: <ierr0oe4esg.fsf@HIDDEN> <83a5v1okwm.fsf@HIDDEN>
 <875y5pk8rj.fsf@HIDDEN> <jwvh6ohz5jl.fsf-monnier+emacs@HIDDEN>
 <iersf7smma5.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65137
Cc: sbaugh@HIDDEN, monnier@HIDDEN, 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Cc: sbaugh@HIDDEN,  Eli Zaretskii <eliz@HIDDEN>,  65137 <at> debbugs.gnu.org
> Date: Tue, 05 Sep 2023 15:51:14 -0400
> 
> 
> * lisp/minibuffer.el (completion-pcm--merge-completions): Don't ignore
> a common suffix in a `prefix' pattern element when it's also a common
> prefix.
> * test/lisp/minibuffer-tests.el (completion-substring-test-5): Add a
> test.

Please mention the bug number in the commit log message.

> +                ;; if the common prefix is unique, it also is a common
> +                ;; suffix, so we should add it for `prefix' elements

Comments should begin with a capital letter and end with a period.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 5 Sep 2023 21:27:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 05 17:27:14 2023
Received: from localhost ([127.0.0.1]:59654 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qddZq-0004f4-6W
	for submit <at> debbugs.gnu.org; Tue, 05 Sep 2023 17:27:14 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27599)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1qddZk-0004eo-Da
 for 65137 <at> debbugs.gnu.org; Tue, 05 Sep 2023 17:27:12 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 11FF24446C5;
 Tue,  5 Sep 2023 17:27:02 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1693949220;
 bh=9qBYky+aJI+rnhdKPehXWloUoKXC0BtTfT0JztVFpeI=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=kcFx3k4Z7g60XE1AA8iZjuyeNeanNn2oBH00Nwp9ovCuRug+TeUYWB4qh/YeYZcSo
 Vd/hT6uqT0crXvS9tDb7vLhw8sKMrTLGhKK0GYvOlJMTl2KkwKPmVFz8yscrnmTxQA
 rlpQ31+Og9Z1cunUBq+J0RF9q0SMGldllZBG3lie96H+T3S0wsoU9U2fHNVAuZRIvo
 f//jiK7cxurR3ezFEC4GYvaJfpQ+lufsBQR7tPikt90MOyz9WT08lAPOCHiuJtmKBn
 lnIuYX6JU7KnwqgUNYncKG9vQ1cUN4x4Ca4fZ+isqcR2FxkZh48xjMOW9PN5l8L6We
 oncEjmPkWrmmw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6BC9F4446B7;
 Tue,  5 Sep 2023 17:27:00 -0400 (EDT)
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 54597120263;
 Tue,  5 Sep 2023 17:27:00 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <iersf7smma5.fsf@HIDDEN> (Spencer Baugh's message of
 "Tue, 05 Sep 2023 15:51:14 -0400")
Message-ID: <jwvo7igialb.fsf-monnier+emacs@HIDDEN>
References: <ierr0oe4esg.fsf@HIDDEN> <83a5v1okwm.fsf@HIDDEN>
 <875y5pk8rj.fsf@HIDDEN> <jwvh6ohz5jl.fsf-monnier+emacs@HIDDEN>
 <iersf7smma5.fsf@HIDDEN>
Date: Tue, 05 Sep 2023 17:26:00 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.117 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65137
Cc: sbaugh@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Patch with test:

Thanks, pushed.

>> Similarly, I see that
>>
>>     (completion-pcm--merge-completions '("abr" "absabr") '(prefix "br"))
>>
>> returns
>>
>>     ("br" prefix)
>>
>> whereas it should arguably return
>>
>>     ("br" "a" prefix)
>>
>> [ Tho this may have the side effect that after this completion, `absabr`
>>   won't be considered any more, if the `basic` completion comes before
>>   `substring` :-(  ]

> I did notice this too.  I could try fixing/changing this too, but it
> does seem annoying when basic comes before substring - as it does by
> default in a number of completion categories.

Yup :-(

I have often wished for there to be a way to remember the style that was
used so as to try and avoid such "style capture".

> I wonder if we should move basic to after substring in those
> categories in completion-category-defaults?

It's a tradeoff: the default is designed to reduce the factor of
surprise for people used to the default (i.e. to mostly prefix completion).

> Or just remove basic from them.

Same difference :-)

> It doesn't seem like having both basic and substring in those lists
> has much point.

If you're used to relying on `substring` indeed it's not helpful.
But if you're used to using mostly prefix-based completion (which may
have the effect that you choose your names such that prefix completion
works well), it can be helpful to have `substring` as a fallback when
you can't remember what prefix to use for the thing you're looking for.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 5 Sep 2023 19:51:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 05 15:51:25 2023
Received: from localhost ([127.0.0.1]:59426 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qdc56-0005ES-Ir
	for submit <at> debbugs.gnu.org; Tue, 05 Sep 2023 15:51:25 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:39931)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qdc52-0005EC-V8
 for 65137 <at> debbugs.gnu.org; Tue, 05 Sep 2023 15:51:22 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <jwvh6ohz5jl.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Tue, 29 Aug 2023 21:31:51 -0400")
References: <ierr0oe4esg.fsf@HIDDEN> <83a5v1okwm.fsf@HIDDEN>
 <875y5pk8rj.fsf@HIDDEN> <jwvh6ohz5jl.fsf-monnier+emacs@HIDDEN>
Date: Tue, 05 Sep 2023 15:51:14 -0400
Message-ID: <iersf7smma5.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 65137
Cc: sbaugh@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Stefan Monnier <monnier@HIDDEN> writes:
>>   (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
>>   -> ("b")
>
> Right this is a bug.
>
>     (completion-pcm--merge-completions '("ab" "sab") '(prefix "b"))
>
> returns (correctly)
>
>     ("b" "a" prefix)
>
> so
>
>     (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
>
> should return either ("b" "a") or ("b" "a" prefix).
>
> Could you accompany your patch of a regression test using
> `completion-pcm--merge-completions` as above?

Patch with test:

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Correctly-handle-common-prefixes-in-substring-comple.patch

From 364a10aa54acd8de71a10d1ab98d059a27f26460 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Tue, 5 Sep 2023 15:40:06 -0400
Subject: [PATCH] Correctly handle common prefixes in substring completion

Substring completion would previously not complete the longest common
substring if that substring was a prefix of all the completion
alternatives.  Now it does.  An explanation of this bug

Substring completion is implemented by passing the `prefix' symbol as
part of the pattern passed to completion-pcm--merge-completions.  This
symbol is supposed to cause completion-pcm--merge-completions to
"grow" a completion of a common substring only from the "right" of the
symbol (a common suffix), not from the "left" of the symbol (a common
prefix).  Yes, this is the opposite of what the name `prefix' would
imply.

When processing a symbolic element of the pattern,
completion-pcm--merge-completions first finds the common prefix of all
the completions in that part of the pattern (using try-completion).
Then for `prefix' and other elements which want to complete a common
suffix, the common prefix is removed from each element and then the
common suffix is calculated with completion--common-suffix.

If the common prefix covers the entirety of all the alternatives
(i.e. when "unique" is true in the code), it's also a common suffix.
In that case, the common suffix calculation (if it runs) is basically
a no-op which will produce an empty string, since we removed the
common prefix before running it.

Before this change, `prefix' elements would unconditionally discard
the common prefix, which produced the wrong result in the case that
common prefix == common suffix.  For example:

  (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
  -> ("b")

Now we detect this situation and include the common prefix in this
case for `prefix' elements.  Then we get:

  (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
  -> ("b" "a")

which is correct.

* lisp/minibuffer.el (completion-pcm--merge-completions): Don't ignore
a common suffix in a `prefix' pattern element when it's also a common
prefix.
* test/lisp/minibuffer-tests.el (completion-substring-test-5): Add a
test.
---
 lisp/minibuffer.el            |  4 +++-
 test/lisp/minibuffer-tests.el | 13 +++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 35b359a75e2..ac054da61d2 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4038,7 +4038,9 @@ completion-pcm--merge-completions
                      (unique (or (and (eq prefix t) (setq prefix fixed))
                                  (and (stringp prefix)
                                       (eq t (try-completion prefix comps))))))
-                (unless (or (eq elem 'prefix)
+                ;; if the common prefix is unique, it also is a common
+                ;; suffix, so we should add it for `prefix' elements
+                (unless (or (and (eq elem 'prefix) (not unique))
                             (equal prefix ""))
                   (push prefix res))
                 ;; If there's only one completion, `elem' is not useful
diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el
index ff58d35eb3e..4f92d7f841c 100644
--- a/test/lisp/minibuffer-tests.el
+++ b/test/lisp/minibuffer-tests.el
@@ -298,6 +298,19 @@ completion-substring-test-4
                   "jab" '("dabjabstabby" "many") nil 3)))
            6)))
 
+(ert-deftest completion-substring-test-5 ()
+  ;; merge-completions needs to work correctly when
+  (should (equal
+           (completion-pcm--merge-completions '("ab" "sab") '(prefix "b"))
+           '("b" "a" prefix)))
+  (should (equal
+           (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
+           '("b" "a")))
+  ;; substring completion should successfully complete the entire string
+  (should (equal
+           (completion-substring-try-completion "b" '("ab" "ab") nil 0)
+           '("ab" . 2))))
+
 (ert-deftest completion-flex-test-1 ()
   ;; Fuzzy match
   (should (equal
-- 
2.39.3


--=-=-=
Content-Type: text/plain


> Similarly, I see that
>
>     (completion-pcm--merge-completions '("abr" "absabr") '(prefix "br"))
>
> returns
>
>     ("br" prefix)
>
> whereas it should arguably return
>
>     ("br" "a" prefix)
>
> [ Tho this may have the side effect that after this completion, `absabr`
>   won't be considered any more, if the `basic` completion comes before
>   `substring` :-(  ]

I did notice this too.  I could try fixing/changing this too, but it
does seem annoying when basic comes before substring - as it does by
default in a number of completion categories.

I wonder if we should move basic to after substring in those categories
in completion-category-defaults?  Or just remove basic from them.  It
doesn't seem like having both basic and substring in those lists has
much point.  Plus it would be a nice improvement to defaults - buffer
completion in particular confused me for a long time before I understood
how basic and substring interacted, so having only substring would ease
understanding for new users.

--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 30 Aug 2023 01:32:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 29 21:32:11 2023
Received: from localhost ([127.0.0.1]:51847 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qbA43-0006Uk-4l
	for submit <at> debbugs.gnu.org; Tue, 29 Aug 2023 21:32:11 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:31479)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1qbA3y-0006UA-JX
 for 65137 <at> debbugs.gnu.org; Tue, 29 Aug 2023 21:32:09 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id A9775100106;
 Tue, 29 Aug 2023 21:31:53 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1693359112;
 bh=oG1nFmoWJOQFRC+KQ0fFxdsEqKK9P8pfNfCwnv2lHsY=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=Bjd2W8AaUwZwcGJ3WA/X9Y8qjp6y0P3zmz9kGr16sYzqg2MVF6SJbCoYH35dEtFCz
 qAlQsBXL/6kWM1NCw/gmE8+O9yqelqMmtB6FIugp/WrVqS1oOo8ArXNTO5roy+j4dd
 3ghbWgsamoZ1+X5m30wcO0WlSrm4inewT0uxW1uPEFPOzbHHCMjvWpTbmEwpoxLTzZ
 Us4rxdIf3qtPmiskZ5kS0a6UUlsgk/r2IClDzuOVh9PMxYpXh7AU4voKoadI1yL8lZ
 fb9IuAmeBHU3oQmdPKlgnryr/VgiPyGsLjappYKN3+CdwgLaEzvNwqbvaqd0gIlcMq
 qmGG5AIpGtkRQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 9555710006B;
 Tue, 29 Aug 2023 21:31:52 -0400 (EDT)
Received: from pastel (unknown [45.72.229.156])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 67B55120432;
 Tue, 29 Aug 2023 21:31:52 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: sbaugh@HIDDEN
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <875y5pk8rj.fsf@HIDDEN> (sbaugh@HIDDEN's message of "Tue, 
 08 Aug 2023 12:40:01 +0000 (UTC)")
Message-ID: <jwvh6ohz5jl.fsf-monnier+emacs@HIDDEN>
References: <ierr0oe4esg.fsf@HIDDEN> <83a5v1okwm.fsf@HIDDEN>
 <875y5pk8rj.fsf@HIDDEN>
Date: Tue, 29 Aug 2023 21:31:51 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.170 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65137
Cc: Spencer Baugh <sbaugh@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>   (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
>   -> ("b")

Right this is a bug.

    (completion-pcm--merge-completions '("ab" "sab") '(prefix "b"))

returns (correctly)

    ("b" "a" prefix)

so

    (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))

should return either ("b" "a") or ("b" "a" prefix).

Could you accompany your patch of a regression test using
`completion-pcm--merge-completions` as above?

Similarly, I see that

    (completion-pcm--merge-completions '("abr" "absabr") '(prefix "br"))

returns

    ("br" prefix)

whereas it should arguably return

    ("br" "a" prefix)

[ Tho this may have the side effect that after this completion, `absabr`
  won't be considered any more, if the `basic` completion comes before
  `substring` :-(  ]


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 29 Aug 2023 23:26:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 29 19:26:03 2023
Received: from localhost ([127.0.0.1]:51811 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qb85y-0003MH-M9
	for submit <at> debbugs.gnu.org; Tue, 29 Aug 2023 19:26:03 -0400
Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:57991)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1qb85v-0003Ll-4G
 for 65137 <at> debbugs.gnu.org; Tue, 29 Aug 2023 19:26:00 -0400
Received: from compute3.internal (compute3.nyi.internal [10.202.2.43])
 by mailout.west.internal (Postfix) with ESMTP id 7407F3200939;
 Tue, 29 Aug 2023 19:25:44 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute3.internal (MEProxy); Tue, 29 Aug 2023 19:25:44 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to; s=fm3; t=
 1693351543; x=1693437943; bh=KQ1U11brztIKlL9ugG186IQrc44ceKuNEei
 DvWmpFuI=; b=VejtZOToCl4J3BMMma5aqyuxdLbfJ1mcxiRlUjjMXl07cQC4/xd
 9ebmJrOg90ax7bLqVGD2Y4onnjkpSJUGzXk9HftRI9tdkB7WRk/IDbL8+KXV5Pk3
 NEv2Hp2cro+VZOTNiefI95N9at5VIFWq3v+2XMY9etSfItlcGg9wWvI6gP365IVu
 x8NohI8K6s3P9fYh0ore83krhVMpGcT90XaMicUhNk0mGraW7KQzhLVB/bSZ0A5g
 4UI5fNWKwyYb7WsIZ0OmZD+vyf8WcJI4H91Dh8S23XRtInwQ0q1DPcH3rM9Vs04G
 yPfA9HFpXvjdpxB5ZUmnJhHLu+0wB9F9LbQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to:x-me-proxy
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=
 1693351543; x=1693437943; bh=KQ1U11brztIKlL9ugG186IQrc44ceKuNEei
 DvWmpFuI=; b=l1LKyF+rsDdbcXJdHwn1YevVOH63D46sWrNweWMANlPD+WDIozk
 gw3tj9bpRkBALu4OAxGvTtR51ulatP66nGKQJcE/YVtgujBlMSpC9EEKTLp4Gjtk
 relPHDWgJ4NwSvbOL+qazWtIaEYfsbOlxEjnVeoaJWjuLjRJwfMXMDVOT+A4i2ah
 n63usEcdpYRJNr/TDGNa1b8zOjWA1JB+weKgr9fmSsC2+fXpPJbrdIBeiCCsTdwt
 +JNkJOs94S/NXkwRcFrYUFVdGp0nNYDdGR/fZpvuZBru3Pu3GIYirmMn8BIkD06H
 HSjYZnVXXM+2yRpqJI7/tHJYPLJ7v7hQ/2A==
X-ME-Sender: <xms:d37uZPkmz9e1QrjuQ3dIz_Z8CigWTSG916YZyvyhGYJ39lP2dJl20w>
 <xme:d37uZC1quSMR8QNZx3dN3TmdMggOU1kaNn-HG96wa4iw9LW3SWSuceXqbZpZJ_S-v
 1jycuMzGHESQJBHPzI>
X-ME-Received: <xmr:d37uZFr7MqoQ-ANt_tKYKg63d5hHNA6j-yCPYJrUir0GBgmQy3eUjM1XVEOZFW4>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudefjedgudelucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi
 thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth
 htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel
 vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug
 hmihhtrhihsehguhhtohhvrdguvghv
X-ME-Proxy: <xmx:d37uZHlNY03tii3o2X50t34pz-UsYIyLV9mhUP_7ki49y2OJH06xBQ>
 <xmx:d37uZN12ssDX8-1zSuwaYuJqDNFwWvydp7lCNv195Cbn9YT_paBQzA>
 <xmx:d37uZGvGaR1R5cLHy3c_3hjXocukT-wv4FDz5ykkISOdKtoGrxvJhw>
 <xmx:d37uZO8uvxsdlCX3c2sVge8CRLsxhbNbQuQqpFeTS2mDOzCReZ9X1Q>
Feedback-ID: i0e71465a:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue,
 29 Aug 2023 19:25:42 -0400 (EDT)
Message-ID: <263f9281-67f4-2eea-ef9b-8dfa67740854@HIDDEN>
Date: Wed, 30 Aug 2023 02:25:41 +0300
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
Content-Language: en-US
To: Spencer Baugh <sbaugh@HIDDEN>
References: <ierr0oe4esg.fsf@HIDDEN>
 <665cd10a-17d9-5586-927e-12b2808c0a71@HIDDEN>
 <ierv8cx7sym.fsf@HIDDEN>
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <ierv8cx7sym.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -1.7 (-)
X-Debbugs-Envelope-To: 65137
Cc: 65137 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

On 29/08/2023 18:45, Spencer Baugh wrote:

>> Could you describe the usage scenario a little more?
>>
>>  From my brief testing, the current behavior seems okay most of the
>> time: you still get the short input which matches a bunch of strings
>> (e.g. filenames), you can type a little more chars and narrow down.
>>
>> With your change, TAB will insert the most common prefix for all those
>> completions, which in case of project-file can be a pretty long
>> string. Not a huge problem, but on the face of it that doesn't seem
>> like an improvement. So which scenario would that make better?
> 
> As a very concrete example that I ran into frequently, for
> project-find-file if you have two files:
> 
> dir/foo.ml
> dir/foo.mli
> 
> and you input "foo" and press Tab, you get "foo.ml".  But it is then
> impossible to expand that to dir/foo.ml using completion because of this
> bug.  So you have to manually select dir/foo.ml if you want to visit
> that file, either by switching to *Completions* and selecting it or by
> using minibuffer-next-completion.

Now I understand, thank you. I guess this is something that certain 
environments (such as OCaml) are more prone to than others.

Also this problem seems somewhat unique to the default completion 
mechanism. If I use Ivy, or Helm, or Vertico, or even the "bare" 
icomplete-mode, they all have the notion of the currently selected 
completion, with a short key sequence to choose it.

E.g. with icomplete-mode on I would type until the needed completion is 
highlighted in the minibuffer and then press C-j (maybe press C-, or C-. 
to select it).

The default completion, as you say, has the means to do a similar thing 
with M-<up> and M-<down>, but it's less obvious and requires more 
keypresses.

> After this bugfix, inputting "foo" and pressing Tab will expand to
> "dir/foo.ml".
> 
> In general, this bug makes it impossible to input a file name with
> completion (in project-file) if that file name is a prefix of another
> file name.  Like dir/foo and dir/foo.tar, or dir/foo.log and
> dir/foo.log.bak.

Your patch fixes that by expanding inputs into longer lines after TAB 
(meaning, the user will see their input text shift, sometimes 
considerably, to the right, and perhaps feel a little disoriented). It 
might be a minor thing, but a downside nevertheless.

I do wonder what Stefan thinks what would be the right behavior here.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 29 Aug 2023 15:45:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 29 11:45:53 2023
Received: from localhost ([127.0.0.1]:51401 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qb0ue-00033U-RQ
	for submit <at> debbugs.gnu.org; Tue, 29 Aug 2023 11:45:53 -0400
Received: from mxout6.mail.janestreet.com ([64.215.233.21]:43103)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qb0uc-00033H-MF
 for 65137 <at> debbugs.gnu.org; Tue, 29 Aug 2023 11:45:51 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <665cd10a-17d9-5586-927e-12b2808c0a71@HIDDEN> (Dmitry Gutov's
 message of "Fri, 25 Aug 2023 03:40:43 +0300")
References: <ierr0oe4esg.fsf@HIDDEN>
 <665cd10a-17d9-5586-927e-12b2808c0a71@HIDDEN>
Date: Tue, 29 Aug 2023 11:45:37 -0400
Message-ID: <ierv8cx7sym.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 65137
Cc: 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Dmitry Gutov <dmitry@HIDDEN> writes:
> Hi Spencer!
>
> On 08/08/2023 02:24, Spencer Baugh wrote:
>> However, even this does not work in the project-file and xref-location
>> completion categories, for which the "basic" style is not included in
>> completion-category-defaults.  For such completion categories, there's
>> simply no way to use completion to insert a common prefix.  This is bad,
>> because a filename or identifier might easily be a prefix of another
>> filename or identifier.
>
> Could you describe the usage scenario a little more?
>
> From my brief testing, the current behavior seems okay most of the
> time: you still get the short input which matches a bunch of strings
> (e.g. filenames), you can type a little more chars and narrow down.
>
> With your change, TAB will insert the most common prefix for all those
> completions, which in case of project-file can be a pretty long
> string. Not a huge problem, but on the face of it that doesn't seem
> like an improvement. So which scenario would that make better?

As a very concrete example that I ran into frequently, for
project-find-file if you have two files:

dir/foo.ml
dir/foo.mli

and you input "foo" and press Tab, you get "foo.ml".  But it is then
impossible to expand that to dir/foo.ml using completion because of this
bug.  So you have to manually select dir/foo.ml if you want to visit
that file, either by switching to *Completions* and selecting it or by
using minibuffer-next-completion.

After this bugfix, inputting "foo" and pressing Tab will expand to
"dir/foo.ml".

In general, this bug makes it impossible to input a file name with
completion (in project-file) if that file name is a prefix of another
file name.  Like dir/foo and dir/foo.tar, or dir/foo.log and
dir/foo.log.bak.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 25 Aug 2023 02:30:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 24 22:30:20 2023
Received: from localhost ([127.0.0.1]:38850 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qZMaZ-00050Z-IU
	for submit <at> debbugs.gnu.org; Thu, 24 Aug 2023 22:30:19 -0400
Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:50578)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <drew.adams@HIDDEN>) id 1qZMaW-00050N-P5
 for 65137 <at> debbugs.gnu.org; Thu, 24 Aug 2023 22:30:18 -0400
Received: from pps.filterd (m0246629.ppops.net [127.0.0.1])
 by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
 37P2S6nH020438; Fri, 25 Aug 2023 02:30:11 GMT
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com;
 h=from : to : subject :
 date : message-id : references : in-reply-to : content-type :
 content-transfer-encoding : mime-version; s=corp-2023-03-30;
 bh=qxViv3uLpjCEyO/i9Gn1oc60e8NomY318y6EFRZkzlA=;
 b=BbdRtafLhap6jh/FFtPRtrEQgPle/ehDWSTIRch06QybI3v8+q7K9C9LUtEjEySgr3u1
 +xUuoiXPuXJqtyyiUENDvmerV0YjVYhnmKOB4Huw7Jpgy4LBvARRJ5KjjRiGYIlK3JeE
 ucs37Uac7Z6tuSXm2Oj5R6JF+VW/v3OsARBhrs6fw9DXhn7EdzAOL8QFGOtta97QizFu
 PtEUqGZ+H8OQeipWkzwkIFFDcM9fr6sbT20vl5b09wQg3sB220O4VM7hEuBrN7Y6OA1i
 4dfi/AjCtmPDNF7N/BRvIIabOVxSRLCiHaTZedxZfRtxxQhtZGh+BQMzJgS7MSayJNfg 2w== 
Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com
 (phxpaimrmta01.appoci.oracle.com [138.1.114.2])
 by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sn1yvwea2-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
 Fri, 25 Aug 2023 02:30:10 +0000
Received: from pps.filterd
 (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1])
 by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19)
 with ESMTP id 37P2Dsu3005682; Fri, 25 Aug 2023 02:30:10 GMT
Received: from nam02-dm3-obe.outbound.protection.outlook.com
 (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40])
 by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id
 3sn1yu12yx-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
 Fri, 25 Aug 2023 02:30:10 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=EsJWji7w8tFs10Ma63KGHqDz4MG/KUtMgLLv63wHsXwLZPxz3hr6qd+zzTpCEAiq9O2mIAAQ4pYttGrDLqFAUVsKC58EGG5kH9EnbJPc67W45z9Csc5PwPL7l7neOjrdgBCWMeLilHhWdIo1eVEDHufRn6LFZ41UzccaiGhNsoq6fM208H+JC1+8vRR3npVZnu3VRUJf6Xc6qzqQn1/3IwOfEP5+Paj9hUbQzA2d9DyxdbZXBBUCT2Y2avgGB3zK8/BeNA6OlHulneBpBDvpmBMzIetSsgc16dnGoZ451YMwAW09kRmYiBSDIfK3GJARFbDtA8RmGmHjZLGK1+4djg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=qxViv3uLpjCEyO/i9Gn1oc60e8NomY318y6EFRZkzlA=;
 b=QIqrSlZlCfeDmu0/L4Q49UR4xX638y8WymxYZZsEmefNl7KLnb3iiEfJLrI+Vj6IZsNf5foPnaE1tpq1xlzpZCKa4UqG+sfHrCzuHPuXeukOwBgcsmVHxHR4wFyFzRZtXCwjpVidjXykSdVi1lWQf4MIDMA7J5d9oCHLZ43HPHRBjm4cxJEjN1BhEZ8qTUcpmnGfJfLG5OhE11aerIy4Pt6Gl1hcrU64CSms/mWlIgWJBVjX1XPfCBGZ6WvX8w1hggVP/g7eT7f0mbC86jX5cD7KaL2W+EAaqEEtBbj48/iNtuoB88NdUqNMbh8GWtcL3NAswlWoWUsRIpiBS5ydGw==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com;
 dkim=pass header.d=oracle.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=qxViv3uLpjCEyO/i9Gn1oc60e8NomY318y6EFRZkzlA=;
 b=ubYmDuTqDxkIlk269zj5Hl5Lr5ECm6iVKV3ChiDBDBfLhdjtSWbhqwG4M1NuN7aLwHmP16+l4XCBFGWddkDj6EUpBpcpkkKUn9MQ1oMwWx3ze/pCleeVwFJorw3eSCx0BIRbvHEMPp3ImWxN3hwAu8PNySCHebNQBmegBBXBBAA=
Received: from CO6PR10MB5473.namprd10.prod.outlook.com (2603:10b6:5:355::21)
 by PH0PR10MB7005.namprd10.prod.outlook.com (2603:10b6:510:281::12) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Fri, 25 Aug
 2023 02:30:02 +0000
Received: from CO6PR10MB5473.namprd10.prod.outlook.com
 ([fe80::a261:8fd:40b4:e4cd]) by CO6PR10MB5473.namprd10.prod.outlook.com
 ([fe80::a261:8fd:40b4:e4cd%4]) with mapi id 15.20.6699.027; Fri, 25 Aug 2023
 02:30:02 +0000
From: Drew Adams <drew.adams@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>, Spencer Baugh <sbaugh@HIDDEN>,
 "65137 <at> debbugs.gnu.org" <65137 <at> debbugs.gnu.org>
Subject: RE: [External] : bug#65137: 29.1; completion-substring-try-completion
 doesn't return the longest common substring
Thread-Topic: [External] : bug#65137: 29.1;
 completion-substring-try-completion doesn't return the longest common
 substring
Thread-Index: AQHZ1uzkY3A94q2wzUupELmv6aLCRq/6QJCw
Date: Fri, 25 Aug 2023 02:30:02 +0000
Message-ID: <CO6PR10MB547335C12CDFA83BD46D2085F3E3A@HIDDEN>
References: <ierr0oe4esg.fsf@HIDDEN>
 <665cd10a-17d9-5586-927e-12b2808c0a71@HIDDEN>
In-Reply-To: <665cd10a-17d9-5586-927e-12b2808c0a71@HIDDEN>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: CO6PR10MB5473:EE_|PH0PR10MB7005:EE_
x-ms-office365-filtering-correlation-id: b58a73ad-61d8-4e57-ea3a-08dba5132fa1
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: rzQSThxzR8vdUYQuCiUesoEyIkOGQAwz2wa0WeOMGjght+gEQVafCGBICdeOwz6CAA8PM9sfVuG/5rwI+eFOHDT/H/uYTRMcveCjlQvMq+m94lFN3MQOiM6quaikEwZQrYPVyKaqGi0lO05dcV8BIyJUVNeyJwGXFmJlhgWTNKxTYHRotozROAlNfR0bWDqmdCE4yGobmAppYnITopWWBh6+7Qh4GV9OTo4UMu1gNZWiG5V9VPefYigmaPsjM0gOK9dWn6DGxAldnFzt3eCB7FiKvVfqqk1zz5ArmA6VKYJ6TnPXd3RGyRBUjUG3nrOwRwhtDdfkcEg+lyw/Sgb4awfsYe2FRjWVsJY9SLQ6TXeH1Xz+qEJedy/tGgXFEZRBXZ0PyQaiAHTAg9Imejnz3qc4jwtDfihr4q7E+zP9272sa3fkykmnf2cb0gq47lnYA9ZlleLbA2xFgi8leHs/usnZ+ilsLKf7bzryqTMGs3G3aVwmWJ34UKSMQ/omeBWJGy7Sd8HMtb2BEmOQj2kALPF/8sLBbZPwAQ79QXtwq09C5R+h4w/gSpivQGzSMdn3rTIDfjMYW8b121Kh1CSjk+TioWFwvK+hEQ+cdrM0iVI=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:CO6PR10MB5473.namprd10.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(13230031)(366004)(376002)(39860400002)(396003)(136003)(346002)(186009)(1800799009)(451199024)(52536014)(5660300002)(8676002)(8936002)(33656002)(7696005)(44832011)(55016003)(26005)(71200400001)(38100700002)(38070700005)(122000001)(76116006)(66556008)(66946007)(66476007)(66446008)(64756008)(316002)(110136005)(478600001)(966005)(41300700001)(9686003)(6506007)(2906002)(86362001);
 DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: =?utf-8?B?UENTdDg2NzYwMlp2QzVUbUwwNHl3WUFYSWhORzNTb282SjJxTWpZVDlyVitw?=
 =?utf-8?B?YzZJeWM0bjA2QU5UNlZZU3cxcTVqOFNEcktXbmZxYnlNekJCQU1BOWIrc2Nj?=
 =?utf-8?B?WFRDL0lIbVlGakxmZ2Vpd3ZRbWMrWWlKQzJhTVRCTFZ2S3Y2bGtFbXprQ1NV?=
 =?utf-8?B?S2VzQWJRaEt3YUluUCtpYnNpYXZ0MGZkZ3BlRHRZTEZtODBIMXZKV2FpblJB?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WZ2xNMXNSdk4yWFVxemY1YXFGbGszMS9O?=
 =?utf-8?B?dGZ1REZBQ3FId3VTZmtxNTB5UmZvc2tVdGp0U0kyak42L0lraWUvN29DbHBC?=
 =?utf-8?B?VWdQYUphRjM4MTdkekNyaTFMVnBURkVjTWNQeHp2WU1QeEhkN2QxUUJRbTgr?=
 =?utf-8?Q?T+NA/zrix1NWV2Y9lxCzPrOlq?=
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: PAd/ujq9+7aUkWxeaEseU7T4xGF2ZvL6VpybXMkmOUvGFVHF2GA9wS/r5g/Bo8t2obXUE1HkQqS5ml6nFxWQUINmIn6Z57gKX8rvGULt/dgbGbLkWSYw414qcCXciGAYzx3PqI5+ye5Dw6OHbu7YxpktfaGu3tPrZcLgg1zZFYAikdiZHaVSeN7tZJNqN97Yxt/2Cs8fEa9tR6R1cWe/RnHjJjoJPsdW96JEDUpM4TPCkCSR/s0Ahlx6obqnZDFyhrk9mYXGDOM2MlXmXpNuubEh3ZQbiA3qAAWqpqeOna5Hy8AkNs0g8QDVH5dQsgNkx55KnYMkh+xpiQWDXVJ4UoW7daXPKsPkr2xidQnmYBxjmzvpBJ5+/Pxy7vcEZNHA7NowfsXw0988KBMPJO5BeCh+tHm26k2H7ZDbEqhcsEuM+v0hGguXVNyHhldt6TajsDiSdM4DxJlFo5c+d8sGD+G9RhidyCMpMYNtA8RzyrnUL0Kyq1iXFi9qVDfJGwOgItDYqiJS727sNgAU5NNPMo4TBp1N3fpTJlhshQ1BsTKNQ8Pa264CyMCswbpPhExVVsuKPr2aHlt5y8jZS2WXb6JjCSVSMvDb9CWk4DZlF+vqctlZltl2P+P/IgcWULcpns/jnbdJ75+x/bh268s4vSRTL3oAQSXK4VEVUoTTlPjNtkZf7KE9tQRGl7O3Fui5fIjUi6jxCZzO3Ze36+X+d/Dkb82vxuQAsm515cDg98LOxHFEuYJMjz71h5q0fF5GoiWWdRcjJto7fuNaH5nhKVuHM7nuoVA4rvfFDn/0YOnjzbtVlpm8/DFT/4Lqmi6dpIFW/nuvYCcRYwrNKT/WDA==
X-OriginatorOrg: oracle.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: CO6PR10MB5473.namprd10.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: b58a73ad-61d8-4e57-ea3a-08dba5132fa1
X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Aug 2023 02:30:02.5090 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: 3khllVwwMo9KOhBxwrmUrYl1GNAgYfpEXeY0EtJLMuoOd94RKemOiT+fbahYIu0b8UUfnkxqsymQdllDH2dMSg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR10MB7005
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26
 definitions=2023-08-25_01,2023-08-24_01,2023-05-22_02
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
 bulkscore=0 mlxscore=0
 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0
 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000
 definitions=main-2308250017
X-Proofpoint-ORIG-GUID: 5MZ0lgtga55foKpYcrHUD7GnxSwKfq3I
X-Proofpoint-GUID: 5MZ0lgtga55foKpYcrHUD7GnxSwKfq3I
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 65137
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

PiBXaXRoIHlvdXIgY2hhbmdlLCBUQUIgd2lsbCBpbnNlcnQgdGhlIG1vc3QNCj4gY29tbW9uIHBy
ZWZpeCBmb3IgYWxsIHRob3NlIGNvbXBsZXRpb25zLA0KPiB3aGljaCBpbiBjYXNlIG9mIHByb2pl
Y3QtZmlsZSBjYW4gYmUgYQ0KPiBwcmV0dHkgbG9uZyBzdHJpbmcuICBOb3QgYSBodWdlIHByb2Js
ZW0sDQo+IGJ1dCBvbiB0aGUgZmFjZSBvZiBpdCB0aGF0IGRvZXNuJ3Qgc2VlbQ0KPiBsaWtlIGFu
IGltcHJvdmVtZW50LiANCg0KQ2F2ZWF0OiBOb3QgZm9sbG93aW5nIHRoaXMgdGhyZWFkIGF0IGFs
bC4NClNvIHRoaXMgaXMgbGlrZWx5IHRvIGJlIG9ubHkgbm9pc2U7IHNvcnJ5LA0KaWYgeW91IGZp
bmQgaXQgc28uDQpfX18NCg0KSWYgc29tZSBvZiB0aGUgZGlzY3Vzc2lvbiBoYXMgdG8gZG8gd2l0
aA0KZmluZGluZyBhbmQgc2hvd2luZyB0aGUgbG9uZ2VzdCBjb21tb24NCm1hdGNoIGFjcm9zcyBh
IHNldCBvZiBt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XR0ZXJuIGluIHRoZSBtaW5pYnVmZmVyIGFzDQp3ZWxsLiAgKFlvdSBjYW4gaGl0IGBDLWwn
IHRvIHJldHJpZXZlIHRoZQ0KcGF0dGVybi4pDQoNClNpbmNlIEkgc2F3IHRoYXQgeW91IG1lbnRp
b25lZCB0aGF0IHRoZQ0KY29tbW9uIHBhcnQgY2FuIGJlIGxvbmcsIGFuZCB0aGF0IGNhbg0KZGlz
dHJhY3QgdXNlcnMsIEknbGwgbWVudGlvbiB0b28gdGhhdCBpZg0KeW91IHVzZSBgQy14IC4nIGR1
cmluZyBjb21wbGV0aW9uIHRoYXQNCnRvZ2dsZXMgYW4gb3B0aW9uIHRoYXQgaGlkZXMgKGVsaWRl
cykgdGhlDQpjb21tb24gcGFydC4gIEUuZy4sIGZpbGUtZmluZGluZyBjb21tYW5kcw0KdGhhdCBl
eHBlY3QgYW4gYWJzb2x1dGUgZmlsZSBuYW1lIGNhbg0KdHVybiBvbiBzdWNoIGVsaWRpbmcgdG8g
c3RhcnQgd2l0aC4NCg0KaHR0cHM6Ly93d3cuZW1hY3N3aWtpLm9yZy9lbWFjcy9JY2ljbGVzXy1f
RXhwYW5kZWQtQ29tbW9uLU1hdGNoX0NvbXBsZXRpb24NCg0K




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 25 Aug 2023 00:41:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 24 20:41:00 2023
Received: from localhost ([127.0.0.1]:38834 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qZKsl-000294-Sn
	for submit <at> debbugs.gnu.org; Thu, 24 Aug 2023 20:41:00 -0400
Received: from out2-smtp.messagingengine.com ([66.111.4.26]:47693)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1qZKsj-00028k-3x
 for 65137 <at> debbugs.gnu.org; Thu, 24 Aug 2023 20:40:58 -0400
Received: from compute6.internal (compute6.nyi.internal [10.202.2.47])
 by mailout.nyi.internal (Postfix) with ESMTP id 9A31B5C0294;
 Thu, 24 Aug 2023 20:40:45 -0400 (EDT)
Received: from mailfrontend1 ([10.202.2.162])
 by compute6.internal (MEProxy); Thu, 24 Aug 2023 20:40:45 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :content-transfer-encoding:content-type:content-type:date:date
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to; s=fm3; t=
 1692924045; x=1693010445; bh=ASGWAdo+sa+qwsZCajqgqLPXed2w9h6dKq4
 hFeSAa+c=; b=TwvtiVN/u4o+XHyNJzFAnfUwUS2+CqoxPCPzut0wArwi+L7G1ES
 fHQZXkvyrIjCASghZILheDPqPlbtUr/hKw5xIcqLU/5qI7Spa800jPrwIp3rSZJB
 MEI1QQKsMxMDM+SmNcLvK2O1wJO8GEAPwTJBhtd16l360UaiGhEquVe4h7s2/aQR
 yAorEmTSnIdxnp5VRnfWKvuvz8kUahSufxPmzUZYTaA9ulitSLiRawnhOYnA/L+N
 c6QLKEggXJ0LApPfstcVCy8uv1TZ16TZ4oqosiRlyidbz6IyK/ReGhp93pYAwIEt
 3jVKcwkEHoK8rPWgmdxdpbq7SO3WjscGoYw==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-transfer-encoding:content-type
 :content-type:date:date:feedback-id:feedback-id:from:from
 :in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy
 :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1692924045; x=
 1693010445; bh=ASGWAdo+sa+qwsZCajqgqLPXed2w9h6dKq4hFeSAa+c=; b=E
 j/9FbF6FtbP8lIl2djUMCgOdESizV56m002dnoXb58dzCAu3POxTeZ2jW2hWUMfm
 vhFYmkRncrWnYKZtaP/OWFfsjlAqp52iQokgbN4wlGRq89U1Esb+7VzumHnaiume
 eUzqZyG4JP60xjUnM/lJ1mosDsWEcbqPHkTPW2M/JV5TpEDh3oD16Y3mKC4rd1UM
 IdZk5jjv6nhgdBbXihBm0IX/QaMJA0r0MP0E7n34MqBLAGhnb5zD60LPE1+vLl/n
 wplnxI+ngBfZtvMOPUxm+vuvnrMVQO9Oc1o/cll3ix1Iaengaj4+6EGEEMpzydUY
 +oURVQdvYWlKtOg0X0bsg==
X-ME-Sender: <xms:jfjnZHULRG70fSMmAGueUY-EErCDo_UoGUgE3g7sDQ2qYGT1VK2GjA>
 <xme:jfjnZPkaFmN2rPFYogVK0Oe6qzZCZ0tog_w8EqVzksNNHNEAEM-fHn_QGjAasXiaF
 bsRzQQv2nkS1RQawAY>
X-ME-Received: <xmr:jfjnZDaKkc_Bhzu0zUqi6smPmX5VhgICipW0t8DMW2eKEgOxsyNfJjgg6UOZr4o>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddvjedgfeeiucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhmihht
 rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth
 gvrhhnpeeghedthedujeeiteeutddtjeekheejteeukeehffdutdejuedvfeevueeviedu
 udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh
 hithhrhiesghhuthhovhdruggvvh
X-ME-Proxy: <xmx:jfjnZCXJz6UVldf8njaacsdYI74ZNYABHgoYcDJXR6FthzDifouZPg>
 <xmx:jfjnZBmnjwi6zhFwqhYLVpOmHCpy0VqWLlmSksk565uvZCBzJdIrAg>
 <xmx:jfjnZPc3Pe_103vhggHimrFHUO9NPlScDfR0VBh8uxHVhc47SNcPtA>
 <xmx:jfjnZAt4tdJZXpvS3cpp95Cs6HphtDRcU4-AJ7laIawfaL9-oQS-GQ>
Feedback-ID: i0e71465a:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
 24 Aug 2023 20:40:44 -0400 (EDT)
Message-ID: <665cd10a-17d9-5586-927e-12b2808c0a71@HIDDEN>
Date: Fri, 25 Aug 2023 03:40:43 +0300
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
Content-Language: en-US
To: Spencer Baugh <sbaugh@HIDDEN>, 65137 <at> debbugs.gnu.org
References: <ierr0oe4esg.fsf@HIDDEN>
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <ierr0oe4esg.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -1.7 (-)
X-Debbugs-Envelope-To: 65137
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

Hi Spencer!

On 08/08/2023 02:24, Spencer Baugh wrote:
> However, even this does not work in the project-file and xref-location
> completion categories, for which the "basic" style is not included in
> completion-category-defaults.  For such completion categories, there's
> simply no way to use completion to insert a common prefix.  This is bad,
> because a filename or identifier might easily be a prefix of another
> filename or identifier.

Could you describe the usage scenario a little more?

 From my brief testing, the current behavior seems okay most of the 
time: you still get the short input which matches a bunch of strings 
(e.g. filenames), you can type a little more chars and narrow down.

With your change, TAB will insert the most common prefix for all those 
completions, which in case of project-file can be a pretty long string. 
Not a huge problem, but on the face of it that doesn't seem like an 
improvement. So which scenario would that make better?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 8 Aug 2023 12:40:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 08 08:40:09 2023
Received: from localhost ([127.0.0.1]:35487 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qTM0O-0007Lu-QB
	for submit <at> debbugs.gnu.org; Tue, 08 Aug 2023 08:40:09 -0400
Received: from s.wrqvwxzv.outbound-mail.sendgrid.net ([149.72.154.232]:12222)
 by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from
 <bounces+21787432-c0fa-65137=debbugs.gnu.org@HIDDEN>)
 id 1qTM0M-0007LL-Ul
 for 65137 <at> debbugs.gnu.org; Tue, 08 Aug 2023 08:40:07 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com;
 h=from:subject:in-reply-to:references:mime-version:to:cc:content-type:
 cc:content-type:from:subject:to;
 s=s1; bh=ZwIFR48YET0vxH4lTSdnWqtXXBGJxdmoxbdxPy5AaYw=;
 b=R6M9emzXJezgBrBVfCh3gnPw9pmD9fWFLijpKgZhk9IH4L6ixbUlOm5o3zw5Y2deleFS
 YwsAB3e9wArOc85bQ17j/uSFO7j06uHB9JGy00cLCSLCRvRr6yVOaAhfIy6TdilRj6+4cv
 co6MJnnEl9M4cxShYFjOgAw0KspdeIHYT4P38D51P8pQhws7aWDSlH5GWFdIzGJ2QbK0I5
 MD0sxlJF3PAQLAE18Rh8CiGUwgEgGPv1qvjFCHHrMsFcLlf1vekGmovQluICf9QN2nYNeg
 ENvxq34n/mEr8ZNzh7VFot2JAjZLocBlg7xSkehWMWqgSSOwHWPUBIR5V5Qf7vog==
Received: by filterdrecv-d7bbbc8bf-5tzkl with SMTP id
 filterdrecv-d7bbbc8bf-5tzkl-1-64D237A1-3
 2023-08-08 12:40:01.230615167 +0000 UTC m=+1517970.612753905
Received: from earth.catern.com (unknown) by geopod-ismtpd-15 (SG) with ESMTP
 id hKdtv99BRqOFW27OGeIWJA Tue, 08 Aug 2023 12:40:01.149 +0000 (UTC)
X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost;
 envelope-from=sbaugh@HIDDEN; receiver=gnu.org 
Received: from localhost (localhost [IPv6:::1])
 by earth.catern.com (Postfix) with ESMTPSA id B2C6F60080;
 Tue,  8 Aug 2023 08:40:00 -0400 (EDT)
From: sbaugh@HIDDEN
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <83a5v1okwm.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 08 Aug
 2023 14:04:09 +0300")
References: <ierr0oe4esg.fsf@HIDDEN> <83a5v1okwm.fsf@HIDDEN>
Date: Tue, 08 Aug 2023 12:40:01 +0000 (UTC)
Message-ID: <875y5pk8rj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbK9GmGdCsIOC1DpypswWW?=
 =?us-ascii?Q?hsnMTsSJMIV7AwwV9E2jzsmrOjd0ZdQyF7L50d6?=
 =?us-ascii?Q?flRF92+Vc7jyMKK1gcntx2J3oc2knX9kGoFEeny?=
 =?us-ascii?Q?q4NjqkHY2qF2goz1ruI6hfsv8X2pRnFqnDMS1++?=
 =?us-ascii?Q?DE+iFbmueWejZre0ykOKbD4DQMAOhNDeYZA=3D=3D?=
To: Eli Zaretskii <eliz@HIDDEN>
X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q==
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 65137
Cc: Spencer Baugh <sbaugh@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>, 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Eli Zaretskii <eliz@HIDDEN> writes:
>> From: Spencer Baugh <sbaugh@HIDDEN>
>> Date: Mon, 07 Aug 2023 19:24:15 -0400
>> 
>> 
>> The substring completion style differs from the "basic" style by
>> performing completion at the start of the input string.  So for example,
>> both of these are valid completions for "bar":
>> 
>> (completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
>> -> ("foobarbaz" "foobar" . 0)
>> 
>> However, the substring completion style's try-completion implementation
>> does not reflect this.  Since "foobar" is a prefix of all the valid
>> completions, it should be returned by try-completion.  But it is not,
>> regardless of the location of point:
>> 
>> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
>> -> ("bar" . 3)
>> 
>> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
>> -> ("bar" . 3)
>> 
>> This breaks completion when one completion candidate is a prefix of
>> other completion candidates.  The recourse is moving point to the start
>> of the input, so that the "basic" completion style takes over, which
>> will correctly insert the common prefix:
>> 
>> (completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
>> -> ("foobar" . 6)
>> 
>> However, even this does not work in the project-file and xref-location
>> completion categories, for which the "basic" style is not included in
>> completion-category-defaults.  For such completion categories, there's
>> simply no way to use completion to insert a common prefix.  This is bad,
>> because a filename or identifier might easily be a prefix of another
>> filename or identifier.
>> 
>> The solution is completion-substring-try-completion to be fixed to
>> insert these common prefixes.  I'll try and fix this, although the code
>> is a bit intimidating.
>
> Adding Stefan, in case he has some comments or ideas.

See also (v2 of) my patch.  Now a one-line change, much simpler than my
earlier patch:


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Correctly-handle-common-prefixes-in-substring-comple.patch

From 48627fdedf44aa48f235c4c550318d0ad2500c16 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Tue, 8 Aug 2023 08:37:49 -0400
Subject: [PATCH] Correctly handle common prefixes in substring completion

substring completion is implemented by passing the `prefix' symbol as
part of the pattern passed to completion-pcm--merge-completions.  This
symbol is supposed to "grow" the completion only as a suffix, not as a
prefix.

The old behavior of completion-pcm--merge-completions when processing
a `prefix' element in the pattern was to find the common prefix of all
the completions in that part of the pattern (using try-completion) and
then completely discard that common prefix.  Then the actual logic for
`prefix' would run with completion--common-suffix.

However, the completion--common-suffix logic would be skipped when the
prefix covers the entirety of this part of the pattern.  (When
"unique" is non-nil, in the code).  For example, in this call:

  (completion-pcm--merge-completions '("ab" "ab") '(star "b"))
  -> ("b" "a")

there is no need to calculate a common suffix of '("a" "a") after
finding the common prefix "a".  (Note the return value is in reverse
order.)

But for `prefix', we discard the common prefix, so this behavior would
result in us skipping the calculation of both common prefix and common
suffix.  Like in this call:

  (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
  -> ("b")

The correct behavior is to include the common prefix even for `prefix'
elements if it covers the entirety of this part of the pattern,
because then it is then also a common suffix.  Then we get:

  (completion-pcm--merge-completions '("ab" "ab") '(prefix "b"))
  -> ("b" "a")

which is correct.

* lisp/minibuffer.el (completion-pcm--merge-completions): Don't ignore
a common suffix in a `prefix' pattern element when there's also a
common prefix.
---
 lisp/minibuffer.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 186a4753df1..cc50427b5bd 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4029,7 +4029,9 @@ completion-pcm--merge-completions
                      (unique (or (and (eq prefix t) (setq prefix fixed))
                                  (and (stringp prefix)
                                       (eq t (try-completion prefix comps))))))
-                (unless (or (eq elem 'prefix)
+                ;; if the common prefix is unique, it also is a common
+                ;; suffix, so we should add it for `prefix' elements
+                (unless (or (and (eq elem 'prefix) (not unique))
                             (equal prefix ""))
                   (push prefix res))
                 ;; If there's only one completion, `elem' is not useful
-- 
2.41.0


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 8 Aug 2023 11:03:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 08 07:03:57 2023
Received: from localhost ([127.0.0.1]:35345 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qTKVI-0007lR-Ia
	for submit <at> debbugs.gnu.org; Tue, 08 Aug 2023 07:03:56 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:42924)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1qTKVG-0007lE-In
 for 65137 <at> debbugs.gnu.org; Tue, 08 Aug 2023 07:03:55 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qTKVA-0004Yq-TX; Tue, 08 Aug 2023 07:03:48 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=xurk2vtUEMSDHuAfnrN6nTr2Orqg1mIJnUg7CXS0E2Q=; b=oiD+eu4RCojg
 nsLIR9QENDf1QEepUfzUC4OG2zyinBUyI9BFwXC6JwcbFt/eaxz4yLE/hQwoMb3aNJva78ZQ+k0fF
 4uO0wv2Xidox9gS2aRYf+LGnuOAsitCkW2oIM+hAsLDJFH+g7BGrhV7V1hRAy8lbUCyySjSwrdZJG
 73kGJ4mV+2fXRWZJtwdPVg0mFBGaEdIdWihXY0bWkqcz7O4ildwPpoaIrQrQbxDf8pu1h1ChTcyRV
 cGgGIVBDvJrKnObnqu2dT3eXmjg0CA3h0Ua4tMshoolscgLazBuEll9XV8GrdptPXx5nyqtY54iii
 3mi4Xu144f3aRJWMtVlWLg==;
Date: Tue, 08 Aug 2023 14:04:09 +0300
Message-Id: <83a5v1okwm.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Spencer Baugh <sbaugh@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <ierr0oe4esg.fsf@HIDDEN> (message from Spencer Baugh on
 Mon, 07 Aug 2023 19:24:15 -0400)
Subject: Re: bug#65137: 29.1;
 completion-substring-try-completion doesn't return the longest common
 substring
References: <ierr0oe4esg.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65137
Cc: 65137 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Spencer Baugh <sbaugh@HIDDEN>
> Date: Mon, 07 Aug 2023 19:24:15 -0400
> 
> 
> The substring completion style differs from the "basic" style by
> performing completion at the start of the input string.  So for example,
> both of these are valid completions for "bar":
> 
> (completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
> -> ("foobarbaz" "foobar" . 0)
> 
> However, the substring completion style's try-completion implementation
> does not reflect this.  Since "foobar" is a prefix of all the valid
> completions, it should be returned by try-completion.  But it is not,
> regardless of the location of point:
> 
> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
> -> ("bar" . 3)
> 
> (completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
> -> ("bar" . 3)
> 
> This breaks completion when one completion candidate is a prefix of
> other completion candidates.  The recourse is moving point to the start
> of the input, so that the "basic" completion style takes over, which
> will correctly insert the common prefix:
> 
> (completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
> -> ("foobar" . 6)
> 
> However, even this does not work in the project-file and xref-location
> completion categories, for which the "basic" style is not included in
> completion-category-defaults.  For such completion categories, there's
> simply no way to use completion to insert a common prefix.  This is bad,
> because a filename or identifier might easily be a prefix of another
> filename or identifier.
> 
> The solution is completion-substring-try-completion to be fixed to
> insert these common prefixes.  I'll try and fix this, although the code
> is a bit intimidating.

Adding Stefan, in case he has some comments or ideas.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 8 Aug 2023 00:41:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 07 20:41:24 2023
Received: from localhost ([127.0.0.1]:34567 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qTAmp-0007Ed-Pq
	for submit <at> debbugs.gnu.org; Mon, 07 Aug 2023 20:41:24 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:35605)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qTAmk-0007EL-Ds
 for 65137 <at> debbugs.gnu.org; Mon, 07 Aug 2023 20:41:21 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: 65137 <at> debbugs.gnu.org
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <iermsz24dlj.fsf@HIDDEN> (Spencer Baugh's message of
 "Mon, 07 Aug 2023 19:50:00 -0400")
References: <ierr0oe4esg.fsf@HIDDEN> <iermsz24dlj.fsf@HIDDEN>
Date: Mon, 07 Aug 2023 20:41:12 -0400
Message-ID: <ieril9q4b87.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -1.0 (-)
X-Debbugs-Envelope-To: 65137
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.0 (--)

--=-=-=
Content-Type: text/plain


Here's a patch fixing this.  It's definitely just a bug in the
implementation of completion-pcm--merge-completions - see my commit
message for details.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Correctly-handle-common-prefixes-in-substring-comple.patch

From ea63217c1c85f1ca4f1f22b9c4781167de6cf00d Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@HIDDEN>
Date: Mon, 7 Aug 2023 20:20:34 -0400
Subject: [PATCH] Correctly handle common prefixes in substring completion

substring completion is implemented by passing the `prefix' symbol as
part of the pattern passed to completion-pcm--merge-completions.  This
symbol is supposed to "grow" the completion only as a suffix, not as a
prefix.

The old behavior of completion-pcm--merge-completions when processing
a `prefix' element in the pattern was to find the common prefix of all
the completions in that part of the pattern (using try-completion) and
then completely discard that common prefix.  Then the actual logic for
`prefix' would run with completion--common-suffix.

However, if all the completion candidates had a common prefix while
processing a `prefix' element, then it would both discard the common
prefix *and* skip the completion--common-suffix logic.  If there was
also a common suffix, e.g. with the following invocation:

  (completion-pcm--merge-completions '("axbc" "aybc") '(prefix "c"))

then this would produce the wrong result by ignoring the common suffix
"b".

The new behavior is to simply not bother generating the common prefix
for `prefix' elements, since we don't use it anyway, and just pretend
it's always empty for `prefix' elements.  Then the
completion--common-suffix logic always runs.

* lisp/minibuffer.el (completion-pcm--merge-completions): Don't ignore
a common suffix in a `prefix' pattern element when there's also a
common prefix.
---
 lisp/minibuffer.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index d2c7e66d2a0..1aa29318bd2 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -4029,12 +4029,15 @@ completion-pcm--merge-completions
               ;; different capitalizations in different parts.
               ;; In practice, it doesn't seem to make any difference.
               (setq ccs (nreverse ccs))
-              (let* ((prefix (try-completion fixed comps))
+              (let* ((prefix
+                      ;; We pretend as if there's no common prefix at all for
+                      ;; `prefix', so we go to completion--common-suffix
+                      (if (eq elem 'prefix) "" (try-completion fixed comps)))
                      (unique (or (and (eq prefix t) (setq prefix fixed))
                                  (and (stringp prefix)
+                                      (not (string-empty-p prefix))
                                       (eq t (try-completion prefix comps))))))
-                (unless (or (eq elem 'prefix)
-                            (equal prefix ""))
+                (unless (equal prefix "")
                   (push prefix res))
                 ;; If there's only one completion, `elem' is not useful
                 ;; any more: it can only match the empty string.
-- 
2.39.3


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at 65137 <at> debbugs.gnu.org:


Received: (at 65137) by debbugs.gnu.org; 7 Aug 2023 23:50:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 07 19:50:08 2023
Received: from localhost ([127.0.0.1]:34561 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qT9zE-00063o-Cf
	for submit <at> debbugs.gnu.org; Mon, 07 Aug 2023 19:50:08 -0400
Received: from mxout1.mail.janestreet.com ([38.105.200.78]:44445)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qT9zC-00063C-D2
 for 65137 <at> debbugs.gnu.org; Mon, 07 Aug 2023 19:50:06 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: 65137 <at> debbugs.gnu.org
Subject: Re: bug#65137: 29.1; completion-substring-try-completion doesn't
 return the longest common substring
In-Reply-To: <ierr0oe4esg.fsf@HIDDEN> (Spencer Baugh's message of
 "Mon, 07 Aug 2023 19:24:15 -0400")
References: <ierr0oe4esg.fsf@HIDDEN>
Date: Mon, 07 Aug 2023 19:50:00 -0400
Message-ID: <iermsz24dlj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 65137
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


I've tracked it down further to:

(completion-pcm--merge-completions
 '("ab1" "ab2")
 '(prefix "b"))
-> (any "b")

which definitely doesn't match the docstring of
completion-pcm--merge-completions...  (note that it returns elements in
reverse order, so this is basically just returning the string "b")




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 7 Aug 2023 23:24:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 07 19:24:31 2023
Received: from localhost ([127.0.0.1]:34534 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qT9aR-0005LU-FL
	for submit <at> debbugs.gnu.org; Mon, 07 Aug 2023 19:24:31 -0400
Received: from lists.gnu.org ([2001:470:142::17]:54684)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <sbaugh@HIDDEN>) id 1qT9aN-0005LE-DK
 for submit <at> debbugs.gnu.org; Mon, 07 Aug 2023 19:24:30 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1qT9aG-00017u-6T
 for bug-gnu-emacs@HIDDEN; Mon, 07 Aug 2023 19:24:20 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>)
 id 1qT9aD-0004p5-8L
 for bug-gnu-emacs@HIDDEN; Mon, 07 Aug 2023 19:24:19 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 29.1; completion-substring-try-completion doesn't return the
 longest common substring
Date: Mon, 07 Aug 2023 19:24:15 -0400
Message-ID: <ierr0oe4esg.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN;
 helo=mxout5.mail.janestreet.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001,
 RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)


The substring completion style differs from the "basic" style by
performing completion at the start of the input string.  So for example,
both of these are valid completions for "bar":

(completion-substring-all-completions "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
-> ("foobarbaz" "foobar" . 0)

However, the substring completion style's try-completion implementation
does not reflect this.  Since "foobar" is a prefix of all the valid
completions, it should be returned by try-completion.  But it is not,
regardless of the location of point:

(completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
-> ("bar" . 3)

(completion-substring-try-completion "bar" '("foobar" "foobarbaz") #'identity (length "bar"))
-> ("bar" . 3)

This breaks completion when one completion candidate is a prefix of
other completion candidates.  The recourse is moving point to the start
of the input, so that the "basic" completion style takes over, which
will correctly insert the common prefix:

(completion-basic-try-completion "bar" '("foobar" "foobarbaz") #'identity 0)
-> ("foobar" . 6)

However, even this does not work in the project-file and xref-location
completion categories, for which the "basic" style is not included in
completion-category-defaults.  For such completion categories, there's
simply no way to use completion to insert a common prefix.  This is bad,
because a filename or identifier might easily be a prefix of another
filename or identifier.

The solution is completion-substring-try-completion to be fixed to
insert these common prefixes.  I'll try and fix this, although the code
is a bit intimidating.



In GNU Emacs 29.1 (build 3, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-07-29 built on

Repository revision: cf24c7ac7608f41078fd2761c856892d5853b676
Repository branch: my-emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.8 (Green Obsidian)

Configured using:
 'configure --config-cache --with-x-toolkit=lucid
 --with-gif=ifavailable'

Configured features:
CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM
XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Memory information:
((conses 16 1210667 128287)
 (symbols 48 75558 3)
 (strings 32 305623 26170)
 (string-bytes 1 9620792)
 (vectors 16 125723)
 (vector-slots 8 2816397 195041)
 (floats 8 762 279)
 (intervals 56 32710 336)
 (buffers 976 120))




Acknowledgement sent to Spencer Baugh <sbaugh@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#65137; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 6 Sep 2023 11:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.