Function: tempo-insert
tempo-insert is a byte-compiled function defined in tempo.el.gz.
Signature
(tempo-insert ELEMENT ON-REGION)
Documentation
Insert a template ELEMENT.
Insert one element from a template. If ON-REGION is non-nil the r
elements are replaced with the current region.
See documentation for tempo-define-template for the kind of elements
possible.
Source Code
;; Defined in /usr/src/emacs/lisp/tempo.el.gz
;;;
;;; tempo-insert
(defun tempo-insert (element on-region)
"Insert a template ELEMENT.
Insert one element from a template. If ON-REGION is non-nil the `r'
elements are replaced with the current region.
See documentation for `tempo-define-template' for the kind of elements
possible."
(pcase element
((pred stringp) (tempo-process-and-insert-string element))
(`(p . ,rest) (tempo-insert-prompt-compat rest))
(`(P . ,rest) (let ((tempo-interactive t))
(tempo-insert-prompt-compat rest)))
;; (`(v ,name ,data) (tempo-save-named name nil data))
(`(r . ,rest) (if on-region
(goto-char tempo-region-stop)
(tempo-insert-prompt-compat rest)))
(`(r> . ,rest) (if on-region
(progn
(goto-char tempo-region-stop)
(indent-region tempo-region-start
tempo-region-stop))
(tempo-insert-prompt-compat rest)))
(`(s ,name) (tempo-insert-named name))
(`(l . ,rest) (dolist (elt rest) (tempo-insert elt on-region)))
('p (tempo-insert-mark (point-marker)))
('r (if on-region
(goto-char tempo-region-stop)
(tempo-insert-mark (point-marker))))
('r> (if on-region
(progn
(goto-char tempo-region-stop)
(indent-region tempo-region-start tempo-region-stop))
(tempo-insert-mark (point-marker))))
('> (indent-according-to-mode))
('& (if (not (or (= (current-column) 0)
(save-excursion
(re-search-backward
"^\\s-*\\=" nil t))))
(insert "\n")))
('% (if (not (or (eolp)
(save-excursion
(re-search-forward
"\\=\\s-*$" nil t))))
(insert "\n")))
('n (insert "\n"))
('n> (insert "\n") (indent-according-to-mode))
;; Bug: If the 'o is the first element in a template, strange
;; things can happen when the template is inserted at the
;; beginning of a line.
('o (if (not (or on-region
(eolp)
(save-excursion
(re-search-forward
"\\=\\s-*$" nil t))))
(open-line 1)))
('nil nil)
(_ (tempo-insert (or (tempo-is-user-element element)
(eval element t))
on-region))))