1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Consider key=val labels when renumbering

* lisp/textmodes/reftex-global.el (reftex-translate): Recognize
key=val labels given in the optional or mandatory argument of
environments (AUCTeX bug#57720).

* test/lisp/textmodes/reftex-tests.el
(reftex-renumber-simple-labels): New Test.
This commit is contained in:
Arash Esbati 2022-09-12 09:34:23 +02:00
parent 2a4f2ba91a
commit 191c4fe249
2 changed files with 208 additions and 2 deletions

View file

@ -276,7 +276,18 @@ one with the `xr' package."
;; to ignore the problematic string.
;; If TEST is nil, it is ignored without query.
;; Return the number of replacements.
(let ((n 0) file label match-data buf macro pos cell)
(let ((n 0)
(opt-re (concat "\\(?:{[^}{]*"
"\\(?:{[^}{]*"
"\\(?:{[^}{]*}[^}{]*\\)*"
"}[^}{]*\\)*"
"}[^][]*\\)*"))
(man-re (concat "\\(?:{[^}{]*"
"\\(?:{[^}{]*"
"\\(?:{[^}{]*}[^}{]*\\)*"
"}[^}{]*\\)*"
"}[^}{]*\\)*"))
file label match-data buf macro pos cell)
(while (setq file (pop files))
(setq buf (reftex-get-file-buffer-force file))
(unless buf
@ -301,7 +312,29 @@ one with the `xr' package."
(looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]")
(looking-at (format
reftex-find-label-regexp-format
(regexp-quote label)))))
(regexp-quote label)))
;; In case the label-keyval is inside an
;; optional argument to \begin{env}
(looking-at (concat
"\\\\begin[[:space:]]*{[^}]+}"
"[[:space:]]*"
"\\[[^][]*"
opt-re
(format
reftex-find-label-regexp-format
(regexp-quote label))
"[^]]*\\]"))
;; In case the label-keyval is inside the
;; first mandatory argument to \begin{env}
(looking-at (concat
"\\\\begin[[:space:]]*{[^}]+}"
"[[:space:]]*"
"{[^}{]*"
man-re
(format
reftex-find-label-regexp-format
(regexp-quote label))
"[^}]*}"))))
;; OK, we should replace it.
(set-match-data match-data)
(cond