Function: bibtex-entry-update

bibtex-entry-update is an interactive and byte-compiled function defined in bibtex.el.gz.

Signature

(bibtex-entry-update &optional ENTRY-TYPE)

Documentation

Update an existing BibTeX entry.

In the BibTeX entry at point, make new fields for those items that may occur according to bibtex-field-list, but are not yet present. Also, add field delimiters to numerical fields if they are not present. If ENTRY-TYPE is non-nil, change first the entry type to ENTRY-TYPE. When called interactively with a prefix arg, query for a value of ENTRY-TYPE.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
(defun bibtex-entry-update (&optional entry-type)
  "Update an existing BibTeX entry.
In the BibTeX entry at point, make new fields for those items that may occur
according to `bibtex-field-list', but are not yet present.
Also, add field delimiters to numerical fields if they are not present.
If ENTRY-TYPE is non-nil, change first the entry type to ENTRY-TYPE.
When called interactively with a prefix arg, query for a value of ENTRY-TYPE."
  (interactive
   (list (if current-prefix-arg
             (let ((completion-ignore-case t))
               (completing-read "New entry type: " bibtex-entry-alist
                                nil t nil 'bibtex-entry-type-history)))))
  (save-excursion
    (bibtex-beginning-of-entry)
    (when (looking-at bibtex-entry-maybe-empty-head)
      (goto-char (match-end 0))
      (if entry-type
          (save-excursion
            (replace-match (concat "@" entry-type) nil nil nil 1))
        (setq entry-type (bibtex-type-in-head)))
      (let* ((field-list (bibtex-field-list entry-type))
             (required (copy-tree (car field-list)))
             (optional (copy-tree (cdr field-list)))
             bounds)
        (while (setq bounds (bibtex-parse-field))
          (let ((fname (bibtex-name-in-field bounds t))
                (end (copy-marker (bibtex-end-of-field bounds) t)))
            (setq required (delete (assoc-string fname required t) required)
                  optional (delete (assoc-string fname optional t) optional))
            (when (string-match "\\`[0-9]+\\'"
                                (bibtex-text-in-field-bounds bounds))
              (goto-char (bibtex-end-of-text-in-field bounds))
              (insert (bibtex-field-right-delimiter))
              (goto-char (bibtex-start-of-text-in-field bounds))
              (insert (bibtex-field-left-delimiter)))
            (goto-char end)))
        (skip-chars-backward " \t\n")
        (mapc #'bibtex-make-field required)
        (mapc #'bibtex-make-optional-field optional)))))