GNU bug report logs - #53012
28.0.90; completion--nth-completion: Throw a meaningful error

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Tue, 4 Jan 2022 20:14:02 UTC

Severity: normal

Found in version 28.0.90

Done: Stefan Kangas <stefan <at> marxist.se>

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 53012 in the body.
You can then email your comments to 53012 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#53012; Package emacs. (Tue, 04 Jan 2022 20:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Daniel Mendler <mail <at> daniel-mendler.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 04 Jan 2022 20:14:02 GMT) Full text and rfc822 format available.

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

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: bug-gnu-emacs <at> gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: 28.0.90; completion--nth-completion: Throw a meaningful error
Date: Tue, 4 Jan 2022 21:12:47 +0100
In the context of the GNU ELPA Vertico/Mct/Orderless/Embark ecosystem we
teach users to adjust the completion style. Unfortunately
completion--nth-completion is not very robust against misconfiguration.
I propose to throw a more meaningful error instead of the nil error.
Patch follows.

---

From da92169572e375facabb28b6d3c14cb2158ab1c9 Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail <at> daniel-mendler.de>
Date: Tue, 4 Jan 2022 21:08:04 +0100
Subject: [PATCH] completion--nth-completion: Throw meaningful error

If a configured completion style does not exist, throw a meaningful
error. Also make completion-styles-alist a defvar, since completion
styles like orderless extend it.
---
 lisp/minibuffer.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 1d596694e4..ab760a42d1 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -900,7 +900,7 @@ completion-auto-help
 the second failed attempt to complete."
   :type '(choice (const nil) (const t) (const lazy)))

-(defconst completion-styles-alist
+(defvar completion-styles-alist
   '((emacs21
      completion-emacs21-try-completion completion-emacs21-all-completions
      "Simple prefix-based completion.
@@ -1076,9 +1076,10 @@ completion--nth-completion
          (result-and-style
           (completion--some
            (lambda (style)
-             (let ((probe (funcall (nth n (assq style
-                                                completion-styles-alist))
-                                   string table pred point)))
+             (let ((probe (funcall
+                           (or (nth n (assq style completion-styles-alist))
+                               (error "Invalid completion style %s" style))
+                           string table pred point)))
                (and probe (cons probe style))))
            (completion--styles md)))
          (adjust-fn (get (cdr result-and-style)
'completion--adjust-metadata)))
-- 
2.20.1





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53012; Package emacs. (Wed, 05 Jan 2022 00:20:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: 53012 <at> debbugs.gnu.org
Subject: Re: 28.0.90; completion--nth-completion: Throw a meaningful error
Date: Tue, 04 Jan 2022 19:19:22 -0500
Daniel Mendler [2022-01-04 21:12:47] wrote:
> In the context of the GNU ELPA Vertico/Mct/Orderless/Embark ecosystem we
> teach users to adjust the completion style. Unfortunately
> completion--nth-completion is not very robust against misconfiguration.
> I propose to throw a more meaningful error instead of the nil error.

Thanks, looks good.
Pushed to `master`.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#53012; Package emacs. (Wed, 05 Jan 2022 00:43:01 GMT) Full text and rfc822 format available.

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

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 53012 <at> debbugs.gnu.org
Subject: Re: 28.0.90; completion--nth-completion: Throw a meaningful error
Date: Wed, 5 Jan 2022 01:42:19 +0100
On 1/5/22 1:19 AM, Stefan Monnier wrote:
> Daniel Mendler [2022-01-04 21:12:47] wrote:
>> In the context of the GNU ELPA Vertico/Mct/Orderless/Embark ecosystem we
>> teach users to adjust the completion style. Unfortunately
>> completion--nth-completion is not very robust against misconfiguration.
>> I propose to throw a more meaningful error instead of the nil error.
> 
> Thanks, looks good.
> Pushed to `master`.

Thanks!




Reply sent to Stefan Kangas <stefan <at> marxist.se>:
You have taken responsibility. (Sun, 09 Jan 2022 15:32:02 GMT) Full text and rfc822 format available.

Notification sent to Daniel Mendler <mail <at> daniel-mendler.de>:
bug acknowledged by developer. (Sun, 09 Jan 2022 15:32:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefan <at> marxist.se>
To: Daniel Mendler <mail <at> daniel-mendler.de>
Cc: 53012-done <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#53012: 28.0.90; completion--nth-completion: Throw a
 meaningful error
Date: Sun, 9 Jan 2022 09:31:36 -0600
Daniel Mendler <mail <at> daniel-mendler.de> writes:

> On 1/5/22 1:19 AM, Stefan Monnier wrote:
>> Daniel Mendler [2022-01-04 21:12:47] wrote:
>>> In the context of the GNU ELPA Vertico/Mct/Orderless/Embark ecosystem we
>>> teach users to adjust the completion style. Unfortunately
>>> completion--nth-completion is not very robust against misconfiguration.
>>> I propose to throw a more meaningful error instead of the nil error.
>>
>> Thanks, looks good.
>> Pushed to `master`.
>
> Thanks!

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. (Mon, 07 Feb 2022 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 76 days ago.

Previous Next


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