I am trying to come up with a Elisp function that narrows a buffer to a certain LaTeX enviroment (table, figures, ...), does some query-replace-regexp
inside the narrowing, then searches for the next occurrence of the environment and does the same, until the last occurrence of the environment.
I have come up with this:
(defun narrowtable ()
"narrowing on table environment"
(interactive)
(beginning-of-buffer)
(save-excursion
(search-forward "begin{table}")
(LaTeX-narrow-to-environment)
(goto-char (point-min))
(query-replace "X" "B"); Just some query-replace
(widen)))
which works for fine the first occurence of {table}, but only for that.
I guess I misplaced save-excursion
for this to work properly, or there is something other to improve?