Function: reftex-pop-to-bibtex-entry

reftex-pop-to-bibtex-entry is an autoloaded and byte-compiled function defined in reftex-cite.el.gz.

Signature

(reftex-pop-to-bibtex-entry KEY FILE-LIST &optional MARK-TO-KILL HIGHLIGHT ITEM RETURN)

Documentation

Find BibTeX KEY in any file in FILE-LIST in another window.

If MARK-TO-KILL is non-nil, mark new buffer to kill. If HIGHLIGHT is non-nil, highlight the match. If ITEM in non-nil, search for bibitem instead of database entry. If RETURN is non-nil, just return the entry and restore point.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-cite.el.gz
;;; Find a certain reference in any of the BibTeX files.
;;;###autoload
(defun reftex-pop-to-bibtex-entry (key file-list &optional mark-to-kill
                                       highlight item return)
  "Find BibTeX KEY in any file in FILE-LIST in another window.
If MARK-TO-KILL is non-nil, mark new buffer to kill.
If HIGHLIGHT is non-nil, highlight the match.
If ITEM in non-nil, search for bibitem instead of database entry.
If RETURN is non-nil, just return the entry and restore point."
  (let* ((re
          (if item
              (concat "\\\\bibitem[ \t]*\\(\\[[^]]*\\]\\)?[ \t]*{"
		      (regexp-quote key) "}")
            (concat "@\\(?:\\w\\|\\s_\\)+[ \t\n\r]*[{(][ \t\n\r]*"
		    (regexp-quote key) "[, \t\r\n}]")))
         (buffer-conf (current-buffer))
         file buf pos oldpos)

    (catch 'exit
      (while file-list
        (setq file (car file-list)
              file-list (cdr file-list))
        (unless (setq buf (reftex-get-file-buffer-force file mark-to-kill))
          (error "No such file %s" file))
        (set-buffer buf)
	(setq oldpos (point))
        (widen)
        (goto-char (point-min))
        (if (not (re-search-forward re nil t))
	    (goto-char oldpos) ;; restore previous position of point
          (goto-char (match-beginning 0))
          (setq pos (point))
          (when return
            ;; Just return the relevant entry
            (if item (goto-char (match-end 0)))
            (setq return (buffer-substring
                          (point) (reftex-end-of-bib-entry item)))
	    (goto-char oldpos) ;; restore point.
            (set-buffer buffer-conf)
            (throw 'exit return))
          (switch-to-buffer-other-window buf)
          (goto-char pos)
          (recenter 0)
          (if highlight
              (reftex-highlight 0 (match-beginning 0) (match-end 0)))
          (throw 'exit (selected-window))))
      (set-buffer buffer-conf)
      (if item
          (error "No \\bibitem with citation key %s" key)
        (error "No BibTeX entry with citation key %s" key)))))