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.
This commit is contained in:
Mauro Aranda 2022-10-26 07:29:51 -03:00
parent d6e08ff459
commit 5d46c0e329

View file

@ -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)