Function: embark-consult-export-location-grep
embark-consult-export-location-grep is a natively compiled function
defined in embark-consult.el.
Signature
(embark-consult-export-location-grep LINES)
Documentation
Create a grep mode buffer listing LINES.
Any LINES that come from a buffer which is not visiting a file
will be excluded from the grep buffer, since grep mode only works
with files. The elements of LINES should be completion
candidates with category consult-location. No matches will be
highlighted in the exported buffer, since the consult-location
candidates do not carry that information.
Source Code
;; Defined in /nix/store/9j1lpwknj0cd46jf87pww3rp6rcmnk70-emacs-packages-deps/share/emacs/site-lisp/elpa/embark-consult-20260503.118/embark-consult.el
(defun embark-consult-export-location-grep (lines)
"Create a grep mode buffer listing LINES.
Any LINES that come from a buffer which is not visiting a file
will be excluded from the grep buffer, since grep mode only works
with files. The elements of LINES should be completion
candidates with category `consult-location'. No matches will be
highlighted in the exported buffer, since the `consult-location'
candidates do not carry that information."
(let (non-file-buffers)
(embark-consult--export-grep
:header "Exported line search results (file-backed buffers only):\n\n"
:lines lines
:insert
(lambda (lines)
(let ((count 0))
(dolist (line lines)
(pcase-let* ((`(,loc . ,num) (consult--get-location line))
(lineno (format "%d" num))
(contents (embark-consult--strip line))
(buffer (marker-buffer loc))
(file (buffer-file-name buffer)))
(if (null file)
(cl-pushnew buffer non-file-buffers)
(insert (file-relative-name file) ":" lineno ":" contents "\n")
(incf count))))
count))
:footer
(lambda ()
(when non-file-buffers
(let ((start (goto-char (point-max))))
(insert "\nSome results were in buffers with no associated file"
" and are missing\nfrom the exported result:\n")
(dolist (buf non-file-buffers)
(insert "- " (buffer-name buf) "\n"))
(insert "\nEither save the buffers or use the"
" `embark-consult-export-location-occur'\nexporter.")
(message "This exporter does not support non-file buffers: %s"
non-file-buffers)
(add-text-properties
start (point-max)
'(read-only t wgrep-footer t front-sticky t))))))))