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

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

[elpa] externals/marginalia 2f849d8 013/241: Simplify marginalia--comple


From: Stefan Monnier
Subject: [elpa] externals/marginalia 2f849d8 013/241: Simplify marginalia--completion-metadata-get
Date: Fri, 28 May 2021 20:48:47 -0400 (EDT)

branch: externals/marginalia
commit 2f849d8ff80907c26c82e8584a3e283172d62bac
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Simplify marginalia--completion-metadata-get
    
    The new simpler function is :before-until advice (the previous
    function was :around advice).
---
 marginalia.el | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index 8cea9cf..f7963bb 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -207,7 +207,7 @@ Annotations are only shown if `marginalia-mode' is enabled."
       (mapcar (lambda (cand) (concat cand (funcall annotate cand))) candidates)
     candidates))
 
-(defun marginalia--completion-metadata-get (fun metadata prop)
+(defun marginalia--completion-metadata-get (metadata prop)
   "Advice for `completion-metadata-get'.
 Replaces the category and annotation function.
 FUN is the original function.
@@ -216,14 +216,11 @@ PROP is the property which is looked up."
   ;; TODO add more category classifiers from Embark
   (pcase prop
     ('annotation-function
-     (or (when-let (cat (marginalia--category-type))
-           (alist-get cat marginalia-annotate-alist))
-         (funcall fun metadata prop)))
+     (when-let (cat (marginalia--category-type))
+       (alist-get cat marginalia-annotate-alist)))
     ('category
-     (or (and marginalia--this-command
-              (alist-get marginalia--this-command 
marginalia-command-category-alist))
-         (funcall fun metadata prop)))
-    (_ (funcall fun metadata prop))))
+     (and marginalia--this-command
+          (alist-get marginalia--this-command 
marginalia-command-category-alist)))))
 
 (defun marginalia--minibuffer-setup ()
   "Setup minibuffer for `marginalia-mode'.
@@ -256,7 +253,7 @@ Remember `this-command' for annotation."
     (add-hook 'minibuffer-setup-hook #'marginalia--minibuffer-setup)
 
     ;; Replace the metadata function.
-    (advice-add #'completion-metadata-get :around 
#'marginalia--completion-metadata-get)))
+    (advice-add #'completion-metadata-get :before-until 
#'marginalia--completion-metadata-get)))
 
 ;;;###autoload
 (defun marginalia-set-command-annotation (cmd ann)



reply via email to

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