[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:23:00 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

>>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:

> On Sat Feb 2 2008 Richard Stallman wrote:
>> When combining unwind-protect and atomic-change-group I found that
>> putting unwind-protect outermost worked for me (i.e., an unwindform
>> moving point to the buffer location where the error occured was
>> obeyed), whereas doing it the other way round didn't work for me
>> (the unwindform was ignored). 
>> An unwind-protect will _work_ either inside or outside
>> of atomic-change-group.  Whatever problem you encountered
>> must be more specific.  I can't guess what it might be.

> Thanks for clarifying this. My real-world example based on
> bibtex-entry-format is too complicated as a test case. I'll boil it
> down to something more amenable.

The patch below should make both cases work similarly.


--- 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]