Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions tempel.el
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ Return the added field."
(open-line 1)))
(`(s ,name) (tempel--field name))
(`(l . ,lst) (dolist (e lst) (tempel--element region e)))
(`(P . ,lst) ; Only for tempo backward compatibility
(tempel--placeholder (nth 0 lst) (nth 1 lst) (nth 2 lst) :only-prompt))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding only-prompt - I am not sure if I had already commented on that. (The inline comment history seems also affected by force pushes). In Tempel every field is "interactive". In contrast, reading from the minibuffer affects the experience negatively since template expansion is paused until the result from the minibuffer has been read. Therefore I had not supported this feature in Tempel until now. read-string is only used if noinsert is specified, since then there is no other possibility to read the input.

Copy link
Copy Markdown
Collaborator Author

@DevelopmentCool2449 DevelopmentCool2449 Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding only-prompt - I am not sure if I had already commented on that. (The inline comment history seems also affected by force pushes).

Oh, i didn't know it, I'm sorry.

In Tempel every field is "interactive". In contrast, reading from the minibuffer affects the experience negatively since template expansion is paused until the result from the minibuffer has been read. Therefore I had not supported this feature in Tempel until now. read-string is only used if noinsert is specified, since then there is no other possibility to read the input.

Fine, i've removed this part.

Although this will break some tests in tempel-tempo-tests.el, I'll see how to fix this.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can maybe keep the prompt argument such that you can override it in tempo.el. However I would not change the behavior in Tempel itself. But then, if we use Tempel as backend anyway, then we can simply consistenly use Tempel behavior. This means simply removing support for tempo-interactive.

((or 'p `(,(or 'p 'P) . ,rest)) (apply #'tempel--placeholder rest))
((or 'r 'r> `(,(or 'r 'r>) . ,rest))
(if (not region)
Expand Down Expand Up @@ -408,14 +410,18 @@ Return the added field."
(funcall hook elt fields))))
elt (cdar tempel--active)))

(defun tempel--placeholder (&optional prompt name noinsert)
(defun tempel--placeholder (&optional prompt name noinsert only-prompt)
"Handle placeholder element and add field with NAME.
If NOINSERT is non-nil do not insert a field, only bind the value to NAME.

If ONLY-PROMPT is non-nil, prompt in the minibuffer for a value to
insert.

PROMPT is the optional prompt/default value.
If a field was added, return it."
(let ((init
(cond
((and (stringp prompt) noinsert) (read-string prompt))
((and (stringp prompt) (or only-prompt noinsert)) (read-string prompt))
((stringp prompt) prompt)
;; TEMPEL EXTENSION: Evaluate prompt
(t (eval prompt (cdar tempel--active))))))
Expand Down