From: Mauro Aranda Date: Wed, 26 Oct 2022 10:29:51 +0000 (-0300) Subject: Make completion-category-overrides choices dynamic X-Git-Tag: emacs-29.0.90~1616^2~453 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5d46c0e329b90619b5e36beb376e9c73baf6c44e;p=emacs.git Make completion-category-overrides choices dynamic See https://lists.gnu.org/archive/html/emacs-devel/2022-10/msg01969.html * lisp/minibuffer.el (completion--update-styles-options): New internal function. (completion--styles-type): Use it. --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index fd878e077a1..4898dfdb983 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -972,21 +972,17 @@ ALL-COMPLETIONS is the function that lists the completions (it should follow the calling convention of `completion-all-completions'), and DOC describes the way this style of completion works.") +(defun completion--update-styles-options (widget) + "Function to keep updated the options in `completion-category-overrides'." + (let ((lst (mapcar (lambda (x) + (list 'const (car x))) + completion-styles-alist))) + (widget-put widget :args (mapcar #'widget-convert lst)) + widget)) + (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) - (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))))))) + (choice :convert-widget completion--update-styles-options))) (defconst completion--cycling-threshold-type '(choice (const :tag "No cycling" nil)