Package: auctex;
Reported by: Wierdl Máté <wierdlmate <at> gmail.com>
Date: Sat, 10 Sep 2022 19:44:01 UTC
Severity: normal
Found in version 13.1.4
Done: Arash Esbati <arash <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57720 in the body.
You can then email your comments to 57720 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-auctex <at> gnu.org
:bug#57720
; Package auctex
.
(Sat, 10 Sep 2022 19:44:01 GMT) Full text and rfc822 format available.Wierdl Máté <wierdlmate <at> gmail.com>
:bug-auctex <at> gnu.org
.
(Sat, 10 Sep 2022 19:44:01 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Wierdl Máté <wierdlmate <at> gmail.com> To: bug-auctex <at> gnu.org Subject: 13.1.4; renumbering simple labels doesn't work with tcolorbox From: "Wierdl Máté" <wierdlmate <at> gmail.com> Date: Sat, 10 Sep 2022 14:42:52 -0500
[Message part 1 (text/plain, inline)]
I do not know if this is a reftex or AUCTeX bug. When using theoremlike environments from the tcolorbox, the function reftex-renumber-simple-labels messes up. It renumbers the labels in references but does nothing to the labels themselves. I start out with \documentclass{article} \usepackage{matyi} \begin{document} \begin{problem}[label={problem:2}]{Prove RH2}{} \end{problem} \begin{equation} \label{eq:2} 2 \end{equation} By \eqref{eq:2} and \ref{problem:2} \begin{problem}[label={problem:1}]{Prove RH1}{} \end{problem} \begin{equation} \label{eq:1} 1 \end{equation} By \eqref{eq:1} and \cref{problem:1}. \end{document} then I do "M-x reftex-renumber-simple-labels" I get the following: (notice how the eq: labels and references got renumbered correctly while the problem: labels didn't get renumbered while their references did get renumbered---making the references incorrect. \documentclass{article} \usepackage{matyi} \begin{document} \begin{problem}[label={problem:2}]{Prove RH2}{} \end{problem} \begin{equation} \label{eq:1} 2 \end{equation} By \eqref{eq:1} and \ref{problem:1} \begin{problem}[label={problem:1}]{Prove RH1}{} \end{problem} \begin{equation} \label{eq:2} 1 \end{equation} By \eqref{eq:2} and \cref{problem:2}. \end{document} I am attaching the used matyi.el file. Thanks, Máté Emacs : GNU Emacs 28.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-07-15 Package: 13.1.4 current state: ============== (setq AUCTeX-date "2022-08-26" window-system 'x LaTeX-version "2e" TeX-style-path '("~/.emacs.d/auctex" "/home/apu/.emacs.d/elpa/auctex-13.1.4/style" "/home/apu/.emacs.d/auctex/auto" "/home/apu/.emacs.d/auctex/style" "auto" "style") TeX-auto-save t TeX-parse-self t TeX-master t TeX-command-list '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) %S%(PDFout)%(mode)%' %(output-dir) %t" TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("Makeinfo" "makeinfo %(extraopts) %(o-dir) %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with Info output") ("Makeinfo HTML" "makeinfo %(extraopts) %(o-dir) --html %t" TeX-run-compile nil (texinfo-mode) :help "Run Makeinfo with HTML output") ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %(output-dir) %t" TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX") ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %(O?aux)" TeX-run-BibTeX nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode context-mode) :help "Run BibTeX") ("Biber" "biber %(output-dir) %s" TeX-run-Biber nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run Biber") ("Texindex" "texindex %s.??" TeX-run-command nil (texinfo-mode) :help "Run Texindex") ("Texi2dvi" "%(PDF)texi2dvi %t" TeX-run-command nil (texinfo-mode) :help "Run Texi2dvi or Texi2pdf") ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Generate PostScript file") ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PostScript") ("Dvipdfmx" "dvipdfmx -o %(O?pdf) %d" TeX-run-dvipdfmx nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert DVI file to PDF with dvipdfmx") ("Ps2pdf" "ps2pdf %f %(O?pdf)" TeX-run-ps2pdf nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Convert PostScript file to PDF") ("Glossaries" "makeglossaries %(d-dir) %s" TeX-run-command nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeglossaries to create glossary file") ("Index" "makeindex %(O?idx)" TeX-run-index nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run makeindex to create index file") ("upMendex" "upmendex %(O?idx)" TeX-run-index t (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run upmendex to create index file") ("Xindy" "texindy %s" TeX-run-command nil (plain-tex-mode latex-mode doctex-mode ams-tex-mode texinfo-mode) :help "Run xindy to create index file") ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for correctness") ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for common mistakes") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("Other" "" TeX-run-command t t :help "Run an arbitrary command") ) )
[Message part 2 (text/html, inline)]
[matyi.el (text/x-emacs-lisp, attachment)]
bug-auctex <at> gnu.org
:bug#57720
; Package auctex
.
(Sun, 11 Sep 2022 10:15:01 GMT) Full text and rfc822 format available.Message #8 received at 57720 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: Wierdl Máté <wierdlmate <at> gmail.com> Cc: 57720 <at> debbugs.gnu.org Subject: Re: bug#57720: 13.1.4; renumbering simple labels doesn't work with tcolorbox Date: Sun, 11 Sep 2022 12:13:06 +0200
Wierdl Máté <wierdlmate <at> gmail.com> writes: > I do not know if this is a reftex or AUCTeX bug. RefTeX. > When using theoremlike environments from the tcolorbox, the function > reftex-renumber-simple-labels messes up. It renumbers the labels in > references but does nothing to the labels themselves. The issue is more in the function `reftex-translate' which is called inside `reftex-renumber-simple-labels': The former is not prepared to deal with labels inside arguments of environments. Can you try this change by copying to scratch buffer, opening your .tex file, eval'ing this function and then running `reftex-renumber-simple-labels' and see if it works? --8<---------------cut here---------------start------------->8--- (defun reftex-translate (files search-re translate-alist error-fmt test) ;; In FILES, look for SEARCH-RE and replace match 1 of it with ;; its association in TRANSLATE-ALIST. ;; If we do not find an association and TEST is non-nil, query ;; 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) (while (setq file (pop files)) (setq buf (reftex-get-file-buffer-force file)) (unless buf (error "No such file %s" file)) (set-buffer buf) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward search-re nil t) (backward-char) (save-excursion (setq label (reftex-match-string 1) cell (assoc label translate-alist) match-data (match-data) macro (reftex-what-macro 1) pos (cdr macro)) (goto-char (or pos (point))) (when (and macro (or (looking-at "\\\\ref") (looking-at "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]") (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]") (looking-at (format reftex-find-label-regexp-format (regexp-quote label))) ;; In case the label-keyval is inside an ;; optional argument to \begin{env} (looking-at (concat "\\\\begin[[:space:]]*{[^}]+}" "[[:space:]]*" "\\[[^][]*" (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:]]*" "{[^}{]*" (format reftex-find-label-regexp-format (regexp-quote label)) "[^}{]*}")))) ;; OK, we should replace it. (set-match-data match-data) (cond ((and test (not cell)) ;; We've got a problem (unwind-protect (progn (reftex-highlight 1 (match-beginning 0) (match-end 0)) (ding) (or (y-or-n-p (format error-fmt label)) (error "Abort"))) (reftex-unhighlight 1))) ((and test cell) (cl-incf n)) ((and (not test) cell) ;; Replace (goto-char (match-beginning 1)) (delete-region (match-beginning 1) (match-end 1)) (insert (cdr cell))) (t nil)))))))) n)) --8<---------------cut here---------------end--------------->8--- TIA. Best, Arash
bug-auctex <at> gnu.org
:bug#57720
; Package auctex
.
(Sun, 11 Sep 2022 18:10:02 GMT) Full text and rfc822 format available.Message #11 received at 57720 <at> debbugs.gnu.org (full text, mbox):
From: Wierdl Máté <wierdlmate <at> gmail.com> To: Arash Esbati <arash <at> gnu.org> Cc: 57720 <at> debbugs.gnu.org Subject: Re: bug#57720: 13.1.4; renumbering simple labels doesn't work with tcolorbox Date: Sun, 11 Sep 2022 13:08:49 -0500
[Message part 1 (text/plain, inline)]
It now seems to work perfectly. I tried it not only on the test file but also on the book I have been working on which loads quite a few .tex files. Should I put this "defun" into my .emacs for the time being, till it gets incorporated into reftex? Thx, Máté Arash Esbati <arash <at> gnu.org> ezt írta (időpont: 2022. szept. 11., V, 5:14): > Wierdl Máté <wierdlmate <at> gmail.com> writes: > > > I do not know if this is a reftex or AUCTeX bug. > > RefTeX. > > > When using theoremlike environments from the tcolorbox, the function > > reftex-renumber-simple-labels messes up. It renumbers the labels in > > references but does nothing to the labels themselves. > > The issue is more in the function `reftex-translate' which is called > inside `reftex-renumber-simple-labels': The former is not prepared to > deal with labels inside arguments of environments. Can you try this > change by copying to scratch buffer, opening your .tex file, eval'ing > this function and then running `reftex-renumber-simple-labels' and see > if it works? > > --8<---------------cut here---------------start------------->8--- > (defun reftex-translate (files search-re translate-alist error-fmt test) > ;; In FILES, look for SEARCH-RE and replace match 1 of it with > ;; its association in TRANSLATE-ALIST. > ;; If we do not find an association and TEST is non-nil, query > ;; 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) > (while (setq file (pop files)) > (setq buf (reftex-get-file-buffer-force file)) > (unless buf > (error "No such file %s" file)) > (set-buffer buf) > (save-excursion > (save-restriction > (widen) > (goto-char (point-min)) > (while (re-search-forward search-re nil t) > (backward-char) > (save-excursion > (setq label (reftex-match-string 1) > cell (assoc label translate-alist) > match-data (match-data) > macro (reftex-what-macro 1) > pos (cdr macro)) > (goto-char (or pos (point))) > (when (and macro > (or (looking-at "\\\\ref") > (looking-at > "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]") > (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]") > (looking-at (format > reftex-find-label-regexp-format > (regexp-quote label))) > ;; In case the label-keyval is inside an > ;; optional argument to \begin{env} > (looking-at (concat > "\\\\begin[[:space:]]*{[^}]+}" > "[[:space:]]*" > "\\[[^][]*" > (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:]]*" > "{[^}{]*" > (format > reftex-find-label-regexp-format > (regexp-quote label)) > "[^}{]*}")))) > ;; OK, we should replace it. > (set-match-data match-data) > (cond > ((and test (not cell)) > ;; We've got a problem > (unwind-protect > (progn > (reftex-highlight 1 (match-beginning 0) (match-end > 0)) > (ding) > (or (y-or-n-p (format error-fmt label)) > (error "Abort"))) > (reftex-unhighlight 1))) > ((and test cell) > (cl-incf n)) > ((and (not test) cell) > ;; Replace > (goto-char (match-beginning 1)) > (delete-region (match-beginning 1) (match-end 1)) > (insert (cdr cell))) > (t nil)))))))) > n)) > --8<---------------cut here---------------end--------------->8--- > > TIA. Best, Arash >
[Message part 2 (text/html, inline)]
bug-auctex <at> gnu.org
:bug#57720
; Package auctex
.
(Sun, 11 Sep 2022 20:52:01 GMT) Full text and rfc822 format available.Message #14 received at 57720 <at> debbugs.gnu.org (full text, mbox):
From: Arash Esbati <arash <at> gnu.org> To: Wierdl Máté <wierdlmate <at> gmail.com> Cc: 57720 <at> debbugs.gnu.org Subject: Re: bug#57720: 13.1.4; renumbering simple labels doesn't work with tcolorbox Date: Sun, 11 Sep 2022 22:40:17 +0200
Wierdl Máté <wierdlmate <at> gmail.com> writes: > It now seems to work perfectly. I tried it not only on the test file > but also on the book I have been working on which loads quite a few > .tex files. Thanks for testing, also on a bigger project, that gives me a better feeling. > Should I put this "defun" into my .emacs for the time being, till it > gets incorporated into reftex? I think I will install this version which seems a little more robust to me. --8<---------------cut here---------------start------------->8--- (defun reftex-translate (files search-re translate-alist error-fmt test) ;; In FILES, look for SEARCH-RE and replace match 1 of it with ;; its association in TRANSLATE-ALIST. ;; If we do not find an association and TEST is non-nil, query ;; to ignore the problematic string. ;; If TEST is nil, it is ignored without query. ;; Return the number of replacements. (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 (error "No such file %s" file)) (set-buffer buf) (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward search-re nil t) (backward-char) (save-excursion (setq label (reftex-match-string 1) cell (assoc label translate-alist) match-data (match-data) macro (reftex-what-macro 1) pos (cdr macro)) (goto-char (or pos (point))) (when (and macro (or (looking-at "\\\\ref") (looking-at "\\\\[a-zA-Z]*ref\\(range\\)?[^a-zA-Z]") (looking-at "\\\\ref[a-zA-Z]*[^a-zA-Z]") (looking-at (format reftex-find-label-regexp-format (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 ((and test (not cell)) ;; We've got a problem (unwind-protect (progn (reftex-highlight 1 (match-beginning 0) (match-end 0)) (ding) (or (y-or-n-p (format error-fmt label)) (error "Abort"))) (reftex-unhighlight 1))) ((and test cell) (cl-incf n)) ((and (not test) cell) ;; Replace (goto-char (match-beginning 1)) (delete-region (match-beginning 1) (match-end 1)) (insert (cdr cell))) (t nil)))))))) n)) --8<---------------cut here---------------end--------------->8--- And yes, you will have to put in your .emacs wrapped in (with-eval-after-load 'reftex-global (defun ...) ) until Emacs 29 is out and you're using it (unless you want to built the version out of Emacs repo and use it) Best, Arash
Arash Esbati <arash <at> gnu.org>
to control <at> debbugs.gnu.org
.
(Mon, 12 Sep 2022 15:52:02 GMT) Full text and rfc822 format available.Debbugs Internal Request <help-debbugs <at> gnu.org>
to internal_control <at> debbugs.gnu.org
.
(Tue, 11 Oct 2022 11:24:07 GMT) Full text and rfc822 format available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.