branch: externals/embark
commit a563786d0e07fc43601c1c83d1ffc801b86506b9
Merge: 1f47c4ece2 eca973cee2
Author: Omar AntolĂ­n Camarena <omar.anto...@gmail.com>
Commit: GitHub <nore...@github.com>

    Merge pull request #763 from minad/fix-grep-export
    
    embark-consult--export-grep: Call compilation--ensure-parse
---
 embark-consult.el | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/embark-consult.el b/embark-consult.el
index 6c61affe65..80e5c866c7 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -210,7 +210,7 @@ This function is meant to be added to 
`embark-collect-mode-hook'."
 
 (defvar grep-mode-line-matches)
 (defvar grep-num-matches-found)
-(declare-function wgrep-setup "ext:wgrep")
+(declare-function compilation--ensure-parse "compile")
 
 (defvar-keymap embark-consult-rerun-map
   :doc "A keymap with a binding for `embark-rerun-collect-or-export'."
@@ -232,7 +232,11 @@ The function FOOTER is called to insert a footer."
         (dlet ((compilation-filter-start (point)))
           (setq-local grep-num-matches-found (funcall insert lines))
           (goto-char (point-max))
-          ;; Emacs 30 feature `grep-use-headings'
+          ;; Ensure that all `compilation-message' text properties are added.
+          (compilation--ensure-parse (point))
+          ;; Instead of (run-hooks 'compilation-filter-hook), we only run the
+          ;; Emacs 30 grep heading filter. The other `compilation-filter-hook'
+          ;; functions handle escape sequences, which we do not need here.
           (when (and (bound-and-true-p grep-use-headings)
                      (fboundp 'grep--heading-filter))
             (grep--heading-filter))
@@ -245,13 +249,15 @@ The function FOOTER is called to insert a footer."
       (use-local-map (make-composed-keymap
                       embark-consult-rerun-map
                       (current-local-map)))
-      ;; TODO Wgrep 3.0 and development versions use different names for the
-      ;; parser variable.
-      (defvar wgrep-header/footer-parser)
-      (defvar wgrep-header&footer-parser)
-      (setq-local wgrep-header/footer-parser #'ignore
-                  wgrep-header&footer-parser #'ignore)
-      (when (fboundp 'wgrep-setup) (wgrep-setup)))
+      ;; NOTE Wgrep is not needed anymore on Emacs 31 with `grep-edit-mode'.
+      (when (fboundp 'wgrep-setup)
+        ;; TODO Wgrep 3.0 and development versions use different names for the
+        ;; parser variable.
+        (defvar wgrep-header/footer-parser)
+        (defvar wgrep-header&footer-parser)
+        (setq-local wgrep-header/footer-parser #'ignore
+                    wgrep-header&footer-parser #'ignore)
+        (wgrep-setup)))
     (pop-to-buffer buf)))
 
 (defun embark-consult-export-grep (lines)

Reply via email to