Subject: bug#64921: 13.2.1; Infinite loop in LaTeX-arg-biblatex-cites with RefTeX

From: Gustavo Barros <[email-masked]>
Date: Sat, 12 Aug 2023 07:58:44 -0300

Hi Keita,

On Sat, 12 Aug 2023 at 02:21, Ikumi Keita <[email-masked]> 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.