emacs-diffs
[Top][All Lists]
Advanced

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

master 5d46c0e329: Make completion-category-overrides choices dynamic


From: Mauro Aranda
Subject: master 5d46c0e329: Make completion-category-overrides choices dynamic
Date: Wed, 26 Oct 2022 10:33:26 -0400 (EDT)

branch: master
commit 5d46c0e329b90619b5e36beb376e9c73baf6c44e
Author: Mauro Aranda <maurooaranda@gmail.com>
Commit: Mauro Aranda <maurooaranda@gmail.com>

    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 | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index fd878e077a..4898dfdb98 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)



reply via email to

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