From: Mattias EngdegÄrd Date: Wed, 26 Oct 2022 08:51:51 +0000 (+0200) Subject: Dynamic validation of styles in completion-category-overrides X-Git-Tag: emacs-29.0.90~1616^2~460 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e54c3959827eeee3ea60ccaa4918d22b9dce9cc5;p=emacs.git 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. --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index a9f72d600de..fd878e077a1 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)