Function: org-macro--set-templates
org-macro--set-templates is a byte-compiled function defined in
org-macro.el.gz.
Signature
(org-macro--set-templates TEMPLATES)
Documentation
Set template for the macro NAME.
VALUE is the template of the macro. The new value override the previous one, unless VALUE is nil. Return the updated list.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-macro.el.gz
(defun org-macro--set-templates (templates)
"Set template for the macro NAME.
VALUE is the template of the macro. The new value override the
previous one, unless VALUE is nil. Return the updated list."
(let ((new-templates nil))
(pcase-dolist (`(,name . ,value) templates)
(let ((old-definition (assoc name new-templates)))
;; This code can be evaluated unconditionally, as a part of
;; loading Org mode. We *must not* evaluate any code present
;; inside the Org buffer while loading. Org buffers may come
;; from various sources, like received email messages from
;; potentially malicious senders. Org mode might be used to
;; preview such messages and no code evaluation from inside the
;; received Org text should ever happen without user consent.
(when (and (stringp value) (string-match-p "\\`(eval\\>" value))
;; Pre-process the evaluation form for faster macro expansion.
(let* ((args (org-macro--makeargs value))
(body
(condition-case nil
;; `value' is of the form "(eval ...)" but we
;; don't want this to mean to pass the result to
;; `eval' (which would cause double evaluation),
;; so we strip the `eval' away with `cadr'.
(cadr (read value))
(error
(user-error "Invalid definition for macro %S" name)))))
(setq value `(lambda ,args ,body))))
(cond ((and value old-definition) (setcdr old-definition value))
(old-definition)
(t (push (cons name (or value "")) new-templates)))))
new-templates))