[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico d65eeac 04/11: vertico--recompute-candidates: M
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/vertico d65eeac 04/11: vertico--recompute-candidates: Move exact input and default to front |
Date: |
Thu, 8 Apr 2021 07:11:15 -0400 (EDT) |
branch: externals/vertico
commit d65eeac347b9c7c4b1872fac5638f53675919abd
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
vertico--recompute-candidates: Move exact input and default to front
---
vertico.el | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/vertico.el b/vertico.el
index e4e0bff..af778fd 100644
--- a/vertico.el
+++ b/vertico.el
@@ -227,6 +227,12 @@
(if (= (length highlighted) (length candidates))
highlighted candidates)))
+(defun vertico--move-to-front (elem list)
+ "Move ELEM to front of LIST."
+ (if-let (head (car (member elem list)))
+ (nconc (list head) (delq head list))
+ list))
+
(defun vertico--recompute-candidates (input metadata)
"Recompute candidates with INPUT string and METADATA."
(let* ((ignore-re (concat "\\(?:\\`\\|/\\)\\.?\\./\\'"
@@ -246,16 +252,15 @@
(prog1 (cdr last)
(setcdr last nil))
0))
+ (def (or (car-safe minibuffer-default) minibuffer-default))
(total (length all)))
(when (<= total vertico-sort-threshold)
(setq all (if-let (sort (completion-metadata-get metadata
'display-sort-function))
(funcall sort all)
(vertico--sort input all))))
- (when-let* ((def (cond
- ((stringp (car-safe minibuffer-default)) (car
minibuffer-default))
- ((stringp minibuffer-default) minibuffer-default)))
- (rest (member def all)))
- (setq all (nconc (list (car rest)) (delete def all))))
+ (when (stringp def)
+ (setq all (vertico--move-to-front def all)))
+ (setq all (vertico--move-to-front (vertico--input-after-boundary input)
all))
(when-let (group (completion-metadata-get metadata 'x-group-function))
(setq all (mapcan #'cdr (funcall group all))))
(list base total all)))
@@ -292,6 +297,11 @@
(setq pos end)))
(apply #'concat (nreverse chunks))))
+(defun vertico--input-after-boundary (input)
+ "Compute INPUT string after completion boundary."
+ (substring input (car (completion-boundaries input
minibuffer-completion-table
+ minibuffer-completion-predicate
""))))
+
(defun vertico--format-candidates (input metadata)
"Format current candidates with INPUT string and METADATA."
(let* ((index (min (max 0 (- vertico--index (/ vertico-count 2)))
@@ -299,11 +309,7 @@
(candidates
(thread-last (seq-subseq vertico--candidates index
(min (+ index vertico-count)
vertico--total))
- (vertico--highlight
- (substring input
- (car (completion-boundaries input
minibuffer-completion-table
-
minibuffer-completion-predicate "")))
- metadata)
+ (vertico--highlight (vertico--input-after-boundary input) metadata)
(vertico--annotate metadata)))
(max-width (- (* 2 (window-width)) 5))
(title)
- [elpa] externals/vertico updated (1a9b1b2 -> 82ed224), Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico d65eeac 04/11: vertico--recompute-candidates: Move exact input and default to front,
Protesilaos Stavrou <=
- [elpa] externals/vertico ee77886 01/11: Expand README, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico c734b0f 02/11: Minor simplification and docstring updates, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico d9bb816 09/11: README: Mention a few more useful configurations, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico 403e154 05/11: Fix #2 - Screenshot background, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico edf6a06 08/11: Do not always overwrite resize-mini-windows (See #5), Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico bf76000 06/11: Rename vertico--pred to vertico--sort-predicate, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico 1522d9a 07/11: Extract vertico--file-predicate, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico 953ff1e 10/11: README: Document keymap, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico 82ed224 11/11: Package: Remove license header in order to fix the ELPA linter, Protesilaos Stavrou, 2021/04/08
- [elpa] externals/vertico a68f4cf 03/11: vertico--format-candidates: Only add space for point if eobp, Protesilaos Stavrou, 2021/04/08