GNU bug report logs - #64768
biblatex detection in reftex is too naive, multiple bib files are problematic

Previous Next

Package: emacs;

Reported by: "Philipp G. Haselwarter" <philipp <at> haselwarter.org>

Date: Fri, 21 Jul 2023 12:21:02 UTC

Severity: normal

Tags: moreinfo, notabug

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 64768 in the body.
You can then email your comments to 64768 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


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64768; Package emacs. (Fri, 21 Jul 2023 12:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Philipp G. Haselwarter" <philipp <at> haselwarter.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 21 Jul 2023 12:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Philipp G. Haselwarter" <philipp <at> haselwarter.org>
To: bug-gnu-emacs <at> gnu.org
Subject: biblatex detection in reftex is too naive,
 multiple bib files are problematic
Date: Fri, 21 Jul 2023 14:19:06 +0200
[Message part 1 (text/plain, inline)]
To find .bib files, reftex uses `reftex-locate-bibliography-files', which
in turn checks whether bibtex is in use via `reftex-using-biblatex-p'. The
latter is too naïve: it only checks if "biblatex" is amongst the
`TeX-active-styles' or does a simple syntactic check of the current buffer.
In case \usepackage{biblatex} is loaded in, say, an included file, these
checks fail, and the use of biblatex is not detected. As a result, only the
first of potentially several \addbibresource{fooN.bib} statements is picked
up, and subsequent bib resources aren't parsed by reftex.

This is doubly unfortunate, because auctex's "style" (black) magic exposes
`LaTeX-bibliography-list', which does pick up the different bib files, and
could be used in reftex when available.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64768; Package emacs. (Thu, 27 Jul 2023 19:11:01 GMT) Full text and rfc822 format available.

Message #8 received at 64768 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: "Philipp G. Haselwarter" <philipp <at> haselwarter.org>
Cc: 64768 <at> debbugs.gnu.org
Subject: Re: bug#64768: biblatex detection in reftex is too naive, multiple
 bib files are problematic
Date: Thu, 27 Jul 2023 21:10:03 +0200
"Philipp G. Haselwarter" <philipp <at> haselwarter.org> writes:

> To find .bib files, reftex uses `reftex-locate-bibliography-files',
> which in turn checks whether bibtex is in use via
> `reftex-using-biblatex-p'. The latter is too naïve: it only checks if
> "biblatex" is amongst the `TeX-active-styles' or does a simple
> syntactic check of the current buffer. In case \usepackage{biblatex}
> is loaded in, say, an included file, these checks fail, and the use of
> biblatex is not detected.

Can you please describe what you exactly mean with
'\usepackage{biblatex} is an included file'?  I'd like to understand
your setup.

Best, Arash




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64768; Package emacs. (Fri, 28 Jul 2023 10:00:01 GMT) Full text and rfc822 format available.

Message #11 received at 64768 <at> debbugs.gnu.org (full text, mbox):

From: "Philipp G. Haselwarter" <philipp <at> haselwarter.org>
To: Arash Esbati <arash <at> gnu.org>
Cc: 64768 <at> debbugs.gnu.org
Subject: Re: bug#64768: biblatex detection in reftex is too naive, multiple
 bib files are problematic
Date: Fri, 28 Jul 2023 11:58:32 +0200
[Message part 1 (text/plain, inline)]
Hi Arash,

In main.tex, I have the line "\input{mypreamble}", and in mypreamble.tex,
there's a line with "\usepackage{biblatex}". I also have
several "\addbibresource{foo.bib}", "\addbibresource{bar.bib}", etc, either
in main.tex or in mypreamble.tex . I would want reftex to be aware of the
references in foo.bib and bar.bib whenever main.tex is set as TeX-master,
i.e. either while editing main.tex directly or while editing
some-section.tex, where some-section.tex sets TeX-master to main.tex.

Best,
Philipp

On Thu, 27 Jul 2023 at 21:10, Arash Esbati <arash <at> gnu.org> wrote:

> "Philipp G. Haselwarter" <philipp <at> haselwarter.org> writes:
>
> > To find .bib files, reftex uses `reftex-locate-bibliography-files',
> > which in turn checks whether bibtex is in use via
> > `reftex-using-biblatex-p'. The latter is too naïve: it only checks if
> > "biblatex" is amongst the `TeX-active-styles' or does a simple
> > syntactic check of the current buffer. In case \usepackage{biblatex}
> > is loaded in, say, an included file, these checks fail, and the use of
> > biblatex is not detected.
>
> Can you please describe what you exactly mean with
> '\usepackage{biblatex} is an included file'?  I'd like to understand
> your setup.
>
> Best, Arash
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64768; Package emacs. (Mon, 31 Jul 2023 07:41:01 GMT) Full text and rfc822 format available.

Message #14 received at 64768 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: "Philipp G. Haselwarter" <philipp <at> haselwarter.org>
Cc: 64768 <at> debbugs.gnu.org
Subject: Re: bug#64768: biblatex detection in reftex is too naive, multiple
 bib files are problematic
Date: Mon, 31 Jul 2023 09:40:03 +0200
"Philipp G. Haselwarter" <philipp <at> haselwarter.org> writes:

> In main.tex, I have the line "\input{mypreamble}", and in
> mypreamble.tex, there's a line with "\usepackage{biblatex}". I also
> have several "\addbibresource{foo.bib}", "\addbibresource{bar.bib}",
> etc, either in main.tex or in mypreamble.tex . I would want reftex to
> be aware of the references in foo.bib and bar.bib whenever main.tex is
> set as TeX-master, i.e. either while editing main.tex directly or
> while editing some-section.tex, where some-section.tex sets TeX-master
> to main.tex.

Thanks the clarification.  \addbibresource is a preamble only command
and AFAIU, RefTeX looks for this macro only in the main file; it doesn't
go through each \input'ed file in order to find any \addbibresource.

I'd suggest you change your setup a little and rename your
mypreamble.tex to mypreamble.sty and replace there:

  \usepackage{biblatex}

with

  \RequirePackage{biblatex}

and delete any \addbibresource calls.  Now you do this in your main.tex:

  \usepackage{mypreamble}
  \addbibresource{foo.bib}
  \addbibresource{bar.bib}

Now the final step is to write a small AUCTeX style file for your
mypreamble.sty called mypreamble.el which looks like this:

  (TeX-add-style-hook
   "mypreamble"
   (lambda ()
     (TeX-run-style-hooks "biblatex"))
   :latex)

and save this file in the directory specified in the variable
`TeX-style-private' (or adjust it accordingly first).

Now restart Emacs and open your main.tex.  AUCTeX should load
mypreamble.el and biblatex.el subsequently which gets an entry in
`TeX-active-styles' and you should be done.

Best, Arash




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64768; Package emacs. (Thu, 31 Aug 2023 20:26:02 GMT) Full text and rfc822 format available.

Message #17 received at 64768 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: "Philipp G. Haselwarter" <philipp <at> haselwarter.org>
Cc: 64768 <at> debbugs.gnu.org
Subject: Re: bug#64768: biblatex detection in reftex is too naive, multiple
 bib files are problematic
Date: Thu, 31 Aug 2023 22:24:37 +0200
tags 64768 moreinfo notabug
close 64768
thanks

Arash Esbati <arash <at> gnu.org> writes:

> Thanks the clarification.  \addbibresource is a preamble only command
> and AFAIU, RefTeX looks for this macro only in the main file; it doesn't
> go through each \input'ed file in order to find any \addbibresource.

Four weeks are gone and no further input.  I'm closing this report for
now, we can reopen upon any updates.

Best, Arash




Added tag(s) moreinfo and notabug. Request was from Arash Esbati <arash <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 31 Aug 2023 20:26:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 64768 <at> debbugs.gnu.org and "Philipp G. Haselwarter" <philipp <at> haselwarter.org> Request was from Arash Esbati <arash <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 31 Aug 2023 20:26:02 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. (Fri, 29 Sep 2023 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 224 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.