[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult 962f19837d 1/2: Highlight all matches of each r
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult 962f19837d 1/2: Highlight all matches of each regexp in consult-grep (#699) |
Date: |
Sun, 11 Dec 2022 05:57:24 -0500 (EST) |
branch: externals/consult
commit 962f19837dbbc98df8b6ffe4c9a4a62edc700e75
Author: Augusto Stoffel <astoff@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Highlight all matches of each regexp in consult-grep (#699)
---
consult.el | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/consult.el b/consult.el
index c79f947c28..98fd381b73 100644
--- a/consult.el
+++ b/consult.el
@@ -655,16 +655,18 @@ If no capturing groups are used highlight the whole
match. Case is ignored
if IGNORE-CASE is non-nil."
(let ((case-fold-search ignore-case))
(dolist (re regexps)
- (when (string-match re str)
- ;; Unfortunately there is no way to avoid the allocation of the match
- ;; data, since the number of capturing groups is unknown.
- (let ((m (match-data)))
- (setq m (or (cddr m) m))
- (while m
- (when (car m)
- (add-face-text-property (car m) (cadr m)
- 'consult-highlight-match nil str))
- (setq m (cddr m))))))))
+ (let ((i 0))
+ (while (string-match re str i)
+ ;; Unfortunately there is no way to avoid the allocation of the match
+ ;; data, since the number of capturing groups is unknown.
+ (let ((m (match-data)))
+ (setq i (cadr m))
+ (setq m (or (cddr m) m))
+ (while m
+ (when (car m)
+ (add-face-text-property (car m) (cadr m)
+ 'consult-highlight-match nil str))
+ (setq m (cddr m)))))))))
(defconst consult--convert-regexp-table
(append