GNU bug report logs - #81411
31.0.90; Selecting completion for completing-read-multiple does not respect completion boundaries

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: Aaron Zeng <azeng@HIDDEN>; dated Tue, 14 Jul 2026 18:55:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 81411) by debbugs.gnu.org; 6 Aug 2026 15:13:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 06 11:13:46 2026
Received: from localhost ([127.0.0.1]:36161 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wrzn0-0001P0-71
	for submit <at> debbugs.gnu.org; Thu, 06 Aug 2026 11:13:46 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:49315)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>)
 id 1wrzmx-0001OW-HK
 for 81411 <at> debbugs.gnu.org; Thu, 06 Aug 2026 11:13:44 -0400
From: Spencer Baugh <sbaugh@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>, Aaron Zeng <azeng@HIDDEN>, Stefan
 Monnier <monnier@HIDDEN>
Subject: Re: bug#81411: 31.0.90; Selecting completion for
 completing-read-multiple does not respect completion boundaries
In-Reply-To: <86wlu6ce2l.fsf@HIDDEN>
References: <q7mo6g9wgfk.fsf@HIDDEN>
 <q7mv79qkhty.fsf@HIDDEN> <86wlu6ce2l.fsf@HIDDEN>
Date: Thu, 06 Aug 2026 11:13:37 -0400
Message-ID: <ierse4r5ljy.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1786029218;
 bh=muYjr6qRAam+GF+eiB3QLmgD2sreFDXIBDrnGNnMLNk=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date;
 b=ZGIL6n0sYTRWEL2V8YErHdR58DIjAPsCFLe6sjtjaMvtJAJ8Gf30pexdts6yx7emv
 MaoWKCg1l3DCqbsawOPY/IlFAbeLlWkmM8lS+Q8d6itoP29xED0qlP79ZOYieJ+8ic
 02APzI4lW7ujBAa6Xk+y6lUOxaX2Qc0RWqPuSzCAZc2u3sxMyEUBI+mQCl+NUTi3wP
 4AY5xKIpFrAXCmkFgnPBgAO/d7DkG2BUVu0IavbpVBAMa1hKCbCtgEebvopgbVdq0a
 LVtyhy33ikGu8/7+NgWVWTdC6ibxV/DIR2rJSK+m6/TNVjlU/kThPKNDRQVYBJ5G7p
 ABATbGrSnpPLA==
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 81411
Cc: 81411 <at> debbugs.gnu.org, app-emacs-dev@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: -6.0 (------)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Cc: app-emacs-dev@HIDDEN
>> Date: Mon, 03 Aug 2026 17:35:53 -0400
>> From: Aaron Zeng via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
>> 
>> I spent some time staring at this and ended up coming up with a patch.
>> I noticed a separate issue where the existing code was not finding the
>> boundaries of the element correctly (if crm-separator matches more
>> than one character), so the first patch changes it to use the
>> crm--completion-command helper to come up with the boundaries.
>> 
>> The second patch fixes the initial reported bug.  Within the
>> boundaries of the element, it now calls completion-boundaries to get
>> the new boundaries of the part of that element to be completed.
>> 
>> On my machine, I tested that it fixes my initial reproduction example
>> as well as the downstream issue I noticed in my site's extensions, but
>> would appreciate any additional feedback and testing.
>
> Thanks.  Spencer and Stefan, any comments to the patch?

It looks right to me.  It would be nice if it came with a test though.




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

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


