Function: forms-insert-record
forms-insert-record is an interactive and byte-compiled function
defined in forms.el.gz.
Signature
(forms-insert-record ARG)
Documentation
Create a new record before the current one.
With ARG: store the record after the current one.
If forms-new-record-filter contains the name of a function,
it is called to fill (some of) the fields with default values.
If forms-insert-after is non-nil, the default behavior is to insert
after the current record.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/forms.el.gz
;; Sample:
;; (defun my-new-record-filter (the-fields)
;; ;; numbers are relative to 1
;; (aset the-fields 4 (current-time-string))
;; (aset the-fields 6 (user-login-name))
;; the-list)
;; (setq forms-new-record-filter 'my-new-record-filter)
(defun forms-insert-record (arg)
"Create a new record before the current one.
With ARG: store the record after the current one.
If `forms-new-record-filter' contains the name of a function,
it is called to fill (some of) the fields with default values.
If `forms-insert-after' is non-nil, the default behavior is to insert
after the current record."
(interactive "P")
(if forms-read-only
(error ""))
(let (ln the-list the-record)
(if (or (and arg forms-insert-after)
(and (not arg) (not forms-insert-after)))
(setq ln forms--current-record)
(setq ln (1+ forms--current-record)))
(forms--checkmod)
(if forms-new-record-filter
;; As a service to the user, we add a zeroth element so she
;; can use the same indices as in the forms definition.
(let ((the-fields (make-vector (1+ forms-number-of-fields) "")))
(setq the-fields (funcall forms-new-record-filter the-fields))
(setq the-list (cdr (append the-fields nil))))
(setq the-list (make-list forms-number-of-fields "")))
(setq the-record (mapconcat #'identity the-list forms-field-sep))
(with-current-buffer forms--file-buffer
(forms--goto-record ln)
(open-line 1)
(insert the-record)
(beginning-of-line))
(setq forms--current-record ln))
(setq forms--total-records (1+ forms--total-records))
(forms-jump-record forms--current-record))