GNU bug report logs - #69501
30.0.50; customize-mode error with substring completion style

Previous Next

Package: emacs;

Reported by: Eshel Yaron <me <at> eshelyaron.com>

Date: Sat, 2 Mar 2024 09:01:02 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 69501 in the body.
You can then email your comments to 69501 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#69501; Package emacs. (Sat, 02 Mar 2024 09:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eshel Yaron <me <at> eshelyaron.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 02 Mar 2024 09:01:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; customize-mode error with substring completion style
Date: Sat, 02 Mar 2024 09:59:48 +0100
Hi,

With both Emacs 29.2 and with the current master:

1. emacs -Q
2. (setq completion-styles '(substring))
3. C-u M-x customize-mode TAB
4. "Assertion failed: (stringp suffix)"

I not sure exactly why this error occurs, but IIUC it has to do with the
fact that customize-mode let-binds completion-regexp-list.  I suspect
that the substring completion style doesn't handle that correctly.

In general, let-binding completion-regexp-list around completing-read is
not a great idea IMO because it affects recursive minibuffers as well.
So perhaps the best solution is to avoid doing that in customize-mode,
and to rely only on the predicate argument of completing-read instead?


Best,

Eshel




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69501; Package emacs. (Mon, 04 Mar 2024 13:17:02 GMT) Full text and rfc822 format available.

Message #8 received at 69501 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Eshel Yaron <me <at> eshelyaron.com>, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 69501 <at> debbugs.gnu.org
Subject: Re: bug#69501: 30.0.50;
 customize-mode error with substring completion style
Date: Mon, 04 Mar 2024 15:16:12 +0200
> Date: Sat, 02 Mar 2024 09:59:48 +0100
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> With both Emacs 29.2 and with the current master:
> 
> 1. emacs -Q
> 2. (setq completion-styles '(substring))
> 3. C-u M-x customize-mode TAB
> 4. "Assertion failed: (stringp suffix)"
> 
> I not sure exactly why this error occurs, but IIUC it has to do with the
> fact that customize-mode let-binds completion-regexp-list.  I suspect
> that the substring completion style doesn't handle that correctly.
> 
> In general, let-binding completion-regexp-list around completing-read is
> not a great idea IMO because it affects recursive minibuffers as well.
> So perhaps the best solution is to avoid doing that in customize-mode,
> and to rely only on the predicate argument of completing-read instead?

Stefan and Mauro, any suggestions?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69501; Package emacs. (Tue, 05 Mar 2024 12:38:02 GMT) Full text and rfc822 format available.

Message #11 received at 69501 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Eshel Yaron <me <at> eshelyaron.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 69501 <at> debbugs.gnu.org
Subject: Re: bug#69501: 30.0.50; customize-mode error with substring
 completion style
Date: Tue, 5 Mar 2024 09:36:01 -0300
On 4/3/24 10:16, Eli Zaretskii wrote:
>> Date: Sat, 02 Mar 2024 09:59:48 +0100
>> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> With both Emacs 29.2 and with the current master:
>>
>> 1. emacs -Q
>> 2. (setq completion-styles '(substring))
>> 3. C-u M-x customize-mode TAB
>> 4. "Assertion failed: (stringp suffix)"
>>
>> I not sure exactly why this error occurs, but IIUC it has to do with the
>> fact that customize-mode let-binds completion-regexp-list.  I suspect
>> that the substring completion style doesn't handle that correctly.
>>
>> In general, let-binding completion-regexp-list around completing-read is
>> not a great idea IMO because it affects recursive minibuffers as well.
>> So perhaps the best solution is to avoid doing that in customize-mode,
>> and to rely only on the predicate argument of completing-read instead?
>
> Stefan and Mauro, any suggestions?

I took a quick look, but I don't know how "relying on the predicate
argument of completing-read" looks in practice.  It seems I have
forgotten how to use the completion functions (if I ever knew how to use
them at all).  Hopefully Stefan will be of more help.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69501; Package emacs. (Thu, 14 Mar 2024 08:27:02 GMT) Full text and rfc822 format available.

Message #14 received at 69501 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: monnier <at> iro.umontreal.ca, Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 69501 <at> debbugs.gnu.org, me <at> eshelyaron.com
Subject: Re: bug#69501: 30.0.50; customize-mode error with substring
 completion style
Date: Thu, 14 Mar 2024 10:26:01 +0200
> Date: Tue, 5 Mar 2024 09:36:01 -0300
> Cc: 69501 <at> debbugs.gnu.org
> From: Mauro Aranda <maurooaranda <at> gmail.com>
> 
> On 4/3/24 10:16, Eli Zaretskii wrote:
>  >> Date: Sat, 02 Mar 2024 09:59:48 +0100
>  >> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  >>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>  >>
>  >> With both Emacs 29.2 and with the current master:
>  >>
>  >> 1. emacs -Q
>  >> 2. (setq completion-styles '(substring))
>  >> 3. C-u M-x customize-mode TAB
>  >> 4. "Assertion failed: (stringp suffix)"
>  >>
>  >> I not sure exactly why this error occurs, but IIUC it has to do with the
>  >> fact that customize-mode let-binds completion-regexp-list.  I suspect
>  >> that the substring completion style doesn't handle that correctly.
>  >>
>  >> In general, let-binding completion-regexp-list around completing-read is
>  >> not a great idea IMO because it affects recursive minibuffers as well.
>  >> So perhaps the best solution is to avoid doing that in customize-mode,
>  >> and to rely only on the predicate argument of completing-read instead?
>  >
>  > Stefan and Mauro, any suggestions?
> 
> I took a quick look, but I don't know how "relying on the predicate
> argument of completing-read" looks in practice.  It seems I have
> forgotten how to use the completion functions (if I ever knew how to use
> them at all).  Hopefully Stefan will be of more help.

Stefan?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69501; Package emacs. (Thu, 14 Mar 2024 18:13:01 GMT) Full text and rfc822 format available.

Message #17 received at 69501 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 69501 <at> debbugs.gnu.org
Subject: Re: bug#69501: 30.0.50; customize-mode error with substring
 completion style
Date: Thu, 14 Mar 2024 14:11:20 -0400
> In general, let-binding completion-regexp-list around completing-read is
> not a great idea IMO

Definitely: `completion-regexp-list` should be let-bound only right
around calls to `try/all-completions`.

> because it affects recursive minibuffers as well.
> So perhaps the best solution is to avoid doing that in customize-mode,
> and to rely only on the predicate argument of completing-read instead?

Indeed (see patch below).

We should probably also change the completion code so it defends against
such let-bindings of `completion-regexp-list`.


        Stefan


diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 8fad51dc116..f004002333b 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1159,14 +1159,15 @@ customize-mode
 for the MODE to customize."
   (interactive
    (list
-    (let ((completion-regexp-list '("-mode\\'"))
-	  (group (custom-group-of-mode major-mode)))
+    (let ((group (custom-group-of-mode major-mode)))
       (if (and group (not current-prefix-arg))
 	  major-mode
 	(intern
 	 (completing-read (format-prompt "Mode" (and group major-mode))
 			  obarray
-			  'custom-group-of-mode
+			  (lambda (s)
+			    (and (string-match "-mode\\'" (symbol-name s))
+			         (custom-group-of-mode s)))
 			  t nil nil (if group (symbol-name major-mode))))))))
   (customize-group (custom-group-of-mode mode)))
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#69501; Package emacs. (Fri, 15 Mar 2024 02:02:01 GMT) Full text and rfc822 format available.

Message #20 received at 69501 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 69501 <at> debbugs.gnu.org
Subject: Re: bug#69501: 30.0.50; customize-mode error with substring
 completion style
Date: Thu, 14 Mar 2024 22:00:39 -0400
> Indeed (see patch below).

Pushed to `master`.


        Stefan





Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sat, 01 Mar 2025 03:19:05 GMT) Full text and rfc822 format available.

Notification sent to Eshel Yaron <me <at> eshelyaron.com>:
bug acknowledged by developer. (Sat, 01 Mar 2025 03:19:06 GMT) Full text and rfc822 format available.

Message #25 received at 69501-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 69501-done <at> debbugs.gnu.org, Eshel Yaron <me <at> eshelyaron.com>
Subject: Re: bug#69501: 30.0.50; customize-mode error with substring
 completion style
Date: Fri, 28 Feb 2025 19:17:59 -0800
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> Indeed (see patch below).
>
> Pushed to `master`.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 Mar 2025 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 98 days ago.

Previous Next


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