From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: Re: nesting of unwind-protect and atomic-change-group Date: Mon, 04 Feb 2008 10:23:00 -0500 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1202138869 30492 80.91.229.12 (4 Feb 2008 15:27:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Feb 2008 15:27:49 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 04 16:28:10 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JM3Ea-00019D-LW for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Feb 2008 16:27:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM3E5-0008Nr-6Z for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Feb 2008 10:27:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JM3Aa-0007Aq-Hp for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JM3AM-00076S-4m for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:39 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM3AL-00076N-Ks for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:25 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JM3AL-0008Vu-7x for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:25 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAGm8pkfO+J95dGdsb2JhbACQKQEwmwWBAg X-IronPort-AV: E=Sophos;i="4.25,303,1199682000"; d="scan'208";a="13607415" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 04 Feb 2008 10:23:00 -0500 Original-Received: from pastel.home ([206.248.159.121]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id KRB86700 for ; Mon, 04 Feb 2008 10:23:00 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 321637F47; Mon, 4 Feb 2008 10:23:00 -0500 (EST) In-Reply-To: (Roland Winkler's message of "Sat, 2 Feb 2008 18:54:03 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:17476 Archived-At: >>>>> "Roland" == Roland Winkler 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. Stefan --- 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.