Function: tempel--insert
tempel--insert is a natively compiled function defined in tempel.el.
Signature
(tempel--insert TEMPLATE REGION)
Documentation
Insert TEMPLATE given the current REGION.
Source Code
;; Defined in /nix/store/b3ibjbs2i12kyhwapibfx6i39f025i85-emacs-packages-deps/share/emacs/site-lisp/elpa/tempel-20260705.1258/tempel.el
(defun tempel--insert (template region)
"Insert TEMPLATE given the current REGION."
(let ((plist (tempel--template-plist template)))
(eval (plist-get plist :pre) 'lexical)
(unless (eq buffer-undo-list t)
(push '(apply tempel--disable) buffer-undo-list))
(setf (alist-get 'tempel--active minor-mode-overriding-map-alist) tempel-map)
(save-excursion
;; Split existing overlays, do not expand within existing field.
(dolist (st tempel--active)
(dolist (ov (cdar st))
(when (and (<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
(setf (overlay-end ov) (point)))))
;; Activate template
(let* ((range (make-overlay (point) (point) nil t))
(st (cons (list range) nil))
(tempel--inhibit-hooks t))
(push st tempel--active)
(cl-loop for x in template until (keywordp x)
do (tempel--element region x))
(move-overlay range (overlay-start range) (point))
;; (overlay-put range 'face 'region) ;; Enable for debugging
(overlay-put range 'modification-hooks (list #'tempel--range-modified))
(overlay-put range 'tempel--range st)
(overlay-put range 'tempel--post (plist-get plist :post))))
(cond
((cl-loop for ov in (caar tempel--active)
never (overlay-get ov 'tempel--field))
(goto-char (overlay-end (caaar tempel--active)))
(tempel--done)) ;; Finalize right away
((cl-loop for ov in (caar tempel--active)
never (and (overlay-get ov 'tempel--field)
(eq (point) (overlay-start ov))))
(tempel-next))))) ;; Jump to first field