[Top][All Lists]

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

Re: nesting of unwind-protect and atomic-change-group

From: Stefan Monnier
Subject: Re: nesting of unwind-protect and atomic-change-group
Date: Mon, 04 Feb 2008 10:21:38 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

> fun1 throws an error and puts point at the buffer location the error
> refers to. fun2 does not put point at the buffer location that
> corresponds to the error. The only difference between fun1 and fun2
> is the order of unwind-protect and atomic-change-group.
> (I find it counterintuitive that both functions put the message 
> "search "foo"" in the *Messages* buffer before the error message,
> but I expect that this has to do with how the error is handled.)

When atomic-change-group undoes changes, it does it like "undo", which
means it also moves point.  That's what you're seeing: the goto-char in
your unwind-protect is "ignored" because the subsequent undo moves
point elsewhere.

Maybe we should wrap cancel-change-group within save-excursion, as in
the patch below?


--- orig/lisp/subr.el
+++ mod/lisp/subr.el
@@ -2008,6 +2008,7 @@
 (defun cancel-change-group (handle)
   "Finish a change group made with `prepare-change-group' (which see).
 This finishes the change group by reverting all of its changes."
+  (save-excursion
   (dolist (elt handle)
     (with-current-buffer (car elt)
       (setq elt (cdr elt))
@@ -2029,7 +2030,7 @@
          (setcar elt old-car)
          (setcdr elt old-cdr))
        ;; Revert the undo info to what it was when we grabbed the state.
-       (setq buffer-undo-list elt)))))
+          (setq buffer-undo-list elt))))))
 ;;;; Display-related functions.

reply via email to

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