Skip to content

Commit

Permalink
add buffer local var rg-match-positions to record all match positions
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyinz authored and dajva committed Sep 8, 2024
1 parent 6f1e39e commit 8c7bdce
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rg-result.el
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ Becomes buffer local in `rg-mode' buffers.")
(defvar-local rg-hit-count 0
"Stores number of hits in a search.")

(defvar-local rg-match-positions nil
"Stores position of matches in a search.
Each element is consists by (match-beginning-marker . match-string-length).")

(defvar-local rg-recompile nil
"Is `recompile' in progress or `compile-start'.")

Expand Down Expand Up @@ -469,8 +473,11 @@ This function is called from `compilation-filter-hook'."
(replace-match (propertize (match-string 1)
'face nil 'font-lock-face 'rg-match-face)
t t)
(push (cons (copy-marker (match-beginning 0))
(length (match-string 0)))
rg-match-positions)
(cl-incf rg-hit-count))

(setq rg-match-positions (nreverse rg-match-positions))
(rg-format-line-and-column-numbers beg end)

;; Delete all remaining escape sequences
Expand Down

0 comments on commit 8c7bdce

Please sign in to comment.