emacs-diffs
[Top][All Lists]
Advanced

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

master 30d4cfc080: completion--nth-completion: Throw meaningful error


From: Stefan Monnier
Subject: master 30d4cfc080: completion--nth-completion: Throw meaningful error
Date: Tue, 4 Jan 2022 19:19:09 -0500 (EST)

branch: master
commit 30d4cfc0806ee1de5a8e5091f0cc5bce22830460
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    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 (completion-styles-alist): Make it a defvar.
    (completion--nth-completion): Give a more meaningful error.
---
 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 @@ If the value is `lazy', the *Completions* buffer is only 
displayed after
 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 @@ This overrides the defaults specified in 
`completion-category-defaults'."
          (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)))



reply via email to

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