GNU bug report logs -
#78841
reftex-get-bibfile-list fails to detect biblatex if there's no buffer for the main file
Previous Next
Full log
View this message in rfc822 format
With (default) settings
(setq reftex-initialize-temporary-buffers nil)
(setq reftex-keep-temporary-buffers 1)
assume you call (reftex-get-bibfile-list) in a chapter.tex buffer but
there's no buffer yet for the main file main.tex that looks like this:
\documentclass{standalone}
\usepackage{biblatex}
\addbibresource{1.bib}
\addbibresource{2.bib}
\begin{document}
\input{chapter.tex}
\end{document}
Then reftex-get-bibfile-list will return only the first bib file but it
is supposed to return both bib files.
The problem is that reftex-locate-bibliography-files tries to figure
out whether biblatex is used, i.e., whether it needs to continue
searching after the first bibliography command. It does so (also) in
main.tex, which has beem opened only as a temp buffer in fundamental
mode. Whether biblatex is used is determined in reftex-using-biblatex-
p, which relies on the value of TeX-active-styles if (boundp 'TeX-
active-styles).
But the latter is the wrong condition: (boundp 'TeX-active-styles) is
true in fundamental mode because 'Tex-active-styles has a (global)
binding of nil.
Replacing
(boundp 'TeX-active-styles)
by
(local-variable-p 'TeX-active-styles)
fixes this check for me. Then reftex-using-biblatex-p will fall back on
a "poor-man's check" (according to the comment in the code), which
looks for \usepackage{biblatex} using some regex.
However, while this patch would fix the problem for me, I still don't
like the resulting code:
* In fact, checking TeX-active-styles would work if only the check was
done in the chapter.tex buffer from which reftex-get-bibfile-list is
called, but it's instead done in each buffer separately.
* Similarly, the poor man's check is done in each buffer separately. I
think this means that also the poor man's check will only work for
any \addbibresource command which happens to be in the same buffer
as \usepackage{biblatex}.
I think this logic is broken. Whether biblatex is used or not should
not be judged in each file of a multifile document separately. Either
the entire document uses biblatex, or it doesn't. As a result,
replacing boundp by local-variable-p is only my second best suggestion.
My best suggestion is to get rid of reftex-using-biblatex-p entirely,
and assume it's always true. In other words, never stop after the first
\addbibresource (or rather \bibliography) command has been found. This
gets rid of the broken logic and both imperfect heuristics. I assume
this is fine performance-wise, and I assume this is what one would do
when asked to reimplement this from scratch.
A look at the history shows that the initial code that stops after the
first value is is >25 years old (and this is just how far back git
goes). Back then there was only bibtex and it was okay to stop after
the first \bibliography, and CPUs were way slower. Then in 2013, the
fix for biblatex was added, but it was done in an attempt to keep the
early return if biblatex is not used.
I'm happy to provide a proper patch for either suggestion, but they're
both trivial enough that you'll probably do the changes yourself
quicker than asking me for the patch.
Best,
Tim
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.