[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 12523d0 023/272: Use flx for highlighting fuzzy matches
From: |
Oleh Krehel |
Subject: |
[elpa] master 12523d0 023/272: Use flx for highlighting fuzzy matches |
Date: |
Mon, 25 Apr 2016 10:13:14 +0000 |
branch: master
commit 12523d0574ee48e7d784b48ae8126acca1b533e0
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Use flx for highlighting fuzzy matches
* ivy.el (ivy--flx-sort): `flx-score' returns ((score i1 i2 i3 ...) str).
Use i1, i2, i3 ... to highlight str appropriately.
(ivy--format-minibuffer-line): Don't re-highlight str for
`ivy--regex-fuzzy', it was already highlighted by `ivy--flx-sort'.
Re #207
---
ivy.el | 33 ++++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/ivy.el b/ivy.el
index 2e9b586..2601647 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1978,6 +1978,13 @@ Prefix matches to NAME are put ahead of the list."
(defun ivy-recompute-index-zero (_re-str _cands)
0)
+(defcustom ivy-minibuffer-faces
+ '(ivy-minibuffer-match-face-1
+ ivy-minibuffer-match-face-2
+ ivy-minibuffer-match-face-3
+ ivy-minibuffer-match-face-4)
+ "List of `ivy' faces for minibuffer group matches.")
+
(defun ivy--flx-sort (name cands)
"Sort according to closeness to string NAME the string list CANDS."
(condition-case nil
@@ -1990,15 +1997,25 @@ Prefix matches to NAME are put ahead of the list."
(delq nil
(mapcar
(lambda (x)
- (let ((score (car (flx-score x flx-name
ivy--flx-cache))))
+ (let ((score (flx-score x flx-name ivy--flx-cache)))
(and score
(cons score x))))
cands))))
(if cands-with-score
- (mapcar #'cdr
+ (mapcar (lambda (x)
+ (let ((str (copy-sequence (cdr x)))
+ (i 1))
+ (dolist (j (cdar x))
+ (ivy-add-face-text-property
+ j (1+ j)
+ (nth (1+ (mod (+ i 2) (1- (length
ivy-minibuffer-faces))))
+ ivy-minibuffer-faces)
+ str)
+ (cl-incf i))
+ str))
(sort cands-with-score
(lambda (x y)
- (> (car x) (car y)))))
+ (> (caar x) (caar y)))))
cands))
cands)
(error
@@ -2064,13 +2081,6 @@ SEPARATOR is used to join the candidates."
cand-pairs
""))
-(defcustom ivy-minibuffer-faces
- '(ivy-minibuffer-match-face-1
- ivy-minibuffer-match-face-2
- ivy-minibuffer-match-face-3
- ivy-minibuffer-match-face-4)
- "List of `ivy' faces for minibuffer group matches.")
-
(defun ivy-add-face-text-property (start end face str)
(if (fboundp 'add-face-text-property)
(add-face-text-property
@@ -2081,7 +2091,8 @@ SEPARATOR is used to join the candidates."
(defun ivy--format-minibuffer-line (str)
(let ((start 0)
(str (copy-sequence str)))
- (when (eq ivy-display-style 'fancy)
+ (when (and (eq ivy-display-style 'fancy)
+ (not (eq ivy--regex-function 'ivy--regex-fuzzy)))
(unless ivy--old-re
(setq ivy--old-re (funcall ivy--regex-function ivy-text)))
(while (and (string-match ivy--old-re str start)
- [elpa] master adfad96 007/272: support imenu, (continued)
- [elpa] master adfad96 007/272: support imenu, Oleh Krehel, 2016/04/25
- [elpa] master d09a16b 011/272: swiper.el (swiper-font-lock-ensure): Add bongo-playlist-mode, Oleh Krehel, 2016/04/25
- [elpa] master a0f1e25 021/272: ivy.el (ivy-completion-in-region): Fix log 0 issue, Oleh Krehel, 2016/04/25
- [elpa] master df1dc78 019/272: counsel.el (counsel-find-file): Add initial-input, Oleh Krehel, 2016/04/25
- [elpa] master 2ea56ec 027/272: ivy.el (ivy-occur): Fix when ivy--old-re isn't a string, Oleh Krehel, 2016/04/25
- [elpa] master db3e7ff 015/272: Ensure the return result of `ivy-read', Oleh Krehel, 2016/04/25
- [elpa] master e070f4c 022/272: ivy.el (ivy-add-face-text-property): New defun, Oleh Krehel, 2016/04/25
- [elpa] master 89ed4d6 024/272: Improve flx highlighting, Oleh Krehel, 2016/04/25
- [elpa] master 09cb5c9 025/272: ivy: fix ivy--resize-minibuffer-to-fit for small delta, Oleh Krehel, 2016/04/25
- [elpa] master 6051225 020/272: Call ivy-set-actions with t to affect all commands, Oleh Krehel, 2016/04/25
- [elpa] master 12523d0 023/272: Use flx for highlighting fuzzy matches,
Oleh Krehel <=
- [elpa] master 1cd501a 029/272: ivy.el (ivy-completion-in-region): Optimize for 1 cand, Oleh Krehel, 2016/04/25
- [elpa] master 0c844c1 030/272: ivy.el (ivy-completion-in-region): Fix for 1 cand, Oleh Krehel, 2016/04/25
- [elpa] master b5dc239 032/272: counsel.el (counsel--async-sentinel): Fix issue with ivy--regex-ignore-order, Oleh Krehel, 2016/04/25
- [elpa] master b3cd0d5 016/272: ivy.el (ivy-mode): Set completing-read-function, Oleh Krehel, 2016/04/25
- [elpa] master 89ed19e 035/272: ivy.el (ivy--regex-plus): Prettify a bit, Oleh Krehel, 2016/04/25
- [elpa] master 2135752 040/272: counsel.el (counsel--async-filter): Fix up, Oleh Krehel, 2016/04/25
- [elpa] master 426cfcb 028/272: ivy.el (ivy-completion-in-region): Fix a few bugs, Oleh Krehel, 2016/04/25
- [elpa] master a526e86 041/272: Refactor swiper-font-lock-ensure, Oleh Krehel, 2016/04/25
- [elpa] master 0d410d3 047/272: ivy.el (ivy-flx-limit): Configure when flx is used, Oleh Krehel, 2016/04/25
- [elpa] master c210bf6 050/272: counsel.el (counsel-tmm): Fix tmm free variable, Oleh Krehel, 2016/04/25