[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/anzu 1eceed7498 196/288: Merge pull request #51 from syohe
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/anzu 1eceed7498 196/288: Merge pull request #51 from syohex/highlight-matching-groups |
Date: |
Thu, 6 Jan 2022 03:58:52 -0500 (EST) |
branch: elpa/anzu
commit 1eceed7498a406af52319b19a8e6bf32be2cfa19
Merge: f41db6225d 494f1d9d39
Author: Syohei YOSHIDA <syohex@gmail.com>
Commit: Syohei YOSHIDA <syohex@gmail.com>
Merge pull request #51 from syohex/highlight-matching-groups
Support highlighting match groups
---
anzu.el | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 52 insertions(+), 5 deletions(-)
diff --git a/anzu.el b/anzu.el
index 373d3853f4..4a3cae247a 100644
--- a/anzu.el
+++ b/anzu.el
@@ -110,6 +110,33 @@
"highlight of replaced string"
:group 'anzu)
+(defface anzu-match-1
+ '((((class color) (background light))
+ :background "aquamarine" :foreground "black")
+ (((class color) (background dark))
+ :background "limegreen" :foreground "black")
+ (t :inverse-video t))
+ "First group of match."
+ :group 'anzu)
+
+(defface anzu-match-2
+ '((((class color) (background light))
+ :background "springgreen" :foreground "black")
+ (((class color) (background dark))
+ :background "yellow" :foreground "black")
+ (t :inverse-video t))
+ "Second group of match."
+ :group 'anzu)
+
+(defface anzu-match-3
+ '((((class color) (background light))
+ :background "yellow" :foreground "black")
+ (((class color) (background dark))
+ :background "aquamarine" :foreground "black")
+ (t :inverse-video t))
+ "Third group of match."
+ :group 'anzu)
+
(defface anzu-replace-to
'((((class color) (background light))
:foreground "red")
@@ -314,11 +341,31 @@
(set-marker m beg buf)
(push m anzu--replaced-markers)))
+(defun anzu--make-overlay (begin end face prio)
+ (let ((ov (make-overlay begin end)))
+ (overlay-put ov 'face face)
+ (overlay-put ov 'priority prio)
+ (overlay-put ov 'anzu-overlay t)
+ ov))
+
+(defun anzu--add-match-group-overlay (match-data groups)
+ (when (>= groups 3)
+ (anzu--make-overlay (cl-fifth match-data) (cl-sixth match-data)
+ 'anzu-match-3 1001))
+ (when (>= groups 2)
+ (anzu--make-overlay (cl-third match-data) (cl-fourth match-data)
+ 'anzu-match-2 1001))
+ (anzu--make-overlay (cl-first match-data) (cl-second match-data)
+ 'anzu-match-1 1001))
+
(defun anzu--add-overlay (beg end)
- (let ((ov (make-overlay beg end)))
- (overlay-put ov 'from-string (buffer-substring-no-properties beg end))
- (overlay-put ov 'face 'anzu-replace-highlight)
- (overlay-put ov 'anzu-replace t)))
+ (let* ((match-data (match-data))
+ (groups (/ (- (length match-data) 2) 2)))
+ (when (>= groups 1)
+ (anzu--add-match-group-overlay (cddr match-data) groups))
+ (let ((ov (anzu--make-overlay beg end 'anzu-replace-highlight 1000)))
+ (overlay-put ov 'from-string (buffer-substring-no-properties beg end))
+ (overlay-put ov 'anzu-replace t))))
(defsubst anzu--cleanup-markers ()
(mapc (lambda (m) (set-marker m nil)) anzu--replaced-markers)
@@ -405,7 +452,7 @@
(defun anzu--clear-overlays (buf beg end)
(with-current-buffer buf
(dolist (ov (overlays-in (or beg (point-min)) (or end (point-max))))
- (when (overlay-get ov 'anzu-replace)
+ (when (overlay-get ov 'anzu-overlay)
(delete-overlay ov)))))
(defun anzu--transform-from-to-history ()
- [nongnu] elpa/anzu cf3370967b 170/288: Refactoring for evil-anzu, (continued)
- [nongnu] elpa/anzu cf3370967b 170/288: Refactoring for evil-anzu, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 53db7f64b7 177/288: Reduce condition check, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu cb20bdcbfe 167/288: Merge pull request #40 from syohex/improve-replace-command, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b723c16507 172/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu db819bfb06 184/288: Merge pull request #47 from syohex/fix-46, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 4d81f2f0cd 192/288: Fix order of conditions in cond, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu f41db6225d 194/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 07b7802d9d 212/288: Fix literal replace, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu b11642d49c 207/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 88a7059601 236/288: Implement isearch-query-replace- like commands, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 1eceed7498 196/288: Merge pull request #51 from syohex/highlight-matching-groups,
ELPA Syncer <=
- [nongnu] elpa/anzu dde4d83cfa 235/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 1ce32470dd 200/288: Merge pull request #54 from syohex/check-from-regexp, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu faae95ccd9 237/288: Update document, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 008c2659b1 208/288: Use https, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu c05a8ac594 206/288: Merge pull request #57 from syohex/fix-typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu de3d805c9a 211/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 9c821d182c 217/288: Bump up version and update Changes, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu ed5e91b0c4 259/288: Add face at no-match case, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu 9574e8140f 247/288: Merge pull request #76 from Fuco1/bugfix/fix-customize-type, ELPA Syncer, 2022/01/06
- [nongnu] elpa/anzu be16738cb7 250/288: Merge pull request #80 from syohex/replace-with-region, ELPA Syncer, 2022/01/06