[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark f9311dedca 1/2: Add match highlight and count to
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark f9311dedca 1/2: Add match highlight and count to grep export |
Date: |
Tue, 13 Dec 2022 14:57:39 -0500 (EST) |
branch: externals/embark
commit f9311dedca0fdd8a876041837bf536a5ecc6fd2b
Author: Augusto Stoffel <arstoffel@gmail.com>
Commit: Augusto Stoffel <arstoffel@gmail.com>
Add match highlight and count to grep export
---
embark-consult.el | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/embark-consult.el b/embark-consult.el
index d5603024a6..8b0a39570a 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -155,6 +155,8 @@ This function is meant to be added to
`embark-collect-mode-hook'."
;;; Support for consult-grep
+(defvar grep-mode-line-matches)
+(defvar grep-num-matches-found)
(defvar wgrep-header/footer-parser)
(declare-function wgrep-setup "ext:wgrep")
@@ -165,12 +167,25 @@ This function is meant to be added to
`embark-collect-mode-hook'."
(defun embark-consult-export-grep (lines)
"Create a grep mode buffer listing LINES."
- (let ((buf (generate-new-buffer "*Embark Export Grep*")))
+ (let ((buf (generate-new-buffer "*Embark Export Grep*"))
+ (count 0)
+ prop)
(with-current-buffer buf
(insert (propertize "Exported grep results:\n\n" 'wgrep-header t))
(dolist (line lines) (insert line "\n"))
(goto-char (point-min))
+ (while (setq prop (text-property-search-forward
+ 'face 'consult-highlight-match t))
+ (cl-incf count)
+ (put-text-property (prop-match-beginning prop)
+ (prop-match-end prop)
+ 'font-lock-face
+ 'match))
+ (goto-char (point-min))
(grep-mode)
+ (when (> count 0)
+ (setq-local grep-num-matches-found count
+ mode-line-process grep-mode-line-matches))
;; Make this buffer current for next/previous-error
(setq next-error-last-buffer buf)
;; Set up keymap before possible wgrep-setup, so that wgrep
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/embark f9311dedca 1/2: Add match highlight and count to grep export,
ELPA Syncer <=