Function: reftex-locate-bibliography-files

reftex-locate-bibliography-files is an autoloaded and byte-compiled function defined in reftex-parse.el.gz.

Signature

(reftex-locate-bibliography-files MASTER-DIR &optional FILES)

Documentation

Scan buffer for bibliography macros and return file list.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-parse.el.gz
;;;###autoload
(defun reftex-locate-bibliography-files (master-dir &optional files)
  "Scan buffer for bibliography macros and return file list."
  (unless files
    (save-excursion
      (goto-char (point-min))
      ;; 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))
	    (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
           (lambda (x)
             (if (or (member x reftex-bibfile-ignore-list)
                     (delq nil (mapcar (lambda (re) (string-match re x))
                                       reftex-bibfile-ignore-regexps)))
                 ;; excluded file
                 nil
               ;; find the file
               (reftex-locate-file x "bib" master-dir)))
           files))
    (delq nil (delete-dups files))))