Skip to content

Commit

Permalink
Add macro ublt/with-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ubolonton committed Mar 26, 2021
1 parent c1c0dee commit 9b3e8d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/ublt-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@
(eval-defun nil))
(compile-defun)))

(defmacro ublt/with-cleanup (form &rest body)
"Execute FORM with BODY as cleanup code that is executed on error.
Unlike `condition-case', any signal error is propagated.
Unlike `unwind-protect', BODY is not executed if FORM does not signal an error."
(declare (indent 1))
`(let ((err t))
(unwind-protect
(prog1 ,form
(setq err nil))
(when err
,@body))))

(defmacro ublt/examples (&rest body)
nil)

Expand Down

0 comments on commit 9b3e8d7

Please sign in to comment.