[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d3f1f2c 18/54: Add extra faces for minibuffer highlighting
From: |
Oleh Krehel |
Subject: |
[elpa] master d3f1f2c 18/54: Add extra faces for minibuffer highlighting |
Date: |
Tue, 29 Sep 2015 14:09:52 +0000 |
branch: master
commit d3f1f2ce8f9763cea546bbd2717cbcf17b9a0ad7
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add extra faces for minibuffer highlighting
* swiper.el (swiper-minibuffer-match-face-1):
(swiper-minibuffer-match-face-2):
(swiper-minibuffer-match-face-3):
(swiper-minibuffer-match-face-4): New defface.
(swiper-minibuffer-faces): New defvar.
* ivy.el (ivy--format-minibuffer-line): New defun.
(ivy--format): Use `ivy--format-minibuffer-line'.
---
ivy.el | 63 +++++++++++++++++++++++++++++++------------------------------
swiper.el | 23 ++++++++++++++++++++++
2 files changed, 55 insertions(+), 31 deletions(-)
diff --git a/ivy.el b/ivy.el
index 3534099..5b9239a 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1507,6 +1507,36 @@ This string will be inserted into the minibuffer.")
s))
cands "\n")))
+(defun ivy--format-minibuffer-line (str)
+ (let ((start 0)
+ (str (copy-sequence str)))
+ (when (eq ivy-display-style 'fancy)
+ (while (and (string-match ivy--old-re str 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-minibuffer-faces))
+ ((zerop i)
+ (car swiper-minibuffer-faces))
+ (t
+ (nth (1+ (mod (+ i 2) (1- (length
swiper-minibuffer-faces))))
+ swiper-minibuffer-faces)))))
+ (set-text-properties
+ (match-beginning i)
+ (match-end i)
+ `(face ,face)
+ str))
+ (cl-incf i)))))
+ (when (fboundp 'add-face-text-property)
+ (add-face-text-property
+ 0 (length str)
+ `(:height ,(face-attribute 'default :height)
+ :overline nil) nil str))
+ str))
+
(defun ivy--format (cands)
"Return a string for CANDS suitable for display in the minibuffer.
CANDS is a list of strings."
@@ -1520,8 +1550,7 @@ 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))
- (re (funcall ivy--regex-function ivy-text)))
+ (index (- ivy--index start)))
(when ivy--directory
(setq cands (mapcar (lambda (x)
(if (string-match-p "/\\'" x)
@@ -1532,35 +1561,7 @@ CANDS is a list of strings."
(setf (nth index cands)
(ivy--add-face ivy--current 'ivy-current-match))
(setq cands (mapcar
- (lambda (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)
- `(:height ,(face-attribute 'default :height)
- :overline nil) nil s))
- s))
+ #'ivy--format-minibuffer-line
cands))
(let* ((ivy--index index)
(res (concat "\n" (funcall ivy-format-function cands))))
diff --git a/swiper.el b/swiper.el
index 6576ab3..c97f9c8 100644
--- a/swiper.el
+++ b/swiper.el
@@ -61,6 +61,22 @@
'((t (:inherit isearch-fail)))
"Face for `swiper' matches modulo 3.")
+(defface swiper-minibuffer-match-face-1
+ '((t (:inherit isearch-lazy-highlight-face)))
+ "The background face for `swiper' minibuffer matches.")
+
+(defface swiper-minibuffer-match-face-2
+ '((t (:inherit isearch)))
+ "Face for `swiper' minibuffer matches modulo 1.")
+
+(defface swiper-minibuffer-match-face-3
+ '((t (:inherit match)))
+ "Face for `swiper' minibuffer matches modulo 2.")
+
+(defface swiper-minibuffer-match-face-4
+ '((t (:inherit isearch-fail)))
+ "Face for `swiper' minibuffer matches modulo 3.")
+
(defface swiper-line-face
'((t (:inherit highlight)))
"Face for current `swiper' line.")
@@ -71,6 +87,13 @@
swiper-match-face-4)
"List of `swiper' faces for group matches.")
+(defcustom swiper-minibuffer-faces
+ '(swiper-minibuffer-match-face-1
+ swiper-minibuffer-match-face-2
+ swiper-minibuffer-match-face-3
+ swiper-minibuffer-match-face-4)
+ "List of `swiper' faces for minibuffer group matches.")
+
(defcustom swiper-min-highlight 2
"Only highlight matches for regexps at least this long."
:type 'integer)
- [elpa] master 1f64cb8 11/54: ivy: enlarge the minibuffer window if the candiate list doesn't fit, (continued)
- [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, 2015/10/07
- [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 <=
- [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
- [elpa] master ba49407 53/54: counsel.el (counsel-ag-function): Improve for fancy faces, Oleh Krehel, 2015/10/07
- [elpa] master 00d8f08 12/54: counsel.el (counsel-org-tag): Now works in agenda, Oleh Krehel, 2015/10/07
- [elpa] master 860e276 13/54: Add swiper-multi command, Oleh Krehel, 2015/10/07
- [elpa] master 5269b79 07/54: When initial input contains a plus, escape it, Oleh Krehel, 2015/10/07
- [elpa] master 59908cd 20/54: Make ivy-current blend correctly for fancy minibuffer, Oleh Krehel, 2015/10/07
- [elpa] master 5eac62d 26/54: Move swiper-minibuffer-faces to ivy.el, Oleh Krehel, 2015/10/07
- [elpa] master d374afe 31/54: Set truncate-lines in the minibuffer, Oleh Krehel, 2015/10/07