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

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

[elpa] externals/tempel af98dd6b4d 4/9: If no region was given for `r` o


From: ELPA Syncer
Subject: [elpa] externals/tempel af98dd6b4d 4/9: If no region was given for `r` or `r>`, flag the field as "terminating"
Date: Fri, 29 Apr 2022 23:57:46 -0400 (EDT)

branch: externals/tempel
commit af98dd6b4d418d99e47e8fb182546ba9164ce89e
Author: Fritz Grabo <fritz.grabo@gmail.com>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    If no region was given for `r` or `r>`, flag the field as "terminating"
---
 README.org | 3 ++-
 tempel.el  | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/README.org b/README.org
index 5d40fffcf9..dc58b9373e 100644
--- a/README.org
+++ b/README.org
@@ -210,7 +210,8 @@ document the important ones here:
 - ~n~ Inserts a newline.
 - ~>~ Indents with ~indent-according-to-mode~.
 - ~r~ Inserts the current region.
-- ~r>~ The region, but indented.
+  If no region is active, quits the containing template when jumped to.
+- ~r>~ Acts like ~r~, but indent region.
 - ~n>~ Inserts a newline and indents.
 - ~&~ Insert newline if there is only whitespace between line start and point.
 - ~%~ Insert newline if there is only whitespace between point and line end.
diff --git a/tempel.el b/tempel.el
index 8b4327cafd..15864b3c11 100644
--- a/tempel.el
+++ b/tempel.el
@@ -324,7 +324,10 @@ Return the added field."
     (`(l . ,lst) (dolist (e lst) (tempel--element st region e)))
     ((or 'p `(,(or 'p 'P) . ,rest)) (apply #'tempel--placeholder st rest))
     ((or 'r 'r> `(,(or 'r 'r>) . ,rest))
-     (if (not region) (apply #'tempel--placeholder st rest)
+     (if (not region)
+         (when-let (ov (apply #'tempel--placeholder st rest))
+           (unless rest
+             (overlay-put ov 'tempel--terminate t)))
        (goto-char (cdr region))
        (when (eq (or (car-safe elt) elt) 'r>)
          (indent-region (car region) (cdr region) nil))))



reply via email to

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