From 9bc236c8263bc81f1b540579a9f98d872ab2da46 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Fri, 1 Nov 2013 11:27:21 +0100 Subject: [PATCH] Allow multiple bibliographies when BibLaTeX is used rathen than BibTeX. * textmodes/reftex-parse.el (reftex-using-biblatex-p): New function. (reftex-locate-bibliography-files): Us it. --- lisp/ChangeLog | 7 +++++++ lisp/textmodes/reftex-parse.el | 38 +++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fd8e77c9c53..1493945af38 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-11-01 Tassilo Horn + + Allow multiple bibliographies when BibLaTeX is used rathen than + BibTeX. + * textmodes/reftex-parse.el (reftex-using-biblatex-p): New function. + (reftex-locate-bibliography-files): Us it. + 2013-11-01 Claudio Bley * image.el (image-type-header-regexps): Fix the 'pbm' part to diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el index a99791e5427..ffabb134c83 100644 --- a/lisp/textmodes/reftex-parse.el +++ b/lisp/textmodes/reftex-parse.el @@ -350,20 +350,38 @@ of master file." ;; Return the list docstruct)) +(defun reftex-using-biblatex-p () + "Return non-nil iff we are using biblatex rather than bibtex." + (if (boundp 'TeX-active-styles) + ;; the sophisticated AUCTeX way + (member "biblatex" TeX-active-styles) + ;; poor-man's check... + (save-excursion + (re-search-forward "^[^%]*\\\\usepackage.*{biblatex}" nil t)))) + (defun reftex-locate-bibliography-files (master-dir &optional files) - "Scan buffer for bibliography macro and return file list." + "Scan buffer for bibliography macros and return file list." (unless files (save-excursion (goto-char (point-min)) - (if (re-search-forward - (concat -; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\(" - "\\(^\\)[^%\n\r]*\\\\\\(" - (mapconcat 'identity reftex-bibliography-commands "\\|") - "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t) - (setq files - (split-string (reftex-match-string 4) - "[ \t\n\r]*,[ \t\n\r]*"))))) + ;; when biblatex is used, multiple \bibliography or + ;; \addbibresource macros are allowed. With plain bibtex, only + ;; the first is used. + (let ((using-biblatex (reftex-using-biblatex-p)) + (again t)) + (while (and again + (re-search-forward + (concat + ;; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\(" + "\\(^\\)[^%\n\r]*\\\\\\(" + (mapconcat 'identity reftex-bibliography-commands "\\|") + "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)") nil t)) + (setq files + (append files + (split-string (reftex-match-string 4) + "[ \t\n\r]*,[ \t\n\r]*"))) + (unless using-biblatex + (setq again nil)))))) (when files (setq files (mapcar -- 2.39.2