The context for this is that I was trying to write a function to help me write LaTeX, specifically I'd like to list all the future references, i.e. when you use a \ref{<something>}
before \label{<something>}
. I managed to write a regex that searches for this pattern, and my attempt is:
(defun get-forward-refs ()
"List in an occur buffer all the future references of the current file."
(interactive)
(occur
(rx (regex "\\ref{") (group (+ not-newline)) "}"
(+ anything)
(regex "\\label{") (backref 1) "}")
))
It works, but occur annoyingly displays ALL the match, which in this case could span several lines, so that I cannot quickly navigate the list (which was the purpose of this). The docstring of occur explicitly says "If a match spreads across multiple lines, all those lines are shown.". My question is: can I tweak this behavior, so that occur shows only the first line of the match? Thanks.