GNU bug report logs -
#64921
13.2.1; Infinite loop in LaTeX-arg-biblatex-cites with RefTeX
Previous Next
Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>
Date: Fri, 28 Jul 2023 20:13:02 UTC
Severity: normal
Found in version 13.2.1
Done: Ikumi Keita <ikumi <at> ikumi.que.jp>
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 64921 in the body.
You can then email your comments to 64921 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Fri, 28 Jul 2023 20:13:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Gustavo Barros <gusbrs.2016 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-auctex <at> gnu.org
.
(Fri, 28 Jul 2023 20:13:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi All,
I might be missing something obvious on this one, but I couldn't
figure out a way to do it and as far as I understand the code, I see
no way to break the loop in `LaTeX-arg-biblatex-cites'. So I report.
When RefTeX is plugged into AUCTeX, trying to insert a `biblatex'
citation list with `TeX-insert-macro' will call
`LaTeX-arg-biblatex-cites' and, as far as I can tell, there is no way
to tell that function no further arguments are required. For sure,
one can interrupt the cycle from the call to `reftex-citation' with
"C-g" or "q", but then one also loses the citation altogether making
the attempt futile.
To reproduce starting with `emacs -Q'. Some setup:
#+begin_src emacs-lisp
(add-to-list 'load-path "~/.emacs.d/elpa/auctex-13.2.1")
(load "auctex.el" nil t t)
(load "reftex.el" nil t t)
(setq TeX-parse-self t)
(setq TeX-auto-save t)
(setq reftex-plug-into-AUCTeX t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-use-external-file-finders t)
#+end_src
Visit a file with contents:
#+begin_src latex
\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\end{document}
#+end_src
Now, use `TeX-insert-macro' to insert a biblatex qualified citation
list, say `\cites': "C-c RET cites RET". You are prompted for a
regexp, as usual, you can enter it, get a list of results, select one
with RET. And, you are prompted again for a new regexp, you can enter
it and select a new candidate, etc. etc. The only chance you get to
break the loop is at the regexp prompt, where you can leave it with
"C-g" or "q", but then you lose the whole citation command, which is
deleted.
Indeed, the loop in `LaTeX-arg-biblatex-cites' takes the form:
#+begin_src emacs-lisp
(while items
;; ... handling of optional arguments
(setq items (if (and (fboundp 'reftex-citation)
(fboundp 'reftex-plug-flag)
(reftex-plug-flag 3))
;; Use RefTeX when enabled.
(reftex-citation t)
;; Multiple citation keys in each argument are allowed.
(TeX-completing-read-multiple
(TeX-argument-prompt optional prompt "Key(s)")
(LaTeX-bibitem-list))))
;; ... macro/argument is inserted, but value of `items' is left untouched
)
#+end_src
So, since `items' is not touched after it is set with
`(reftex-citation t)', leaving the loop would require a way for
`reftex-citation's UI to return nil. I don't see how. But, again, I
may be missing something...
Best regards,
Gustavo.
Emacs : GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0)
of 2023-07-23
Package: 13.2.1
current state:
==============
(setq
AUCTeX-date "2023-07-20"
window-system 'x
LaTeX-version "2e"
TeX-style-path '("~/.emacs.d/auctex"
"/home/gustavo/.emacs.d/elpa/auctex-13.2.1/style"
"/home/gustavo/.emacs.d/auctex/auto"
"/home/gustavo/.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"))
)
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Sat, 12 Aug 2023 05:22:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 64921 <at> debbugs.gnu.org (full text, mbox):
Hi Gustavo, sorry for late reply.
>>>>> Gustavo Barros <gusbrs.2016 <at> gmail.com> writes:
> When RefTeX is plugged into AUCTeX, trying to insert a `biblatex'
> citation list with `TeX-insert-macro' will call
> `LaTeX-arg-biblatex-cites' and, as far as I can tell, there is no way
> to tell that function no further arguments are required. For sure,
> one can interrupt the cycle from the call to `reftex-citation' with
> "C-g" or "q", but then one also loses the citation altogether making
> the attempt futile.
> To reproduce starting with `emacs -Q'. Some setup:
> #+begin_src emacs-lisp
> (add-to-list 'load-path "~/.emacs.d/elpa/auctex-13.2.1")
> (load "auctex.el" nil t t)
> (load "reftex.el" nil t t)
> (setq TeX-parse-self t)
> (setq TeX-auto-save t)
> (setq reftex-plug-into-AUCTeX t)
> (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
> (setq reftex-use-external-file-finders t)
> #+end_src
> Visit a file with contents:
> #+begin_src latex
> \documentclass{article}
> \usepackage{biblatex}
> \addbibresource{biblatex-examples.bib}
> \begin{document}
> \end{document}
> #+end_src
> Now, use `TeX-insert-macro' to insert a biblatex qualified citation
> list, say `\cites': "C-c RET cites RET". You are prompted for a
> regexp, as usual, you can enter it, get a list of results, select one
> with RET. And, you are prompted again for a new regexp, you can enter
> it and select a new candidate, etc. etc. The only chance you get to
> break the loop is at the regexp prompt, where you can leave it with
> "C-g" or "q", but then you lose the whole citation command, which is
> deleted.
I can confirm the reported behavior.
> Indeed, the loop in `LaTeX-arg-biblatex-cites' takes the form:
> #+begin_src emacs-lisp
> (while items
> ;; ... handling of optional arguments
> (setq items (if (and (fboundp 'reftex-citation)
> (fboundp 'reftex-plug-flag)
> (reftex-plug-flag 3))
> ;; Use RefTeX when enabled.
> (reftex-citation t)
> ;; Multiple citation keys in each argument are allowed.
> (TeX-completing-read-multiple
> (TeX-argument-prompt optional prompt "Key(s)")
> (LaTeX-bibitem-list))))
> ;; ... macro/argument is inserted, but value of `items' is left untouched
> )
> #+end_src
> So, since `items' is not touched after it is set with
> `(reftex-citation t)', leaving the loop would require a way for
> `reftex-citation's UI to return nil. I don't see how. But, again, I
> may be missing something...
Your analysis seems right. I don't come up with a good solution yet.
However, most users would type C-c [ to use `reftex-citation' directly,
which works without the reported issue. Thus I expect the importance
of this bug is low enough.
If it doesn't actually harm users, "won'tfix" would be a suitable
treatment to this bug. What do you think?
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Sat, 12 Aug 2023 11:00:03 GMT)
Full text and
rfc822 format available.
Message #11 received at 64921 <at> debbugs.gnu.org (full text, mbox):
Hi Keita,
On Sat, 12 Aug 2023 at 02:21, Ikumi Keita <ikumi <at> ikumi.que.jp> wrote:
>
> I can confirm the reported behavior.
>
Thanks for checking and looking into this.
> > Indeed, the loop in `LaTeX-arg-biblatex-cites' takes the form:
> > #+begin_src emacs-lisp
> > (while items
> > ;; ... handling of optional arguments
> > (setq items (if (and (fboundp 'reftex-citation)
> > (fboundp 'reftex-plug-flag)
> > (reftex-plug-flag 3))
> > ;; Use RefTeX when enabled.
> > (reftex-citation t)
> > ;; Multiple citation keys in each argument are allowed.
> > (TeX-completing-read-multiple
> > (TeX-argument-prompt optional prompt "Key(s)")
> > (LaTeX-bibitem-list))))
> > ;; ... macro/argument is inserted, but value of `items' is left untouched
> > )
> > #+end_src
> > So, since `items' is not touched after it is set with
> > `(reftex-citation t)', leaving the loop would require a way for
> > `reftex-citation's UI to return nil. I don't see how. But, again, I
> > may be missing something...
>
> Your analysis seems right. I don't come up with a good solution yet.
> However, most users would type C-c [ to use `reftex-citation' directly,
> which works without the reported issue. Thus I expect the importance
> of this bug is low enough.
>
> If it doesn't actually harm users, "won'tfix" would be a suitable
> treatment to this bug. What do you think?
That would be disappointing. The sole purpose of this function is to
handle the insertion of arguments of citation lists and it doesn't
work with RefTeX?
Also, I respectfully disagree with the assessment that "it doesn't
actually harm users". Indeed, `reftex-citation' is very convenient,
and also my favorite, but it is not a full replacement for
`TeX-insert-macro' for citation commands. `biblatex' has over 50
citation commands, and `reftex-citation's dispatcher would become
impractical if we actually tried to have them all available there. It
is great for our most used ones, but for those odd birds, we still
need `TeX-insert-macro'.
Regarding what to do, I see two ways to handle it. Either make
"q"/"C-g" not delete the citation when leaving, or simply not loop,
handling just the first bibkey. Perhaps there's good reason why
"q"/"C-g" reverts the whole operation. But it cannot be too difficult
simply not to loop at `LaTeX-arg-biblatex-cites'. And that is actually
how `reftex-citation' works for citation lists, it only inserts the
first argument.
In my experience, trying to use `biblatex' citation lists with
AUCTeX+RefTeX is an uphill battle. This task is probably the single
largest source of patches I must maintain in my config. I'm ready to
agree that the syntax of these citation macros are unfortunate, both
because they may take an arbitrary number of arguments and because
they use parentheses for the global pre/postnotes. The latter alone is
enough to beat `reftex-what-macro' and put RefTeX in a good deal of
trouble.
I don't know, it is true that the case is tricky. But what I've been
getting of late in related reports is that it is "not relevant", or
"not relevant enough". Is it true though that `biblatex's citation
lists don't deserve better support?
Best regards,
Gustavo.
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Tue, 15 Aug 2023 06:19:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 64921 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Gustavo,
>>>>> Gustavo Barros <gusbrs.2016 <at> gmail.com> writes:
> Also, I respectfully disagree with the assessment that "it doesn't
> actually harm users". Indeed, `reftex-citation' is very convenient,
> and also my favorite, but it is not a full replacement for
> `TeX-insert-macro' for citation commands. `biblatex' has over 50
> citation commands, and `reftex-citation's dispatcher would become
> impractical if we actually tried to have them all available there. It
> is great for our most used ones, but for those odd birds, we still
> need `TeX-insert-macro'.
Hmm. I know almost nothing about biblatex, so I didn't know that.
Thanks.
> Regarding what to do, I see two ways to handle it. Either make
> "q"/"C-g" not delete the citation when leaving, or simply not loop,
> handling just the first bibkey. Perhaps there's good reason why
> "q"/"C-g" reverts the whole operation. But it cannot be too difficult
> simply not to loop at `LaTeX-arg-biblatex-cites'. And that is actually
> how `reftex-citation' works for citation lists, it only inserts the
> first argument.
Thank you for suggestion. Does the attached patch give you good results?
(By the way, the reason that "q"/"C-g" deletes the trace of the previous
input is that `TeX-insert-macro' introduced `atomic-change-group' a year
ago[1].)
[1] Thread beginning with
https://lists.gnu.org/r/auctex-devel/2022-08/msg00057.html
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
[patch (text/x-diff, attachment)]
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Tue, 15 Aug 2023 14:50:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 64921 <at> debbugs.gnu.org (full text, mbox):
Hi Keita,
On Tue, 15 Aug 2023 at 03:18, Ikumi Keita <ikumi <at> ikumi.que.jp> wrote:
>
> Thank you for suggestion. Does the attached patch give you good results?
>
It behaves the same as `reftex-citation`, so it looks good to me.
Thank you very much!
> (By the way, the reason that "q"/"C-g" deletes the trace of the previous
> input is that `TeX-insert-macro' introduced `atomic-change-group' a year
> ago[1].)
I see. The thread does not actually cover the reason for the change,
but it makes sense. Also, I don't know why "q" (`reftex-select-quit')
counts as "abnormal exit" or if it really should, given that now
`TeX-insert-macro' uses `atomic-change-group'. But, given the patch
you provided, the difference is arguably inconsequential (at least for
the case at hand).
Best regards,
Gustavo.
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Thu, 17 Aug 2023 07:26:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 64921 <at> debbugs.gnu.org (full text, mbox):
>>>>> Gustavo Barros <gusbrs.2016 <at> gmail.com> writes:
> On Tue, 15 Aug 2023 at 03:18, Ikumi Keita <ikumi <at> ikumi.que.jp> wrote:
>>
>> Thank you for suggestion. Does the attached patch give you good results?
>>
> It behaves the same as `reftex-citation`, so it looks good to me.
> Thank you very much!
Thank you for confirmation. I pushed the fix to the git repository.
>> (By the way, the reason that "q"/"C-g" deletes the trace of the previous
>> input is that `TeX-insert-macro' introduced `atomic-change-group' a year
>> ago[1].)
> I see. The thread does not actually cover the reason for the change,
> but it makes sense. Also, I don't know why "q" (`reftex-select-quit')
> counts as "abnormal exit" or if it really should, given that now
> `TeX-insert-macro' uses `atomic-change-group'.
I think RefTeX by design sends quit signal for input "q", which breaks
the elisp execution.
Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine
Information forwarded
to
bug-auctex <at> gnu.org
:
bug#64921
; Package
auctex
.
(Thu, 17 Aug 2023 10:34:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 64921 <at> debbugs.gnu.org (full text, mbox):
On Thu, 17 Aug 2023 at 04:25, Ikumi Keita <ikumi <at> ikumi.que.jp> wrote:
>
> Thank you for confirmation. I pushed the fix to the git repository.
>
Thank you very much.
Best,
Gustavo.
bug closed, send any further explanations to
64921 <at> debbugs.gnu.org and Gustavo Barros <gusbrs.2016 <at> gmail.com>
Request was from
Ikumi Keita <ikumi <at> ikumi.que.jp>
to
control <at> debbugs.gnu.org
.
(Tue, 22 Aug 2023 07:05:01 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 19 Sep 2023 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 2 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.