emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#53012: closed (28.0.90; completion--nth-completion: Throw a meaningf


From: GNU bug Tracking System
Subject: bug#53012: closed (28.0.90; completion--nth-completion: Throw a meaningful error)
Date: Sun, 09 Jan 2022 15:32:02 +0000

Your message dated Sun, 9 Jan 2022 09:31:36 -0600
with message-id 
<CADwFkm=8K3HgQno0sa6Az2NDK2eR-mn7N-oapQkXVqmsc6_x1A@mail.gmail.com>
and subject line Re: bug#53012: 28.0.90; completion--nth-completion: Throw a 
meaningful error
has caused the debbugs.gnu.org bug report #53012,
regarding 28.0.90; completion--nth-completion: Throw a meaningful error
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
53012: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=53012
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- 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@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




--- End Message ---
--- Begin Message --- Subject: Re: bug#53012: 28.0.90; completion--nth-completion: Throw a meaningful error Date: Sun, 9 Jan 2022 09:31:36 -0600 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
Daniel Mendler <mail@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.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]