Received: (at 81411) by debbugs.gnu.org; 4 Aug 2026 11:36:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Aug 04 07:36:47 2026
Received: from localhost ([127.0.0.1]:37591 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wrDRt-0003wd-9U
	for submit <at> debbugs.gnu.org; Tue, 04 Aug 2026 07:36:47 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:54726)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wrDRq-0003w2-Ut
 for 81411 <at> debbugs.gnu.org; Tue, 04 Aug 2026 07:36:43 -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 1wrDRl-00046t-5S; Tue, 04 Aug 2026 07:36:37 -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=SEYF5hbDVcX5jb7vvzwnqF/w/oR+EXXmqS+AqsAvCTk=; b=E2N3sA/e0b0c
 ubu9v0OZiV/MgKVqO0YWbGbCFHdiZuV/d/GrmNWbgRQjinoyVA9+fKclMiolsrbviM7xp6vXWEOf9
 nBn/gYtvmnwtPX8VjPh9wmxA3fVateTNisqx9kMv8qusdT9AxxC7qsfjFe5Vp42rR1mp9KeMafcwM
 MHqZn9uD3Ai2qHX+Dlizl351pN+V9NrAMQCAvvm4RkK8u8V8UbwIkvNCE84M7tfKB9SZw2aLBmagN
 1Lh0h9WQPQoOTkiV6zh6AjbWX8uSPNHj0yGmFQT4n9Bd0HAEC01NIbztleHD3+LaG9OWIqyR8f0aw
 JdoR/ZBl1rDdRc3f+cbu0w==;
Date: Tue, 04 Aug 2026 14:36:34 +0300
Message-Id: <86wlu6ce2l.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Aaron Zeng <azeng@HIDDEN>, Spencer Baugh <sbaugh@HIDDEN>, 
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <q7mv79qkhty.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#81411: 31.0.90;
 Selecting completion for completing-read-multiple does not respect
 completion boundaries
References: <q7mo6g9wgfk.fsf@HIDDEN> <q7mv79qkhty.fsf@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 81411
Cc: 81411 <at> debbugs.gnu.org, app-emacs-dev@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: -1.7 (-)

> Cc: app-emacs-dev@HIDDEN
> Date: Mon, 03 Aug 2026 17:35:53 -0400
> From: Aaron Zeng via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> I spent some time staring at this and ended up coming up with a patch.
> I noticed a separate issue where the existing code was not finding the
> boundaries of the element correctly (if crm-separator matches more
> than one character), so the first patch changes it to use the
> crm--completion-command helper to come up with the boundaries.
> 
> The second patch fixes the initial reported bug.  Within the
> boundaries of the element, it now calls completion-boundaries to get
> the new boundaries of the part of that element to be completed.
> 
> On my machine, I tested that it fixes my initial reproduction example
> as well as the downstream issue I noticed in my site's extensions, but
> would appreciate any additional feedback and testing.

Thanks.  Spencer and Stefan, any comments to the patch?




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

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


Received: (at 81411) by debbugs.gnu.org; 3 Aug 2026 21:36:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Aug 03 17:36:03 2026
Received: from localhost ([127.0.0.1]:59955 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wr0KI-0004MW-FM
	for submit <at> debbugs.gnu.org; Mon, 03 Aug 2026 17:36:03 -0400
Received: from mxout5.mail.janestreet.com ([64.215.233.18]:49267)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <azeng@HIDDEN>)
 id 1wr0KF-0004Lw-CO
 for 81411 <at> debbugs.gnu.org; Mon, 03 Aug 2026 17:36:01 -0400
From: Aaron Zeng <azeng@HIDDEN>
To: 81411 <at> debbugs.gnu.org
Subject: Re: bug#81411: 31.0.90; Selecting completion for
 completing-read-multiple does not respect completion boundaries
X-Debbugs-Cc: app-emacs-dev@HIDDEN
Date: Mon, 03 Aug 2026 17:35:53 -0400
Message-ID: <q7mv79qkhty.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1785792953;
 bh=8HSwu4aw6EP/bqJW4fc2n1EjvOQwD1bd0JyL/PplQ5Q=;
 h=From:To:Subject:Date;
 b=K+8jZ47Os0moda+ePVW+vCWSyMWpPbufUIHw2RYtD6hjv1ETl8rVs0PPGvhUaiIIm
 nLl7P/08t4FHy9GQvugNbOpgmu9nuzdv4o5YcPPt27xmCZKr4LbWvh59Oy1C6TUFrp
 fDG8ioorSljpoSRCWy1D0wRAOP+3DgETts9UaNCxnm2c/s7unBtTEPa3CSa0TlpryJ
 rEGyXRNn5JL7oY3C31usWYswz/Hi0CuZNiH1CmKAWTm6qIQRK+8/8KVKCMMoKNbcxj
 jsv2yrtiOoSFg5iDpLpkMuTWSWuc0zl5ChC2HfFjwNtkISTPT+h8aDrVXMCaZWiqsc
 wc8wtdERJmgMw==
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 81411
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: -7.0 (-------)

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

