[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/tempel 91baf97c37 3/3: Add user elements
From: |
ELPA Syncer |
Subject: |
[elpa] externals/tempel 91baf97c37 3/3: Add user elements |
Date: |
Sun, 9 Jan 2022 21:57:52 -0500 (EST) |
branch: externals/tempel
commit 91baf97c37c12f42c306e2f4330cdb4982e291db
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add user elements
---
tempel.el | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tempel.el b/tempel.el
index cf0e9c8185..2f7d93b243 100644
--- a/tempel.el
+++ b/tempel.el
@@ -66,6 +66,12 @@
"Annotation width for `tempel-complete'."
:type '(choice (const nil integer)))
+(defcustom tempel-user-elements nil
+ "List of user element functions.
+The function take a template element as argument and must return either
+nil or a new template element, which is subsequently evaluated."
+ :type 'hook)
+
(defface tempel-field
'((((class color) (min-colors 88) (background light))
:background "#fdf0ff" :foreground "#541f4f")
@@ -292,7 +298,10 @@ INIT is the optional initial input."
(goto-char (cdr region))
(when (eq (or (car-safe elt) elt) 'r>)
(indent-region (car region) (cdr region) nil))))
- (_ (tempel--form st elt)))) ;; TEMPEL EXTENSION: Evaluate forms
+ (_ (if-let (ret (run-hook-with-args-until-success 'tempel-user-elements
elt))
+ (tempel--element st region ret)
+ ;; TEMPEL EXTENSION: Evaluate forms
+ (tempel--form st elt)))))
(defun tempel--placeholder (st &optional prompt name noinsert)
"Handle placeholder element and add field with NAME to ST.