I have this LaTeX code:
\caption{Lorem ipsum dolor sit amet: foo), bar), baz) and qux) consectetuer adipiscing elit.}
I want to put a marker immediately before the first {
and one immediately after its corresponding }
.
forward-list
is my usual choice in order to find balanced parentheses, but in this case it is not suitable because it moves cursor immediately after the first )
(as its standard behaviour).
How can I do this?
;; my standard way
(while (re-search-forward "\\\\\\<caption\\>" nil t)
(setq pos1 (point-marker))
(set-marker-insertion-type pos1 t)
(forward-list)
(setq pos2 (point-marker))
(set-marker-insertion-type pos2 t)
(save-excursion
(save-restriction
(narrow-to-region pos1 pos2)
(goto-char (point-min))
;; do something
)))
Updates
I have found an answer here:
Function forward-pexp
does the trick.