[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu cca1eaf 09/14: Extract corfu--move-prefix-candida
From: |
Protesilaos Stavrou |
Subject: |
[elpa] externals/corfu cca1eaf 09/14: Extract corfu--move-prefix-candidates-to-front |
Date: |
Sat, 17 Apr 2021 10:25:43 -0400 (EDT) |
branch: externals/corfu
commit cca1eaf4d08069ffc6b064939a2d90dc6b0ef9b3
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Extract corfu--move-prefix-candidates-to-front
---
corfu.el | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/corfu.el b/corfu.el
index f71ec4e..cf45558 100644
--- a/corfu.el
+++ b/corfu.el
@@ -287,6 +287,12 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(lambda (x) (and (not (string-match-p ignore x)) (funcall pred x)))
(lambda (x) (not (string-match-p ignore x))))))
+(defun corfu--move-prefix-candidates-to-front (field candidates)
+ "Move CANDIDATES which match prefix of FIELD to the beginning."
+ (let ((word (replace-regexp-in-string " .*" "" field)))
+ (nconc (seq-filter (lambda (x) (string-prefix-p word x)) candidates)
+ (seq-remove (lambda (x) (string-prefix-p word x)) candidates))))
+
(defun corfu--recompute-candidates (str bounds metadata pt table pred)
"Recompute candidates from STR, BOUNDS, METADATA, PT, TABLE and PRED."
(let* ((field (substring str (car bounds) (+ pt (cdr bounds))))
@@ -301,11 +307,7 @@ If `line-spacing/=nil' or in text-mode, the background
color is used instead.")
(setq all (if-let (sort (corfu--metadata-get metadata
'display-sort-function))
(funcall sort all)
(sort all #'corfu--sort-predicate)))
- ;; Move candidates which match prefix to the beginning
- (let* ((word (replace-regexp-in-string " .*" "" field))
- (prefix (seq-filter (lambda (x) (string-prefix-p word x)) all))
- (not-prefix (seq-remove (lambda (x) (string-prefix-p word x)) all)))
- (setq all (nconc prefix not-prefix)))
+ (setq all (corfu--move-prefix-candidates-to-front field all))
(when (and completing-file (not (string-suffix-p "/" field)))
(setq all (corfu--move-to-front (concat field "/") all)))
(setq all (corfu--move-to-front field all))
- [elpa] externals/corfu 4e58a71 04/14: Minor optimizations, (continued)
- [elpa] externals/corfu 4e58a71 04/14: Minor optimizations, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu ff1579e 11/14: README: Add link to ELPA, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 2ebd35f 12/14: corfu-map: Bind M-n and M-p, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 4c2c997 14/14: Version 0.2, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 41eb724 02/14: Ignore corfu-abort if documentation/location window is shown, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 82474fb 01/14: Fix typo in corfu-minor-mode, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 7fcd09b 08/14: README: Update caveat, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 6e9b8ef 10/14: Add corfu-completion-styles, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu 10660b4 07/14: corfu-first: Jump to the prompt if first candidate is selected, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu cf7c6c9 05/14: Do not show annotation in candidate preview (See #2), Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu cca1eaf 09/14: Extract corfu--move-prefix-candidates-to-front,
Protesilaos Stavrou <=
- [elpa] externals/corfu 6e91059 06/14: Fix some face issues, add comment about face usage, Protesilaos Stavrou, 2021/04/17
- [elpa] externals/corfu a01d068 13/14: Do not colorize left border (See #6), Protesilaos Stavrou, 2021/04/17