Function: bibtex-entry-alist

bibtex-entry-alist is a byte-compiled function defined in bibtex.el.gz.

Signature

(bibtex-entry-alist DIALECT)

Documentation

Return entry-alist for DIALECT.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
;; It would be nice to process here `bibtex-include-OPTcrossref'
;; once and for all, so that then the variable `bibtex-entry-alist' need not
;; distinguish anymore between CROSSREF and OPTIONAL fields.  But even if
;; an entry is listed in `bibtex-include-OPTcrossref', actual entries need not
;; use a crossref field.
(defun bibtex-entry-alist (dialect)
  "Return entry-alist for DIALECT."
  (cl-flet ((vfun (fmt)
              (let ((var (intern (format fmt dialect))))
                (if (boundp var)
                    (symbol-value var)
                  (user-error "BibTeX dialect `%s': `%s' undefined"
                              dialect var)))))
    (let* ((main-entry-alist (vfun "bibtex-%s-entry-alist"))
           (aux-entry-alist (vfun "bibtex-%s-aux-entry-alist"))
           (aux-opt-alist (append (vfun "bibtex-%s-aux-opt-alist")
                                  bibtex-aux-opt-alist))
           ;; For look-up put auxiliary entries before regular entries.
           (all-alist (append aux-entry-alist main-entry-alist))
           entry-alist)
      (dolist (entry (mapcar
                      ;; Expand aliases
                      (lambda (entry)
                        (let ((elt (nth 2 entry))
                              ref)
                          (cond ((listp elt) ; proper entry
                                 entry)
                                ((setq ref (assoc-string elt all-alist t)) ; alias
                                 (append (take 2 entry) (nthcdr 2 ref)))
                                (t (user-error "Alias `%s' undefined" entry)))))
                      ;; Give higher precedence to entry definitions
                      ;; in aux-entry-alist.
                      (reverse (append main-entry-alist aux-entry-alist))))
        ;; Include each entry only once.
        (unless (assoc-string (car entry) entry-alist t)
          (push (if aux-opt-alist
                    ;; Splice aux-opt-alist into entry (nondestructively).
                    ;; Elements in aux-opt-alist take precedence over elements
                    ;; in opt-alist of entry.
                    (let ((aux-opt-alist aux-opt-alist))
                      (mapc (lambda (field)
                              (unless (assoc-string (car field) aux-opt-alist t)
                                (push field aux-opt-alist)))
                            (reverse (nth 4 entry)))
                      (append (take 4 entry) (list aux-opt-alist)))
                  entry)
                entry-alist)))
      entry-alist)))