branch: externals/embark
commit 872c1db47649f6891496e984132875025fdd3584
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    Grep export: Support grep-use-headings (Fix #719)
---
 embark-consult.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/embark-consult.el b/embark-consult.el
index b1a543f1e5..24d3992c68 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -225,13 +225,18 @@ count of the matches (there may be more than one match 
per line).
 The function FOOTER is called to insert a footer."
   (let ((buf (generate-new-buffer "*Embark Export Grep*")))
     (with-current-buffer buf
-      (insert (propertize header 'wgrep-header t 'front-sticky t))
-      (let ((count (funcall insert lines)))
-        (funcall footer)
-        (goto-char (point-min))
-        (grep-mode)
-        (setq-local grep-num-matches-found count
-                    mode-line-process grep-mode-line-matches))
+      (grep-mode)
+      (setq-local mode-line-process grep-mode-line-matches)
+      (let ((inhibit-read-only t))
+        (insert (propertize header 'wgrep-header t 'front-sticky t))
+        (dlet ((compilation-filter-start (point)))
+          (setq-local grep-num-matches-found (funcall insert lines))
+          ;; Emacs 30 feature `grep-use-headings'
+          (when (and (bound-and-true-p grep-use-headings)
+                     (fboundp 'grep--heading-filter))
+            (grep--heading-filter))
+          (funcall footer)
+          (goto-char (point-min))))
       ;; Make this buffer current for next/previous-error
       (setq next-error-last-buffer buf)
       ;; Set up keymap before possible wgrep-setup, so that wgrep

Reply via email to