[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8d754de 17/54: ivy.el (ivy-display-style): New defcustom
From: |
Oleh Krehel |
Subject: |
[elpa] master 8d754de 17/54: ivy.el (ivy-display-style): New defcustom |
Date: |
Tue, 29 Sep 2015 14:09:52 +0000 |
branch: master
commit 8d754dea08ff492ca01fd087c13d0356b8492a7e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-display-style): New defcustom
* ivy.el (ivy--format): Add additional highlighting for the minibuffer,
similar to `swiper', when `ivy-display-style' is set to 'fancy.
Fixes #212
---
ivy.el | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/ivy.el b/ivy.el
index 48f3e12..3534099 100644
--- a/ivy.el
+++ b/ivy.el
@@ -78,6 +78,17 @@ and the candidate count."
"Whether to wrap around after the first and last candidate."
:type 'boolean)
+(defcustom ivy-display-style nil
+ "The style for formatting the minibuffer.
+
+By default, the matched strings will be copied as they are.
+
+With the fancy method, the matching parts of the regexp will be
+additionally highlighted, just like `swiper' does it."
+ :type '(choice
+ (const :tag "Plain" nil)
+ (const :tag "Fancy" fancy)))
+
(defcustom ivy-on-del-error-function 'minibuffer-keyboard-quit
"The handler for when `ivy-backward-delete-char' throws.
This is usually meant as a quick exit out of the minibuffer."
@@ -1509,7 +1520,8 @@ CANDS is a list of strings."
(end (min (+ start (1- ivy-height)) ivy--length))
(start (max 0 (min start (- end (1- ivy-height)))))
(cands (cl-subseq cands start end))
- (index (- ivy--index start)))
+ (index (- ivy--index start))
+ (re (funcall ivy--regex-function ivy-text)))
(when ivy--directory
(setq cands (mapcar (lambda (x)
(if (string-match-p "/\\'" x)
@@ -1521,7 +1533,28 @@ CANDS is a list of strings."
(ivy--add-face ivy--current 'ivy-current-match))
(setq cands (mapcar
(lambda (s)
- (let ((s (copy-sequence s)))
+ (let ((start 0)
+ (s (copy-sequence s)))
+ (when (eq ivy-display-style 'fancy)
+ (while (and (string-match re s start)
+ (> (- (match-end 0) (match-beginning 0))
0))
+ (setq start (match-end 0))
+ (let ((i 0))
+ (while (<= i ivy--subexps)
+ (let ((face
+ (cond ((zerop ivy--subexps)
+ (cadr swiper-faces))
+ ((zerop i)
+ (car swiper-faces))
+ (t
+ (nth (1+ (mod (+ i 2) (1- (length
swiper-faces))))
+ swiper-faces)))))
+ (set-text-properties
+ (match-beginning i)
+ (match-end i)
+ `(face ,face)
+ s))
+ (cl-incf i)))))
(when (fboundp 'add-face-text-property)
(add-face-text-property
0 (length s)
- [elpa] master 8b73497 54/54: Merge commit 'ba49407c5b4c719dd5dcc298c260513abf0c70df' from swiper, (continued)
- [elpa] master 8b73497 54/54: Merge commit 'ba49407c5b4c719dd5dcc298c260513abf0c70df' from swiper, Oleh Krehel, 2015/10/07
- [elpa] master 9413acb 52/54: counsel.el (counsel--find-symbol): Allow to jump back with pop-tag-mark, Oleh Krehel, 2015/10/07
- [elpa] master aa3e1dd 51/54: swiper.el (swiper-font-lock-ensure): Add mu4e, Oleh Krehel, 2015/10/07
- [elpa] master 680f6e2 44/54: swiper.el (swiper--ivy): Use minibuffer-allow-text-properties, Oleh Krehel, 2015/10/07
- [elpa] master 5fef653 08/54: ivy.el (ivy-completing-read): Fix up last commit, Oleh Krehel, 2015/10/07
- [elpa] master 1f93f40 16/54: counsel.el (counsel-cl): New command, Oleh Krehel, 2015/10/07
- [elpa] master 67cd682 06/54: Fix #126 again., Oleh Krehel, 2015/10/07
- [elpa] master 1f64cb8 11/54: ivy: enlarge the minibuffer window if the candiate list doesn't fit, Oleh Krehel, 2015/10/07
- [elpa] master f164cfe 33/54: counsel.el (counsel-yank-pop): New command, Oleh Krehel, 2015/10/07
- [elpa] master 03d93f7 40/54: ivy.el (ivy-switch-buffer): Make "M-o r" rename buffer, Oleh Krehel, 2015/10/07
- [elpa] master 8d754de 17/54: ivy.el (ivy-display-style): New defcustom,
Oleh Krehel <=
- [elpa] master efd1f09 48/54: Make ivy-display-style more compatible with 24.3, Oleh Krehel, 2015/10/07
- [elpa] master b45d10c 43/54: Revert multiple frames workaround, Oleh Krehel, 2015/10/07
- [elpa] master 3ce7df8 49/54: Truncate minibuffer prompts longer than window-width, Oleh Krehel, 2015/10/07
- [elpa] master 78499dd 22/54: Add default values for minibuffer faces, Oleh Krehel, 2015/10/07
- [elpa] master dad8183 23/54: Make the minibuffer faces look nicer, Oleh Krehel, 2015/10/07
- [elpa] master 4b17d9a 27/54: Fix up the "foo ! bar" matching and highlighting, Oleh Krehel, 2015/10/07
- [elpa] master d3f1f2c 18/54: Add extra faces for minibuffer highlighting, Oleh Krehel, 2015/10/07
- [elpa] master 1bf45be 21/54: ivy.el (ivy--format-minibuffer-line): Fix nil regexp, Oleh Krehel, 2015/10/07
- [elpa] master e03d968 50/54: ivy.el (ivy--insert-prompt): Avoid negative length error, Oleh Krehel, 2015/10/07
- [elpa] master 7a2070b 45/54: Fix minibuffer collapse in text mode emacs, Oleh Krehel, 2015/10/07