Tags: patch

I spent some time staring at this and ended up coming up with a patch.
I noticed a separate issue where the existing code was not finding the
boundaries of the element correctly (if crm-separator matches more
than one character), so the first patch changes it to use the
crm--completion-command helper to come up with the boundaries.

The second patch fixes the initial reported bug.  Within the
boundaries of the element, it now calls completion-boundaries to get
the new boundaries of the part of that element to be completed.

On my machine, I tested that it fixes my initial reproduction example
as well as the downstream issue I noticed in my site's extensions, but
would appreciate any additional feedback and testing.

Thanks,
Aaron

In GNU Emacs 31.0.91 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2026-07-29 built on
 vdc-qws-i40813a
Repository revision: 112645541ac2e8781080e722ba6756227606160c
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --with-x-toolkit=lucid --without-gpm --without-gconf
 --without-selinux --without-imagemagick --with-modules --with-gif=no
 --with-cairo --with-rsvg --without-compress-install
 --with-tree-sitter --with-native-compilation=aot
 --prefix=/usr/local/home/garnish/raw-emacs/31-20260729_110947'


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0001-Fix-completing-read-multiple-when-separators-are-lon.patch

From 5f5213e17da34760da735397f0ff3dcf7ae6f4c1 Mon Sep 17 00:00:00 2001
From: "Aaron L. Zeng" <azeng@HIDDEN>
Date: Tue, 21 Jul 2026 13:56:50 -0400
Subject: [PATCH 1/2] Fix completing-read-multiple when separators are longer
 than 1 char

* lisp/emacs-lisp/crm.el (completing-read-multiple): Use
crm--completion-command to determine element boundaries.
---
 lisp/emacs-lisp/crm.el | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index b68d3d55525..9be7913a954 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -263,16 +263,7 @@ completing-read-multiple
                     'crm--choose-completion-string nil 'local)
           (setq-local completion-list-insert-choice-function
                       (lambda (_start _end choice)
-                        (let* ((beg (save-excursion
-                                      (if (search-backward-regexp crm-separator
-                                                                  (field-beginning)
-                                                                  t)
-                                          (1+ (point))
-                                        (minibuffer-prompt-end))))
-                               (end (save-excursion
-                                      (if (search-forward-regexp crm-separator nil t)
-                                          (1- (point))
-                                        (point-max)))))
+                        (crm--completion-command beg end
                           (completion--replace beg end choice))))
           (setq-local crm-completion-table table)
           (use-local-map map))
-- 
2.43.7


--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment;
 filename=0002-Fix-choose-completion-in-CRM-with-boundaries.patch

From 16ae3cd8b28015e5baa8c8d0774e134c2ae4aaaf Mon Sep 17 00:00:00 2001
From: "Aaron L. Zeng" <azeng@HIDDEN>
Date: Tue, 21 Jul 2026 14:02:33 -0400
Subject: [PATCH 2/2] Fix choose-completion in CRM with boundaries

