[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] atomic-change-group does not preserve value of ,body
From: |
Stefan Monnier |
Subject: |
Re: [PATCH] atomic-change-group does not preserve value of ,body |
Date: |
Tue, 30 Jan 2018 09:56:27 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> (atomic-change-group 5) returns t, while it seems natural to me to expect
> it to work like save-excursion etc. and return 5.
Thanks, I installed the patch below, which uses prog1 instead,
Stefan
diff --git a/lisp/subr.el b/lisp/subr.el
index 24bd28839f..00bab70e8a 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2586,7 +2586,7 @@ y-or-n-p
;;; Atomic change groups.
(defmacro atomic-change-group (&rest body)
- "Perform BODY as an atomic change group.
+ "Like `progn' but perform BODY as an atomic change group.
This means that if BODY exits abnormally,
all of its changes to the current buffer are undone.
This works regardless of whether undo is enabled in the buffer.
@@ -2609,8 +2609,8 @@ atomic-change-group
;; it enables undo if that was disabled; we need
;; to make sure that it gets disabled again.
(activate-change-group ,handle)
- ,@body
- (setq ,success t))
+ (prog1 ,(macroexp-progn body)
+ (setq ,success t)))
;; Either of these functions will disable undo
;; if it was disabled before.
(if ,success