Function: xref--parse-hits
xref--parse-hits is a byte-compiled function defined in xref.el.gz.
Signature
(xref--parse-hits GREP-RE LINE-GROUP FILE-GROUP STATUS &optional PARENT-DIR)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--parse-hits ( grep-re line-group file-group status
&optional parent-dir)
(let (hits)
(goto-char (point-min))
;; Can't use the exit status: Grep exits with 1 to mean "no
;; matches found". Find exits with 1 if any of the invocations
;; exit with non-zero. "No matches" and "Grep program not found"
;; are all the same to it.
(when (and (/= (point-min) (point-max))
(not (looking-at grep-re))
;; TODO: Show these matches as well somehow?
;; Matching both Grep's and Ripgrep 13's messages.
(not (looking-at ".*[bB]inary file.* matches")))
(user-error "Search failed with status %d: %s" status
(buffer-substring (point-min) (line-end-position))))
(while (re-search-forward grep-re nil t)
(push (list (string-to-number (match-string line-group))
(if parent-dir
(concat parent-dir (substring (match-string file-group) 1))
(match-string file-group))
(buffer-substring-no-properties (point) (line-end-position)))
hits))
(nreverse hits)))