emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/tempel bf95b3f1c2 31/82: Add support for (q (FORM ...)


From: ELPA Syncer
Subject: [elpa] externals/tempel bf95b3f1c2 31/82: Add support for (q (FORM ...) var)
Date: Sun, 9 Jan 2022 20:58:43 -0500 (EST)

branch: externals/tempel
commit bf95b3f1c236e9070da995376efd58e321b76f08
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add support for (q (FORM ...) var)
---
 README.org | 2 ++
 tempel.el  | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/README.org b/README.org
index c366d493e1..7b79213349 100644
--- a/README.org
+++ b/README.org
@@ -116,5 +116,7 @@ important ones here:
 Furthermore Tempel supports two syntax extensions:
 
  - ~(q PROMPT NAME)~ Query the user via ~read-string~ and store the result in 
variable ~NAME~.
+ - ~(q (form ...) NAME)~ Query the user using ~FORM~ and store the result in 
variable ~NAME~.
+   Use caution with templates which execute code!
  - ~(form ...)~ Other Lisp forms are evaluated. Named fields are lexically 
bound.
    Use caution with templates which execute code!
diff --git a/tempel.el b/tempel.el
index f817473f70..1a7e69ddc5 100644
--- a/tempel.el
+++ b/tempel.el
@@ -187,7 +187,9 @@ BEG and END are the boundaries of the modification."
 
 (defun tempel--query (st prompt name)
   "Read input with PROMPT and assign to binding NAME in ST."
-  (setf (alist-get name (cdr st)) (read-string prompt)))
+  (setf (alist-get name (cdr st)) (if (stringp prompt)
+                                      (read-string prompt)
+                                    (eval prompt 'lexical-binding))))
 
 (defun tempel--element (st element region)
   "Add template ELEMENT to ST given the REGION."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]