Function: bib-document-citekeys-obarray

bib-document-citekeys-obarray is a byte-compiled function defined in bib-cite.el.

Signature

(bib-document-citekeys-obarray)

Documentation

Return cite keys obarray for multi-file document.

Return nil if not a multi-file document. This is a AUCTeX supported feature only. Also, see bib-buffer-citekeys-obarray. Set global variable bib-document-citekeys-obarray-warnings.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/bib-cite.el
(defun bib-document-citekeys-obarray ()
  "Return cite keys obarray for multi-file document.
Return nil if not a multi-file document.
This is a AUCTeX supported feature only.
Also, see `bib-buffer-citekeys-obarray'.
Set global variable `bib-document-citekeys-obarray-warnings'."
  (setq bib-document-citekeys-obarray-warnings nil)
  (let ((master-tex (bib-master-file))
        (master-aux))
    (if (not master-tex)
        nil                             ;Not a multifile document.  No need...
      (setq master-aux (bib-return-aux-file-from-tex master-tex "aux"))
      (or (file-readable-p master-aux)
          (error "Sorry, cannot read file %s" master-aux))
      (and (file-newer-than-file-p master-tex master-aux)
           (setq bib-document-citekeys-obarray-warnings
                 (format "Warning: %s is out of date relative to %s.\n"
                         master-aux master-tex)))
      (let ((work-buffer (get-buffer-create "*bib-cite-work*"))
            (keys-obarray (make-vector 201 0)))
        (with-current-buffer work-buffer
          (insert-file-contents master-aux)
          ;; Because we will be looking for \input statements, we need to set
          ;; the default directory to that of the master file.
          (setq default-directory (file-name-directory master-tex))
          ;; bib-make-bibliography will need this also to find .bib files
          ;; look for \@input{chap1/part1.aux}
          (while (re-search-forward "^\\\\@input{\\(.*\\)}$" nil t)
            (let* ((auxfile (match-string 1))
                   (texfile (bib-return-aux-file-from-tex auxfile "tex")))
              (if (not (file-readable-p auxfile))
                  (setq bib-document-citekeys-obarray-warnings
                        (concat
                         bib-document-citekeys-obarray-warnings
                         (format "Warning: %s is not found or readable.\n"
                                 auxfile)))
                (if (file-newer-than-file-p texfile auxfile)
                    (setq bib-document-citekeys-obarray-warnings
                          (concat
                           bib-document-citekeys-obarray-warnings
                           (format
                            "Warning: %s is out of date relative to %s.\n"
                            auxfile texfile))))
                (end-of-line)(insert "\n")
                (insert-file-contents auxfile))))
          (goto-char 1)

;;;  Patched by calvanes@dis.uniroma1.it (Diego Calvanese)
;;;      ;; look for \citation{gertsenshtein59}
;;;       (while (re-search-forward "^\\\\citation{\\(.*\\)}$" nil t)
;;;         (intern (buffer-substring (match-beginning 1)(match-end 1))
;;;                 keys-obarray))
          ;; look for \citation{gertsenshtein59,vardi88,...,ullmann90}
          ;; comma-separation generated by certain LaTeX styles.
          (while (re-search-forward "^\\\\citation{\\(.*\\)}$" nil t)
            (let ((string (match-string 1))
                  (start 0))
              (while (string-match "\\([^,\n]+\\)" string start)
                (intern (substring string (match-beginning 1) (match-end 1))
                        keys-obarray)
                (setq start (match-end 0))))))
        (kill-buffer work-buffer)
        keys-obarray))))