emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 7f81470250: Load multiple bibliographies with multibib package


From: Arash Esbati
Subject: master 7f81470250: Load multiple bibliographies with multibib package
Date: Mon, 2 May 2022 08:35:15 -0400 (EDT)

branch: master
commit 7f81470250589dd0ca4b024a315c0103fce9bf84
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    Load multiple bibliographies with multibib package
    
    * lisp/textmodes/reftex-parse.el (reftex-using-biblatex-p):
    Recognize 'multibib' which allows multiple bibliography loading
    macro calls.
    (reftex-locate-bibliography-files): Prevent possible duplications
    in bibliography database files.
---
 lisp/textmodes/reftex-parse.el | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 016c9cf399..bae455dd4d 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -370,13 +370,18 @@ of master file."
     docstruct))
 
 (defun reftex-using-biblatex-p ()
-  "Return non-nil if we are using biblatex rather than bibtex."
+  "Return non-nil if we are using biblatex or other specific cite package.
+biblatex and other packages like multibib allow multiple macro
+calls to load a bibliography file.  This packages should be
+detected by this function."
   (if (boundp 'TeX-active-styles)
       ;; the sophisticated AUCTeX way
-      (member "biblatex" TeX-active-styles)
+      (or (member "biblatex" TeX-active-styles)
+          (member "multibib" TeX-active-styles))
     ;; poor-man's check...
     (save-excursion
-      (re-search-forward "^[^%\n]*?\\\\usepackage.*{biblatex}" nil t))))
+      (re-search-forward
+       "^[^%\n]*?\\\\usepackage\\(\\[[^]]*\\]\\)?{biblatex\\|multibib}" nil 
t))))
 
 ;;;###autoload
 (defun reftex-locate-bibliography-files (master-dir &optional files)
@@ -384,7 +389,7 @@ of master file."
   (unless files
     (save-excursion
       (goto-char (point-min))
-      ;; when biblatex is used, multiple \bibliography or
+      ;; when biblatex or multibib are used, multiple \bibliography or
       ;; \addbibresource macros are allowed.  With plain bibtex, only
       ;; the first is used.
       (let ((using-biblatex (reftex-using-biblatex-p))
@@ -392,7 +397,7 @@ of master file."
        (while (and again
                    (re-search-forward
                     (concat
-                     ;;           "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
+                     ;; "\\(\\`\\|[\n\r]\\)[^%]*\\\\\\("
                      "\\(^\\)[^%\n\r]*\\\\\\("
                      (mapconcat #'identity reftex-bibliography-commands "\\|")
                      "\\)\\(\\[.+?\\]\\)?{[ \t]*\\([^}]+\\)")
@@ -415,7 +420,7 @@ of master file."
                ;; find the file
                (reftex-locate-file x "bib" master-dir)))
            files))
-    (delq nil files)))
+    (delq nil (delete-dups files))))
 
 (defun reftex-replace-label-list-segment (old insert &optional entirely)
   "Replace the segment in OLD which corresponds to INSERT.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]