Function: embark-consult--export-grep
embark-consult--export-grep is a natively compiled function defined in
embark-consult.el.
Signature
(embark-consult--export-grep &key HEADER LINES INSERT FOOTER)
Documentation
Create a grep mode buffer listing LINES.
The HEADER string is inserted at the top of the buffer. The function INSERT is called to insert the LINES and should return a count of the matches (there may be more than one match per line). The function FOOTER is called to insert a footer.
Source Code
;; Defined in /nix/store/9j1lpwknj0cd46jf87pww3rp6rcmnk70-emacs-packages-deps/share/emacs/site-lisp/elpa/embark-consult-20260503.118/embark-consult.el
(cl-defun embark-consult--export-grep (&key header lines insert footer)
"Create a grep mode buffer listing LINES.
The HEADER string is inserted at the top of the buffer. The
function INSERT is called to insert the LINES and should return a
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
(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))
(goto-char (point-max))
;; 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))
(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
;; restores our binding too when the user finishes editing.
(use-local-map (make-composed-keymap
embark-consult-rerun-map
(current-local-map)))
;; 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)))