emacs-diffs
[Top][All Lists]
Advanced

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

master e54c395982: Dynamic validation of styles in completion-category-o


From: Mattias Engdegård
Subject: master e54c395982: Dynamic validation of styles in completion-category-overrides
Date: Wed, 26 Oct 2022 05:05:28 -0400 (EDT)

branch: master
commit e54c3959827eeee3ea60ccaa4918d22b9dce9cc5
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Dynamic validation of styles in completion-category-overrides
    
    The type of the defcustom completion-category-overrides must be able
    to accommodate dynamic changes to completion-styles-alist, because
    some packages (eglot) make their own additions.
    
    This change fixes a failure in test-custom-opts.  See discussion at:
    https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg01969.html
    
    * lisp/minibuffer.el (completion--styles-type):
    Add an "Other" case that accepts any symbol which is then validated
    dynamically against completion-styles-alist.
---
 lisp/minibuffer.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index a9f72d600d..fd878e077a 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -975,7 +975,19 @@ and DOC describes the way this style of completion works.")
 (defconst completion--styles-type
   `(repeat :tag "insert a new menu to add more styles"
            (choice ,@(mapcar (lambda (x) (list 'const (car x)))
-                             completion-styles-alist))))
+                             completion-styles-alist)
+                   (symbol :tag "Other"
+                           :validate
+                           ,(lambda (widget)
+                              (let ((value (widget-value widget)))
+                                (if (assq value completion-styles-alist)
+                                    nil    ; Valid.
+                                  (widget-put
+                                   widget :error
+                                   (format "Invalid completion style: %S"
+                                           value))
+                                  widget)))))))
+
 (defconst completion--cycling-threshold-type
   '(choice (const :tag "No cycling" nil)
            (const :tag "Always cycle" t)



reply via email to

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