Function: bib-make-bibliography

bib-make-bibliography is an interactive and byte-compiled function defined in bib-cite.el.

Signature

(bib-make-bibliography)

Documentation

Extract citations used in the current document from \bibliography{} file(s).

Put them into a buffer named after the current buffer, with extension .bib.

In an AUCTeX multi-file document, parsing must be on and the citation keys are extracted from the .aux files.

In a plain LaTeX buffer (not multi-file), the cite keys are extracted from the text itself. Therefore the text need not have been previously processed by LaTeX.

This function is useful when you want to share a LaTeX file, and therefore want to create a bibtex file containing only the references used in the document.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/bib-cite.el
(defun bib-make-bibliography ()
  "Extract citations used in the current document from \\bibliography{} file(s).
Put them into a buffer named after the current buffer, with extension .bib.

In an AUCTeX multi-file document, parsing must be on and the citation keys
are extracted from the .aux files.

In a plain LaTeX buffer (not multi-file), the cite keys are extracted from
the text itself.  Therefore the text need not have been previously processed
by LaTeX.

This function is useful when you want to share a LaTeX file, and therefore want
to create a bibtex file containing only the references used in the document."
  (interactive)
  (let* ((the-keys-obarray (or (bib-document-citekeys-obarray)
                               (bib-buffer-citekeys-obarray)))
                                        ;1st in case of error
         (new-buffer
          (create-file-buffer
           (concat (substring (buffer-name) 0
                              (or (string-match "\\." (buffer-name))
                                  (length (buffer-name))))
                   "-bib.bib")))
         (bib-buffer (bib-get-bibliography nil))
         (the-warnings (bib-get-citations the-keys-obarray
                                          bib-buffer
                                          new-buffer
                                          nil)))
    (kill-buffer bib-buffer)
;;; (switch-to-buffer new-buffer)
    (funcall bib-switch-to-buffer-function new-buffer)
    (bibtex-mode)
    (if (or bib-document-citekeys-obarray-warnings
            the-warnings)
        (progn
          (cond
           ((and bib-document-citekeys-obarray-warnings the-warnings)
            (with-output-to-temp-buffer "*Help*"
              (princ bib-document-citekeys-obarray-warnings the-warnings)))
           (bib-document-citekeys-obarray-warnings
            (with-output-to-temp-buffer "*Help*"
              (princ bib-document-citekeys-obarray-warnings)))
           (the-warnings
            (with-output-to-temp-buffer "*Help*" (princ the-warnings))))
          (setq bib-document-citekeys-obarray-warnings nil) ;Reset
          (bib-cite-fontify-red)))
    (if bib-novice
        (message
         (substitute-command-keys
          "Use \\[save-buffer] to save this buffer to a file.")))))