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

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

[elpa] externals/vertico ab81df5 3/4: vertico--format-candidates: Extrac


From: ELPA Syncer
Subject: [elpa] externals/vertico ab81df5 3/4: vertico--format-candidates: Extract vertico--format-candidate
Date: Sun, 4 Jul 2021 04:57:16 -0400 (EDT)

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

    vertico--format-candidates: Extract vertico--format-candidate
---
 vertico.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/vertico.el b/vertico.el
index f4ca5b0..44b331e 100644
--- a/vertico.el
+++ b/vertico.el
@@ -425,6 +425,14 @@ See `resize-mini-windows' for documentation."
      (replace-regexp-in-string "\\`[\t\n ]+\\|[\t\n ]+\\'" ""))
    max-width 0 nil (cdr vertico-multiline)))
 
+(defun vertico--format-candidate (cand prefix suffix index)
+  "Format CAND given PREFIX, SUFFIX and INDEX."
+  (setq cand (vertico--flatten-string 'invisible (vertico--flatten-string 
'display cand))
+        cand (concat prefix cand suffix "\n"))
+  (when (= index vertico--index)
+    (add-face-text-property 0 (length cand) 'vertico-current 'append cand))
+  cand)
+
 (defun vertico--format-candidates (metadata)
   "Format current candidates with METADATA."
   (let* ((group-fun (completion-metadata-get metadata 'group-function))
@@ -446,14 +454,11 @@ See `resize-mini-windows' for documentation."
           (unless (equal title new-title)
             (push (format group-format (setq title new-title)) lines))
           (setq cand (funcall group-fun cand 'transform)))
+        (when (= index vertico--index)
+          (setq curr-line (length lines)))
         (when (string-match-p "\n" cand)
           (setq cand (vertico--truncate-multiline cand max-width)))
-        (setq cand (vertico--flatten-string 'invisible 
(vertico--flatten-string 'display cand))
-              cand (concat prefix cand suffix "\n"))
-        (when (= index vertico--index)
-          (setq curr-line (length lines))
-          (add-face-text-property 0 (length cand) 'vertico-current 'append 
cand))
-        (push cand lines)
+        (push (vertico--format-candidate cand prefix suffix index) lines)
         (setq index (1+ index))))
     (setq lines (nreverse lines) index (length lines))
     (while (> index vertico-count)



reply via email to

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