branch: externals/tempel
commit 57bd20da7d86c03b61a378d7a164dccbfad5aab7
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    Revert "Add support for (P ...) tag which always reads from the minibuffer"
    
    This reverts commit d20eeed637b6cd461bb5b06f5f01f515275a8c69.
---
 README.org |  2 --
 tempel.el  | 19 ++++++++-----------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/README.org b/README.org
index 7be6886b00..4fa80e2636 100644
--- a/README.org
+++ b/README.org
@@ -330,8 +330,6 @@ docstring of ~tempel--element~ in tempel.el and originally 
in
   value is bound to ~NAME~ and updated dynamically. If ~NOINSERT~ is non-nil, 
no
   field is inserted and the minibuffer is used for prompting. For clarity, the
   symbol ~noinsert~ should be used as argument.
-- ~(P PROMPT <NAME> <NOINSERT>)~ Works just like ~(p ...)~, but always reads 
from
-  the minibuffer.
 - ~(r PROMPT <NAME> <NOINSERT>)~: Like ~(p ..)~, but if there is a current 
region,
   it is placed here.
 - ~(r> PROMPT <NAME> <NOINSERT>)~ Like ~(r ..)~, but it also indents the 
region.
diff --git a/tempel.el b/tempel.el
index f330aba8a4..a68eb3230c 100644
--- a/tempel.el
+++ b/tempel.el
@@ -386,8 +386,6 @@ A template can consist of elements of several types:
   NOINSERT is non-nil, no field is inserted and the minibuffer is used
   for prompting.  For clarity, the symbol `noinsert' should be used as
   argument.
-- (P PROMPT <NAME> <NOINSERT>): Works just like (p ...), but always
-  reads from the minibuffer.
 - (r PROMPT <NAME> <NOINSERT>): Like (p ..), but if there is a current
   region, it is placed here.
 - (r> PROMPT <NAME> <NOINSERT>): Like (r ..), but is also indents the
@@ -429,11 +427,10 @@ Use caution with templates which execute arbitrary code!"
           (open-line 1)))
     (`(s ,name) (tempel--field name))
     (`(l . ,lst) (dolist (e lst) (tempel--element region e)))
-    ((or 'p `(,(and tag (or 'p 'P)) . ,rest))
-     (apply #'tempel--placeholder (eq tag 'P) rest))
+    ((or 'p `(,(or 'p 'P) . ,rest)) (apply #'tempel--placeholder rest))
     ((or 'r 'r> `(,(or 'r 'r>) . ,rest))
      (if (not region)
-         (when-let* ((ov (apply #'tempel--placeholder nil rest))
+         (when-let* ((ov (apply #'tempel--placeholder rest))
                      ((not rest))
                      (tempel-done-on-region))
            (overlay-put ov 'tempel--enter #'tempel--done))
@@ -463,20 +460,20 @@ Use caution with templates which execute arbitrary code!"
                          (funcall hook elt fields))))
                     elt (cdar tempel--active)))
 
-(defun tempel--placeholder (read &optional prompt name noinsert)
+(defun tempel--placeholder (&optional prompt name noinsert)
   "Handle placeholder element and add field with NAME.
-If READ is non-nil read a string from the minibuffer.  If NOINSERT is
-non-nil do not insert a field, only bind the value to NAME.  PROMPT is
-the optional prompt/default value.  If a field was added, return it."
+If NOINSERT is non-nil do not insert a field, only bind the value to NAME.
+PROMPT is the optional prompt/default value.
+If a field was added, return it."
   (let ((init
          (cond
-          ((and (stringp prompt) (or noinsert read)) (read-string prompt))
+          ((and (stringp prompt) noinsert) (read-string prompt))
           ((stringp prompt) prompt)
           ;; TEMPEL EXTENSION: Evaluate prompt
           (t (eval prompt (cdar tempel--active))))))
     (if noinsert
         (progn (setf (alist-get name (cdar tempel--active)) init) nil)
-      (tempel--field name init (and (not read) (stringp prompt))))))
+      (tempel--field name init (stringp prompt)))))
 
 (defun tempel--insert (template region)
   "Insert TEMPLATE given the current REGION."

Reply via email to