* lisp/emacs-lisp/crm.el (completing-read-multiple): Respect
completion boundaries when inserting a choice.
---
 lisp/emacs-lisp/crm.el | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index 9be7913a954..e46570d1a47 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -263,8 +263,19 @@ completing-read-multiple
                     'crm--choose-completion-string nil 'local)
           (setq-local completion-list-insert-choice-function
                       (lambda (_start _end choice)
+                        ;; Respect the boundaries of the current
+                        ;; element, and within that, any boundaries
+                        ;; specified by the completion table
+                        ;; (bug#81411).
                         (crm--completion-command beg end
-                          (completion--replace beg end choice))))
+                          (let ((bounds (completion-boundaries
+                                         (buffer-substring beg (point))
+                                         crm-completion-table
+                                         minibuffer-completion-predicate
+                                         (buffer-substring (point) end))))
+                            (completion--replace (+ beg (car bounds))
+                                                 (+ (point) (cdr bounds))
+                                                 choice)))))
           (setq-local crm-completion-table table)
           (use-local-map map))
       (setq input (completing-read
-- 
2.43.7


--=-=-=--




Information forwarded to app-emacs-dev@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#81411; Package emacs. Full text available.

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


Received: (at 81411) by debbugs.gnu.org; 1 Aug 2026 08:34:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 01 04:34:41 2026
Received: from localhost ([127.0.0.1]:51134 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wq5B2-0007IR-3r
	for submit <at> debbugs.gnu.org; Sat, 01 Aug 2026 04:34:41 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:48260)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1wq5Ay-0007Hw-Hq
 for 81411 <at> debbugs.gnu.org; Sat, 01 Aug 2026 04:34:38 -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 1wq5As-0000ZO-DE; Sat, 01 Aug 2026 04:34:30 -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=+useQ6qSmzLOiSLNDMmdIXbX7lwkdGjRV+kVTaf3BIc=; b=FFswvvPECuUG
 S0NSymJ6eSvF/8e+LlF/N2uKfUO4w7RacmmRkivetVBrybs+yLsH8Ev/kglhqWgSWLfwOvJIjkdpf
 U2no2Fbya+3ReaU8BiB5+6bXNWULOPA20y0CylMYlfPfSrIsf4MqKaEb2HH5vZsiZkWE8vMboYksN
 PxqCHAZiIdGLR8XhxF0rJuNSYrWAslXJVOWvh+2u0gz1XYa95iMhPlojHi7Pl6LZ4qQ/WtVnG+6AV
 nEKudGuVcM9VisaWOLK5jtpz8CRXyNR4O4uIYgco1awKGWEr0IZHSrgYt+yRBhflJ4lc4LM3X39hk
 lrYi/+6pdm35dpRQrI+L2Q==;
Date: Sat, 01 Aug 2026 11:34:25 +0300
Message-Id: <86ldaqi6i6.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Aaron Zeng <azeng@HIDDEN>, Spencer Baugh <sbaugh@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <q7mo6g9wgfk.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#81411: 31.0.90;
 Selecting completion for completing-read-multiple does not respect
 completion boundaries
References: <q7mo6g9wgfk.fsf@HIDDEN>
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 81411
Cc: 81411 <at> debbugs.gnu.org, app-emacs-dev@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: -1.7 (-)

> Cc: app-emacs-dev@HIDDEN
> Date: Tue, 14 Jul 2026 14:54:07 -0400
> From: Aaron Zeng via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> When in a completing-read-multiple, selecting a completion to insert
> into the minibuffer does not respect the completion boundaries, leading
> to unexpected results.  A common example of a completion table with
> nontrivial boundaries is completion-file-name-table, although the use
> case I have in mind is with a custom, site-specific completion table.
> 
> Here is a quick example to reproduce from 'emacs -Q':
> 
> ```
> (defun crm-file-boundary-repro (reader)
>   (let* ((root (make-temp-file "crm-boundary-" 'directory))
>          (default-directory root))
>     (unwind-protect
>         (progn
>           (make-directory "dir")
>           (with-temp-file "dir/alpha" (insert ""))
>           (funcall reader
>                    "Pick: "
>                    #'completion-file-name-table
>                    nil t "dir/a"))
>       (delete-directory root t))))
> 
> (defun crm-file-boundary-repro-single ()
>   (interactive)
>   (message "Result: %S"
>            (crm-file-boundary-repro #'completing-read)))
> 
> (defun crm-file-boundary-repro-multiple ()
>   (interactive)
>   (message "Result: %S"
>            (crm-file-boundary-repro #'completing-read-multiple)))
> ```
> 
> Reproduction steps:
> 
> 1. Eval the above snippet
> 2. M-x crm-file-boundary-repro-single; initial input is "dir/a"
> 3. Press ? to show completions, then M-<down> to select the string "alpha"
> 4. Press M-RET: completing-read returns "dir/alpha" as expected
> 
> In contrast:
> 
> 5. M-x crm-file-boundary-repro-multiple; initial input is "dir/a"
> 6. Press ? to show completions, then M-<down> to select the string "alpha"
> 7. Press M-RET: the minibuffer contents are replaced by "alpha" ("dir/"
>    was erased unexpectedly).  completing-read-multiple does not return
>    because REQUIRE-MATCH was non-nil and the input does not match.
> 
>    Instead, inserting the completion should only affect the region after
>    "dir/".

Spencer and Stefan, any comments or suggestions?

> In GNU Emacs 31.0.90 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
>  version 1.15.12, Xaw scroll bars) of 2026-07-14 built on
>  igm-qws-u12685a
> Repository revision: 48a481ac8d8d0c2436ee343b582755d51c608374
> Repository branch: HEAD
> Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
> System Description: Rocky Linux 8.10 (Green Obsidian)
> 
> Configured using:
>  'configure --with-x-toolkit=lucid --without-gpm --without-gconf
>  --without-selinux --without-imagemagick --with-modules --with-gif=no
>  --with-cairo --with-rsvg --without-compress-install --with-tree-sitter
>  --with-native-compilation=aot
>  PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'
> 
> Configured features:
> CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSYSTEMD
> LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP
> SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM
> XINERAMA XINPUT2 XPM XRANDR LUCID ZLIB
> 
> Important settings:
>   value of $LANG: en_US.utf8
>   locale-coding-system: utf-8-unix
> 
> Major mode: Lisp Interaction
> 
> Minor modes in effect:
>   tooltip-mode: t
>   global-eldoc-mode: t
>   eldoc-mode: t
>   show-paren-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   tool-bar-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   blink-cursor-mode: t
>   minibuffer-nonselected-mode: t
>   minibuffer-regexp-mode: t
>   line-number-mode: t
>   indent-tabs-mode: t
>   transient-mark-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
> 
> Load-path shadows:
> None found.
> 
> Features:
> (shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
> dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
> rfc6068 epg-config gnus-util text-property-search time-date subr-x
> mule-util mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
> sendmail mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util
> mail-prsvr mail-utils format-spec crm thingatpt comp-run bytecomp
> byte-compile comp-common rx warnings icons cl-loaddefs cl-lib rmc
> iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
> vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
> term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
> fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
> register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
> scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
> frame minibuffer nadvice seq simple cl-generic indonesian philippine
> cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
> korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
> european ethiopic indian cyrillic chinese composite emoji-zwj charscript
> charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
> cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
> files window text-properties overlay sha1 md5 base64 format env
> code-pages mule custom widget keymap hashtable-print-readable backquote
> threads dbusbind inotify dynamic-setting system-font-setting
> font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar
> make-network-process tty-child-frames native-compile emacs)
> 
> Memory information:
> ((conses 16 58648 18691) (symbols 48 6366 0) (strings 32 16506 1939)
>  (string-bytes 1 565419) (vectors 16 9924)
>  (vector-slots 8 142174 9474) (floats 8 26 18) (intervals 56 331 0)
>  (buffers 1064 11))
> 
> 
> 
> 




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

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


Received: (at 81411) by debbugs.gnu.org; 14 Jul 2026 20:55:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 14 16:55:02 2026
Received: from localhost ([127.0.0.1]:44486 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wjk9b-0005uv-8V
	for submit <at> debbugs.gnu.org; Tue, 14 Jul 2026 16:55:01 -0400
Received: from mail.eshelyaron.com ([107.175.124.16]:47866 helo=eshelyaron.com)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <me@HIDDEN>) id 1wjk9X-0005uf-Mo
 for 81411 <at> debbugs.gnu.org; Tue, 14 Jul 2026 16:54:57 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com;
 s=mail; t=1784062494;
 bh=4358Rwh3KVW1PlIOTpHthQQLAzE0jJuXWLC0K/v4YnY=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=ct9GfqqdVNHKjc5XdV/FHMNAPCNQpYZYTpc4TB691+Sw0pVb6E8OS59S9PnPOePSc
 EUMgnCnmoOsU+tzMfQjBrIj1xK65r3z+CJfzTNYwkIaoxZpXlNQ586vEigFalZzK7C
 IAyWcoPHno+jok6GIKA5SaOYlDwDXVT160KlnP39+RbCtjQJJgIO+xuvLtiDaqOB/A
 d4Uq95IlJOR4uNJ5dT5UjZiGhznDKqx2zG60I8ZVvwO2lhQj+vEi7iEgb5PzDZGUvO
 AulNzK4HU5YsRhRSpH4/E4uby16gXQr2Xjij/vd7C8bSL2/1pGmD7Mo2nPXMQLH6y4
 9npf97Hfg3ATg==
From: Eshel Yaron <me@HIDDEN>
To: Aaron Zeng <azeng@HIDDEN>
Subject: Re: bug#81411: 31.0.90; Selecting completion for
 completing-read-multiple does not respect completion boundaries
In-Reply-To: <q7mo6g9wgfk.fsf@HIDDEN>
References: <q7mo6g9wgfk.fsf@HIDDEN>
Date: Tue, 14 Jul 2026 22:54:50 +0200
Message-ID: <87zeztgulh.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: 81411
Cc: 81411 <at> debbugs.gnu.org, app-emacs-dev@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: -1.0 (-)

Hi,

Aaron Zeng writes:

> When in a completing-read-multiple, selecting a completion to insert
> into the minibuffer does not respect the completion boundaries, leading
> to unexpected results.  A common example of a completion table with
> nontrivial boundaries is completion-file-name-table, although the use
> case I have in mind is with a custom, site-specific completion table.
>
> [...]
>
> Reproduction steps: [...]

FWIW, I recall struggling with, and fixing, a similar case in my
completing-read-multiple (re)implementation, and indeed this does not
reproduce here; it works as expected.

If it helps, my implementation is here: https://git.sr.ht/~eshel/emacs
There's also a slightly earlier version of it (which I didn't test now)
in branch feature/minibuffer-completion-enhancements of emacs.git.


