Function: tempel--field

tempel--field is a natively compiled function defined in tempel.el.

Signature

(tempel--field &optional NAME INIT DEFAULT)

Documentation

Add template field.

NAME is the optional field name. INIT is the optional initial input. DEFAULT specifies if initial input is a default value. Return the added field.

Source Code

;; Defined in /nix/store/b3ibjbs2i12kyhwapibfx6i39f025i85-emacs-packages-deps/share/emacs/site-lisp/elpa/tempel-20260705.1258/tempel.el
(defun tempel--field (&optional name init default)
  "Add template field.
NAME is the optional field name.
INIT is the optional initial input.
DEFAULT specifies if initial input is a default value.
Return the added field."
  (let ((st (car tempel--active))
        (ov (make-overlay (point) (point)))
        (hooks (list #'tempel--field-modified)))
    (push ov (cdar st))
    (when name
      (overlay-put ov 'tempel--name name)
      (setf init (or init (alist-get name (cdr st) ""))
            (alist-get name (cdr st)) init))
    (when (and init (not (equal init "")))
      (insert init)
      (move-overlay ov (overlay-start ov) (point)))
    (tempel--update-mark ov)
    (overlay-put ov 'tempel--field st)
    (overlay-put ov 'modification-hooks hooks)
    (overlay-put ov 'insert-in-front-hooks hooks)
    (overlay-put ov 'insert-behind-hooks hooks)
    (overlay-put ov 'face 'tempel-field)
    (when (and init default)
      (overlay-put ov 'face 'tempel-default)
      (overlay-put ov 'tempel--default
                   (if (string-suffix-p ": " init) 'end 'start)))
    (tempel--sync-fields st ov)
    (goto-char (overlay-end ov))
    ov))