unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic
@ 2023-07-21 12:19 Philipp G. Haselwarter
  2023-07-27 19:10 ` Arash Esbati
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp G. Haselwarter @ 2023-07-21 12:19 UTC (permalink / raw)
  To: 64768

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 870 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic
  2023-07-21 12:19 bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic Philipp G. Haselwarter
@ 2023-07-27 19:10 ` Arash Esbati
  2023-07-28  9:58   ` Philipp G. Haselwarter
  0 siblings, 1 reply; 5+ messages in thread
From: Arash Esbati @ 2023-07-27 19:10 UTC (permalink / raw)
  To: Philipp G. Haselwarter; +Cc: 64768

"Philipp G. Haselwarter" <philipp@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic
  2023-07-27 19:10 ` Arash Esbati
@ 2023-07-28  9:58   ` Philipp G. Haselwarter
  2023-07-31  7:40     ` Arash Esbati
  0 siblings, 1 reply; 5+ messages in thread
From: Philipp G. Haselwarter @ 2023-07-28  9:58 UTC (permalink / raw)
  To: Arash Esbati; +Cc: 64768

[-- Attachment #1: Type: text/plain, Size: 1278 bytes --]

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@gnu.org> wrote:

> "Philipp G. Haselwarter" <philipp@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
>

[-- Attachment #2: Type: text/html, Size: 1817 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic
  2023-07-28  9:58   ` Philipp G. Haselwarter
@ 2023-07-31  7:40     ` Arash Esbati
  2023-08-31 20:24       ` Arash Esbati
  0 siblings, 1 reply; 5+ messages in thread
From: Arash Esbati @ 2023-07-31  7:40 UTC (permalink / raw)
  To: Philipp G. Haselwarter; +Cc: 64768

"Philipp G. Haselwarter" <philipp@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic
  2023-07-31  7:40     ` Arash Esbati
@ 2023-08-31 20:24       ` Arash Esbati
  0 siblings, 0 replies; 5+ messages in thread
From: Arash Esbati @ 2023-08-31 20:24 UTC (permalink / raw)
  To: Philipp G. Haselwarter; +Cc: 64768

tags 64768 moreinfo notabug
close 64768
thanks

Arash Esbati <arash@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-31 20:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-21 12:19 bug#64768: biblatex detection in reftex is too naive, multiple bib files are problematic Philipp G. Haselwarter
2023-07-27 19:10 ` Arash Esbati
2023-07-28  9:58   ` Philipp G. Haselwarter
2023-07-31  7:40     ` Arash Esbati
2023-08-31 20:24       ` Arash Esbati

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).