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

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

[elpa] externals/tempel f4e6b35fbf: Use with-demoted-errors correctly


From: ELPA Syncer
Subject: [elpa] externals/tempel f4e6b35fbf: Use with-demoted-errors correctly
Date: Tue, 11 Oct 2022 13:58:15 -0400 (EDT)

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

    Use with-demoted-errors correctly
---
 tempel.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tempel.el b/tempel.el
index 435e35c1d2..f504b1d0f5 100644
--- a/tempel.el
+++ b/tempel.el
@@ -308,14 +308,19 @@ Return the added field."
       (push ov (car st))
       ov)))
 
+(defmacro tempel--protect (&rest body)
+  "Protect BODY, catch errors."
+  `(with-demoted-errors "Tempel Error: %S"
+     ,@body))
+
 (defun tempel--element (st region elt)
   "Add template ELT to ST given the REGION."
   (pcase elt
     ('nil)
     ('n (insert "\n"))
     ;; `indent-according-to-mode' fails sometimes in Org. Ignore errors.
-    ('n> (insert "\n") (with-demoted-errors (indent-according-to-mode)))
-    ('> (with-demoted-errors (indent-according-to-mode)))
+    ('n> (insert "\n") (tempel--protect (indent-according-to-mode)))
+    ('> (tempel--protect (indent-according-to-mode)))
     ((pred stringp) (insert elt))
     ('& (unless (or (bolp) (save-excursion (re-search-backward "^\\s-*\\=" nil 
t)))
           (insert "\n")))
@@ -592,8 +597,7 @@ This is meant to be a source in `tempel-template-sources'."
         (buf (current-buffer)))
     ;; Ignore errors in post expansion to ensure that templates can be
     ;; terminated gracefully.
-    (with-demoted-errors
-      (eval (overlay-get (caar st) 'tempel--post) (cdr st)))
+    (tempel--protect (eval (overlay-get (caar st) 'tempel--post) (cdr st)))
     (with-current-buffer buf
       (tempel--disable st))))
 



reply via email to

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