Function: reftex-format-bib-entry

reftex-format-bib-entry is a byte-compiled function defined in reftex-cite.el.gz.

Signature

(reftex-format-bib-entry ENTRY)

Documentation

Format a BibTeX ENTRY so that it is nice to look at.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/reftex-cite.el.gz
(defun reftex-format-bib-entry (entry)
  "Format a BibTeX ENTRY so that it is nice to look at."
  (let*
      ((auth-list (reftex-get-bib-names "author" entry))
       (authors (mapconcat #'identity auth-list ", "))
       (year      (reftex-get-bib-field "year" entry))
       (title     (reftex-get-bib-field "title" entry))
       (type      (reftex-get-bib-field "&type" entry))
       (key       (reftex-get-bib-field "&key"  entry))
       (extra
        (cond
         ((equal type "article")
          (concat (let ((jt (reftex-get-bib-field "journal" entry)))
                    ;; biblatex prefers the alternative journaltitle
                    ;; field, so check if that exists in case journal
                    ;; is empty.
                    (if (zerop (length jt))
                        (reftex-get-bib-field "journaltitle" entry)
                      jt))
                  " "
                  (reftex-get-bib-field "volume" entry) ", "
                  (reftex-get-bib-field "pages" entry)))
         ((equal type "book")
          (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
         ((equal type "phdthesis")
          (concat "PhD: " (reftex-get-bib-field "school" entry)))
         ((equal type "mastersthesis")
          (concat "Master: " (reftex-get-bib-field "school" entry)))
         ((equal type "inbook")
          (concat "Chap: " (reftex-get-bib-field "chapter" entry)
                  ", pp. " (reftex-get-bib-field "pages"   entry)))
         ((or (equal type "conference")
              (equal type "incollection")
              (equal type "inproceedings"))
          (reftex-get-bib-field "booktitle" entry "in: %s"))
         (t ""))))
    (setq authors (reftex-truncate authors 30 t t))
    (when (reftex-use-fonts)
      (put-text-property 0 (length key)     'face reftex-label-face
                         key)
      (put-text-property 0 (length authors) 'face reftex-bib-author-face
                         authors)
      (put-text-property 0 (length year)    'face reftex-bib-year-face
                         year)
      (put-text-property 0 (length title)   'face reftex-bib-title-face
                         title)
      (put-text-property 0 (length extra)   'face reftex-bib-extra-face
                         extra))
    (concat key "\n     " authors " " year " " extra "\n     " title "\n\n")))