Function: bibtex-make-field

bibtex-make-field is an interactive and byte-compiled function defined in bibtex.el.gz.

Signature

(bibtex-make-field FIELD &optional MOVE INTERACTIVE NODELIM)

Documentation

Make a field named FIELD in current BibTeX entry.

FIELD is either a string or a list of the form
(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
bibtex-BibTeX-entry-alist and friends. If MOVE is non-nil, move point past the present field before making the new field. If INTERACTIVE is non-nil, move point to the end of the new field. Otherwise move point past the new field. MOVE and INTERACTIVE are t when called interactively. INIT is surrounded by field delimiters, unless NODELIM is non-nil.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/bibtex.el.gz
(defun bibtex-make-field (field &optional move interactive nodelim)
  "Make a field named FIELD in current BibTeX entry.
FIELD is either a string or a list of the form
\(FIELD-NAME COMMENT-STRING INIT ALTERNATIVE-FLAG) as in
`bibtex-BibTeX-entry-alist' and friends.
If MOVE is non-nil, move point past the present field before making
the new field.  If INTERACTIVE is non-nil, move point to the end of
the new field.  Otherwise move point past the new field.
MOVE and INTERACTIVE are t when called interactively.
INIT is surrounded by field delimiters, unless NODELIM is non-nil."
  (interactive
   (list (let ((completion-ignore-case t)
               (field-list (bibtex-field-list
                            (save-excursion
                              (bibtex-beginning-of-entry)
                              (looking-at bibtex-any-entry-maybe-empty-head)
                              (bibtex-type-in-head)))))
           (completing-read "BibTeX field name: "
                            (append (car field-list) (cdr field-list))
                            nil nil nil bibtex-field-history))
         t t))
  (unless (consp field)
    (setq field (list field)))
  (when move
    (bibtex-find-text)
    (if (looking-at "[}\"]")
        (forward-char)))
  (insert ",\n")
  (indent-to-column (+ bibtex-entry-offset bibtex-field-indentation))
  ;; If there are multiple sets of alternatives, we could use
  ;; the numeric value of (nth 3 field) to number these sets.  Useful??
  (if (nth 3 field) (insert "ALT"))
  (insert (car field) " ")
  (if bibtex-align-at-equal-sign
      (indent-to-column (+ bibtex-entry-offset
                           (- bibtex-text-indentation 2))))
  (insert "= ")
  (unless bibtex-align-at-equal-sign
    (indent-to-column (+ bibtex-entry-offset
                         bibtex-text-indentation)))
  (let ((init (nth 2 field)))
    (if (not init) (setq init "")
      (if (functionp init) (setq init (funcall init)))
      (unless (stringp init) (user-error "`%s' is not a string" init)))
    ;; NODELIM is required by `bibtex-insert-kill'
    (if nodelim (insert init)
      (insert (bibtex-field-left-delimiter) init
              (bibtex-field-right-delimiter))))
  (when interactive
    ;; (bibtex-find-text nil nil bibtex-help-message)
    (if (memq (preceding-char) '(?} ?\")) (forward-char -1))
    (if bibtex-help-message (bibtex-print-help-message (car field)))))