Function: bibtex-map-entries

bibtex-map-entries is a byte-compiled function defined in bibtex.el.gz.

Signature

(bibtex-map-entries FUN)

Documentation

Call FUN for each BibTeX entry in buffer (possibly narrowed).

FUN is called with three arguments, the key of the entry and the buffer positions of beginning and end of entry. Also, point is at beginning of entry and match-data corresponds to the header of the entry, see regexp bibtex-entry-head. If bibtex-sort-ignore-string-entries is non-nil, FUN is not called for @String entries.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
(defun bibtex-map-entries (fun)
  "Call FUN for each BibTeX entry in buffer (possibly narrowed).
FUN is called with three arguments, the key of the entry and the buffer
positions of beginning and end of entry.  Also, point is at beginning of
entry and `match-data' corresponds to the header of the entry,
see regexp `bibtex-entry-head'.  If `bibtex-sort-ignore-string-entries'
is non-nil, FUN is not called for @String entries."
  (let ((case-fold-search t)
        (end-marker (make-marker))
        found)
    ;; Use marker to keep track of the buffer position of the end of
    ;; a BibTeX entry as this position may change during reformatting.
    (set-marker-insertion-type end-marker t)
    (save-excursion
      (goto-char (point-min))
      (let ((prev nil))
        (while (setq found (bibtex-skip-to-valid-entry))
          ;; If we have invalid entries, ensure that we have forward
          ;; progress so that we don't infloop.
          (if (equal (point) prev)
              (forward-line 1)
            (setq prev (point))
            (set-marker end-marker (cdr found))
            (looking-at bibtex-any-entry-maybe-empty-head)
            (funcall fun (bibtex-key-in-head "") (car found) end-marker)
            (goto-char end-marker)))))))