Function: bib-get-bibliography
bib-get-bibliography is a byte-compiled function defined in
bib-cite.el.
Signature
(bib-get-bibliography INCLUDE-FILENAMES-F)
Documentation
Returns a new bibliography buffer holding all bibtex files in the document.
If using AUCTeX, and either TeX-parse-self is set or C-c C-n is used to parse the document, then the entire multifile document will be searched for \bibliography commands.
If this fails, the current buffer is searched for the first \bibliography command.
If include-filenames-f is true, include as a special header the filename of each bib file.
Puts the buffer in text-mode such that forward-sexp works with german " accents embeded in bibtex entries.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/bib-cite.el
;; --------------------------------------------------------------------------
;; The following routines make a temporary bibliography buffer
;; holding all bibtex files found.
(defun bib-get-bibliography (include-filenames-f)
"Returns a new bibliography buffer holding all bibtex files in the document.
If using AUCTeX, and either TeX-parse-self is set or C-c C-n is used to
parse the document, then the entire multifile document will be searched
for \\bibliography commands.
If this fails, the current buffer is searched for the first \\bibliography
command.
If include-filenames-f is true, include as a special header the filename
of each bib file.
Puts the buffer in text-mode such that forward-sexp works with german \"
accents embeded in bibtex entries."
(let ((bib-list (or (and (fboundp 'LaTeX-bibliography-list)
(boundp 'TeX-mode-p) TeX-mode-p
(LaTeX-bibliography-list))
;; LaTeX-bibliography-list (if bound) returns an unformatted list of
;; bib files used in the document, but only if parsing is turned on
;; or C-c C-n was used.
(bib-bibliography-list)))
(bib-buffer (get-buffer-create "*bibtex-bibliography*"))
;; Path is relative to the master directory
(default-directory (bib-master-directory))
(the-name)(the-warnings)(the-file))
(with-current-buffer bib-buffer
;; such that forward-sexp works with embeeded \" in german,
;; and unbalanced ()
(erase-buffer)
(set-syntax-table text-mode-syntax-table)
;; (if (boundp 'bibtex-mode-syntax-table)
;; (set-syntax-table bibtex-mode-syntax-table)
;; (text-mode))
)
;;We have a list of bib files
;;Search for them, include them, list those not readable
(while bib-list
(setq the-name (car (car bib-list))) ;Extract the string only
(setq bib-list (cdr bib-list))
(setq the-name
(substring the-name
(string-match "[^ ]+" the-name) ;remove leading spaces
(string-match "[ ]+$" the-name))) ;remove trailing space
(if (not (string-match "\\.bib$" the-name))
(setq the-name (concat the-name ".bib")))
(setq the-file
(or (and (file-readable-p the-name) the-name)
(psg-checkfor-file-list
the-name (psg-list-env bib-bibtex-env-variable))
;; Check for BIBINPUT env variable as well (by popular demand!)
(psg-checkfor-file-list the-name (psg-list-env "BIBINPUT"))
(and bib-cite-inputs
(psg-checkfor-file-list the-name bib-cite-inputs))
(and (boundp 'TeX-check-path)
(psg-checkfor-file-list the-name TeX-check-path))))
(if the-file
(with-current-buffer bib-buffer
(goto-char (point-max))
(if include-filenames-f
(insert "%%%Filename: " the-file "\n"))
(insert-file-contents the-file nil)
(goto-char 1))
(setq the-warnings
(concat the-warnings "Could not read file: " the-name "\n"))))
(if the-warnings
(progn
(with-output-to-temp-buffer "*Help*"
(princ the-warnings))
(kill-buffer bib-buffer)
(error
"Sorry, can't find all bibtex files in \\bibliography command"))
bib-buffer)))