[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico 0d14eb7 2/5: vertico--candidate: Add optional H
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/vertico 0d14eb7 2/5: vertico--candidate: Add optional HIGHLIGHT argument |
Date: |
Mon, 12 Apr 2021 15:27:24 -0400 (EDT) |
branch: externals/vertico
commit 0d14eb7dd423987e5f732b857957f87d64b9c04b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
vertico--candidate: Add optional HIGHLIGHT argument
This is useful for `consult-completion-in-region` preview
---
vertico.el | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/vertico.el b/vertico.el
index 2c8614a..3515023 100644
--- a/vertico.el
+++ b/vertico.el
@@ -525,13 +525,13 @@
(delete-minibuffer-contents)
(insert cand)))
-(defun vertico--candidate ()
- "Return current candidate string."
- (let ((content (minibuffer-contents-no-properties)))
- (if (< vertico--index 0)
- content
- (concat (substring content 0 vertico--base)
- (nth vertico--index vertico--candidates)))))
+(defun vertico--candidate (&optional hl)
+ "Return current candidate string with optional highlighting if HL is
non-nil."
+ (let ((content (minibuffer-contents)))
+ (if-let (cand (and (>= vertico--index 0) (nth vertico--index
vertico--candidates)))
+ (concat (substring content 0 vertico--base)
+ (if hl (car (funcall vertico--highlight (list cand))) cand))
+ content)))
(defun vertico--setup ()
"Setup completion UI."