From b179ecbb0bc5823077b11c8308ad9293dedc470f Mon Sep 17 00:00:00 2001 From: Mauro Aranda Date: Wed, 26 Oct 2022 07:29:51 -0300 Subject: [PATCH] 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. --- lisp/minibuffer.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index a9f72d600d..4898dfdb98 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -972,10 +972,18 @@ completion-styles-alist 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)))) + (choice :convert-widget completion--update-styles-options))) + (defconst completion--cycling-threshold-type '(choice (const :tag "No cycling" nil) (const :tag "Always cycle" t) -- 2.34.1