From 1b20a28bb86089aaf9bc0049d8da99fa1d2cc083 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Thu, 16 Jan 2025 21:39:04 +0100 Subject: [PATCH] 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 f95d0bf..d5f86a9 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