Best,

Eshel




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

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


Received: (at submit) by debbugs.gnu.org; 14 Jul 2026 18:54:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jul 14 14:54:25 2026
Received: from localhost ([127.0.0.1]:44191 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1wjiGu-0008O1-JH
	for submit <at> debbugs.gnu.org; Tue, 14 Jul 2026 14:54:25 -0400
Received: from lists1p.gnu.org ([2001:470:142::17]:50922)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <azeng@HIDDEN>)
 id 1wjiGq-0008Nk-5V
 for submit <at> debbugs.gnu.org; Tue, 14 Jul 2026 14:54:22 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <azeng@HIDDEN>)
 id 1wjiGk-000690-AQ
 for bug-gnu-emacs@HIDDEN; Tue, 14 Jul 2026 14:54:14 -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 <azeng@HIDDEN>)
 id 1wjiGf-0006Ns-ST
 for bug-gnu-emacs@HIDDEN; Tue, 14 Jul 2026 14:54:12 -0400
From: Aaron Zeng <azeng@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 31.0.90; Selecting completion for completing-read-multiple does not
 respect completion boundaries
X-Debbugs-Cc: app-emacs-dev@HIDDEN
Date: Tue, 14 Jul 2026 14:54:07 -0400
Message-ID: <q7mo6g9wgfk.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com;
 s=waixah; t=1784055248;
 bh=oFJxBDjQMKbqaoYMucnN+RIcRTax74mPJx91vDuDIlc=;
 h=From:To:Subject:Date;
 b=WAT++USuOS0aX9QSVnbeKJx1uz13G/HEn4tUzrDo9ZdpMwARfhtlqvYVxFqEEHSWR
 TCxID9stPBOiO+4pbodEnH46xGALVLX6nJ6UQK+wjiqnn5Jcyp0m1EueAjGOhnIvvc
 PGIUY/0SXnI0AoHJK48wRc7a1IQdU6nUMZuGG6gvk8a0RqCcMGcWAfsz7+kCIEQ4x6
 HHJS3PoW8MjFsjpXz/ZD4cGPp95LIjTFmqp1wedhgMBb9Xvkjb4bYWk8oE0rs5WDWm
 w7t3htzIdeDI+QYlkmtU5tyVgLgl1Jg1oVxP/kf+UhVfAx0XWLHtcg64s2yQB3Q+Jt
 X+wRA+BbObqBw==
