Function: r2b-get-field
r2b-get-field is a byte-compiled function defined in refbib.el.gz.
Signature
(r2b-get-field VAR FIELD &optional UNIQUE REQUIRED CAPITALIZE)
Documentation
Set VAR to string value of FIELD, if any. If none, VAR is set to
nil. If multiple fields appear, then separate values with the
'\nand\t\t', unless UNIQUE is non-nil, in which case log a warning
and just concatenate the values. Trim off leading blanks and tabs on
first line, and trailing blanks and tabs of every line. Log a warning
and set VAR to the empty string if REQUIRED is true. Capitalize as a
title if CAPITALIZE is true. Returns value of VAR.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/refbib.el.gz
(defun r2b-get-field (var field &optional unique required capitalize)
"Set VAR to string value of FIELD, if any. If none, VAR is set to
nil. If multiple fields appear, then separate values with the
'\\nand\\t\\t', unless UNIQUE is non-nil, in which case log a warning
and just concatenate the values. Trim off leading blanks and tabs on
first line, and trailing blanks and tabs of every line. Log a warning
and set VAR to the empty string if REQUIRED is true. Capitalize as a
title if CAPITALIZE is true. Returns value of VAR."
(let (item val (not-past-end t))
(r2b-trace "snarfing %s" field)
(goto-char (point-min))
(while (and not-past-end
(re-search-forward
(concat "^" field "\\b[ \t]*\\(.*[^ \t\n]\\)[ \t]*") nil t))
(setq item (r2b-match 1))
(while (and (setq not-past-end (zerop (forward-line 1)))
(not (looking-at "[ \t]*$\\|%")))
(looking-at "\\(.*[^ \t\n]\\)[ \t]*$")
(setq item (concat item "\n" (r2b-match 1)))
)
(if (null val)
(setq val item)
(if unique
(progn
(r2b-warning "*Invalid multiple field %s %s" field item)
(setq val (concat val "\n" item))
)
(setq val (concat val "\n\t\tand " item))
)
)
)
(if (and val capitalize)
(setq val (r2b-capitalize-title val)))
(set var val)
(if (and (null val) required)
(r2b-require var))
))