[Top][All Lists]

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

[elpa] externals/corfu 61e520b: Replace corfu-kind-formatter with corfu-

From: ELPA Syncer
Subject: [elpa] externals/corfu 61e520b: Replace corfu-kind-formatter with corfu-margin-formatters
Date: Fri, 12 Nov 2021 03:57:11 -0500 (EST)

branch: externals/corfu
commit 61e520bafff48cc4d9bce30b17068c0a7c674630
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Replace corfu-kind-formatter with corfu-margin-formatters
 README.org |  2 +-
 corfu.el   | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/README.org b/README.org
index 89a99e7..5cfc260 100644
--- a/README.org
+++ b/README.org
@@ -49,7 +49,7 @@
   - Show candidate documentation/signature string in the echo area.
   - Deprecated candidates are crossed out in the display.
   - Support for annotations (~annotation-function~, ~affixation-function~).
-  - Icons can be provided by an external package via ~corfu-kind-formatter~.
+  - Icons can be provided by an external package via margin formatter 
 * Configuration
diff --git a/corfu.el b/corfu.el
index 6e9fc47..12989e9 100644
--- a/corfu.el
+++ b/corfu.el
@@ -102,12 +102,12 @@ completion began less than that number of seconds ago."
   "Show documentation string in the echo area after that number of seconds."
   :type '(choice boolean float))
-(defcustom corfu-kind-formatter nil
-  "Formatting function for candidate kind.
-The function takes a symbol corresponding to the kind of the candidate
-and must return a string. This function can be used to display icons in
-front of the candidates."
-  :type '(choice function (const nil)))
+(defcustom corfu-margin-formatters nil
+  "Registry for margin formatter functions.
+Each function of the list is called until an appropriate formatter is found.
+The function should return a formatter function, which takes the candidate
+string and must return a string, possibly an icon."
+  :type 'hook)
 (defcustom corfu-auto-prefix 3
   "Minimum length of prefix for auto completion."
@@ -596,14 +596,14 @@ A scroll bar is displayed from LO to LO+BAR."
                                  (propertize suffix 'face 
             (cl-loop for cand in cands collect (list cand "" "")))))
   (let ((dep (plist-get corfu--extra :company-deprecated))
-        (kind (and corfu-kind-formatter (plist-get corfu--extra 
+        (mf (run-hook-with-args-until-success 'corfu-margin-formatters)))
     (cl-loop for x in cands for (c . _) = x do
-             (when kind
-               (setf (cadr x) (funcall corfu-kind-formatter (funcall kind c))))
+             (when mf
+               (setf (cadr x) (funcall mf c)))
              (when (and dep (funcall dep c))
                (setcar x (setq c (substring c)))
                (add-face-text-property 0 (length c) 'corfu-deprecated 'append 
-    (cons kind cands)))
+    (cons mf cands)))
 (defun corfu--metadata-get (prop)
   "Return PROP from completion metadata."
@@ -647,10 +647,10 @@ A scroll bar is displayed from LO to LO+BAR."
                (bar (ceiling (* corfu-count corfu-count) corfu--total))
                (lo (min (- corfu-count bar 1) (floor (* corfu-count start) 
                (cands (funcall corfu--highlight (seq-subseq corfu--candidates 
start last)))
-               (`(,kind . ,acands) (corfu--affixate cands))
+               (`(,mf . ,acands) (corfu--affixate cands))
                (`(,pw ,width ,fcands) (corfu--format-candidates acands))
-               ;; Disable the left margin if a kind function is specified.
-               (corfu-left-margin-width (if kind 0 corfu-left-margin-width)))
+               ;; Disable the left margin if a margin formatter is active.
+               (corfu-left-margin-width (if mf 0 corfu-left-margin-width)))
     ;; Nonlinearity at the end and the beginning
     (when (/= start 0)
       (setq lo (max 1 lo)))

reply via email to

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