emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/marginalia ed74ca9 040/241: add marginalia-toggle-annot


From: Stefan Monnier
Subject: [elpa] externals/marginalia ed74ca9 040/241: add marginalia-toggle-annotators
Date: Fri, 28 May 2021 20:48:52 -0400 (EDT)

branch: externals/marginalia
commit ed74ca9457a78f7019d9e32ffad87aa50694aac2
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    add marginalia-toggle-annotators
---
 marginalia.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index bf2963d..f1900a4 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -95,12 +95,14 @@
   :group 'marginalia)
 
 (defcustom marginalia-annotators
-  'marginalia-annotators-light
+  '(marginalia-annotators-light marginalia-annotators-heavy)
   "Choose an annotator association list for minibuffer completion.
+The first entry in the list is used for annotations.
+You can toggle between the annotators using `marginalia-toggle-annotators'.
 Annotations are only shown if `marginalia-mode' is enabled."
-  :type '(choice (const :tag "Light" marginalia-annotators-light)
-                 (const :tag "Heavy" marginalia-annotators-heavy)
-                 (symbol :tag "Other"))
+  :type '(repeat (choice (const :tag "Light" marginalia-annotators-light)
+                         (const :tag "Heavy" marginalia-annotators-heavy)
+                         (symbol :tag "Other")))
   :group 'marginalia)
 
 (defcustom marginalia-annotators-light
@@ -380,7 +382,7 @@ PROP is the property which is looked up."
     ('annotation-function
      (when-let (cat (completion-metadata-get metadata 'category))
        ;; we do want the advice triggered for completion-metadata-get
-       (alist-get cat (symbol-value marginalia-annotators))))
+       (alist-get cat (symbol-value (car marginalia-annotators)))))
     ('category
      (let ((marginalia--original-category (alist-get 'category metadata)))
        ;; using alist-get in the line above bypasses any advice on
@@ -409,5 +411,11 @@ Remember `this-command' for annotation."
     ;; Replace the metadata function.
     (advice-add #'completion-metadata-get :before-until 
#'marginalia--completion-metadata-get)))
 
+(defun marginalia-toggle-annotators ()
+  "Toggle between annotators in `marginalia-annotators'."
+  (interactive)
+  (setq marginalia-annotators (append (cdr marginalia-annotators)
+                                      (list (car marginalia-annotators)))))
+
 (provide 'marginalia)
 ;;; marginalia.el ends here



reply via email to

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