Received-SPF: pass client-ip=64.215.233.18; envelope-from=azeng@HIDDEN;
 helo=mxout5.mail.janestreet.com
X-Spam_score_int: -80
X-Spam_score: -8.1
X-Spam_bar: --------
X-Spam_report: (-8.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5,
 RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, 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 (/)

When in a completing-read-multiple, selecting a completion to insert
into the minibuffer does not respect the completion boundaries, leading
to unexpected results.  A common example of a completion table with
nontrivial boundaries is completion-file-name-table, although the use
case I have in mind is with a custom, site-specific completion table.

Here is a quick example to reproduce from 'emacs -Q':

```
(defun crm-file-boundary-repro (reader)
  (let* ((root (make-temp-file "crm-boundary-" 'directory))
         (default-directory root))
    (unwind-protect
        (progn
          (make-directory "dir")
          (with-temp-file "dir/alpha" (insert ""))
          (funcall reader
                   "Pick: "
                   #'completion-file-name-table
                   nil t "dir/a"))
      (delete-directory root t))))

(defun crm-file-boundary-repro-single ()
  (interactive)
  (message "Result: %S"
           (crm-file-boundary-repro #'completing-read)))

(defun crm-file-boundary-repro-multiple ()
  (interactive)
  (message "Result: %S"
           (crm-file-boundary-repro #'completing-read-multiple)))
```

Reproduction steps:

1. Eval the above snippet
2. M-x crm-file-boundary-repro-single; initial input is "dir/a"
3. Press ? to show completions, then M-<down> to select the string "alpha"
4. Press M-RET: completing-read returns "dir/alpha" as expected

In contrast:

5. M-x crm-file-boundary-repro-multiple; initial input is "dir/a"
6. Press ? to show completions, then M-<down> to select the string "alpha"
7. Press M-RET: the minibuffer contents are replaced by "alpha" ("dir/"
   was erased unexpectedly).  completing-read-multiple does not return
   because REQUIRE-MATCH was non-nil and the input does not match.

   Instead, inserting the completion should only affect the region after
   "dir/".

In GNU Emacs 31.0.90 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2026-07-14 built on
 igm-qws-u12685a
Repository revision: 48a481ac8d8d0c2436ee343b582755d51c608374
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --with-x-toolkit=lucid --without-gpm --without-gconf
 --without-selinux --without-imagemagick --with-modules --with-gif=no
 --with-cairo --with-rsvg --without-compress-install --with-tree-sitter
 --with-native-compilation=aot
 PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'

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

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

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-nonselected-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date subr-x
mule-util mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
sendmail mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils format-spec crm thingatpt comp-run bytecomp
byte-compile comp-common rx warnings icons cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames native-compile emacs)

Memory information:
((conses 16 58648 18691) (symbols 48 6366 0) (strings 32 16506 1939)
 (string-bytes 1 565419) (vectors 16 9924)
 (vector-slots 8 142174 9474) (floats 8 26 18) (intervals 56 331 0)
 (buffers 1064 11))




Acknowledgement sent to Aaron Zeng <azeng@HIDDEN>:
New bug report received and forwarded. Copy sent to app-emacs-dev@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to app-emacs-dev@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#81411; 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: Thu, 6 Aug 2026 15:15:02 UTC

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