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:21:38 -0500 Organization: UseNetServer.com 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 1202138866 30481 80.91.229.12 (4 Feb 2008 15:27:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Feb 2008 15:27:46 +0000 (UTC) To: gnu-emacs-bug@moderators.isc.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 04 16:28:06 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 1JM3Eb-00013H-OO for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Feb 2008 16:27:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM3Dv-0008JD-OG for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Feb 2008 10:27:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JM3AY-0007AL-D0 for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:38 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JM3AP-00077W-6n for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:37 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM3AO-00077O-S9 for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:28 -0500 Original-Received: from moderators.individual.net ([130.133.4.7]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JM3AM-0008Jq-Gw for bug-gnu-emacs@gnu.org; Mon, 04 Feb 2008 10:23:29 -0500 Original-Received: from eweka2.usenetserver.com ([208.49.80.202]) by moderators.individual.net (Exim 4.69) for gnu-emacs-bug@moderators.isc.org with esmtp (envelope-from ) id <1JM38e-0005Fo-K8>; Mon, 04 Feb 2008 16:21:40 +0100 Original-Received: from eweka2.usenetserver.com (eweka2.usenetserver.com [127.0.0.1]) by eweka2.usenetserver.com (8.12.11/8.12.11) with ESMTP id m14FLdWH002242 for ; Mon, 4 Feb 2008 15:21:39 GMT Original-Received: (from news@localhost) by eweka2.usenetserver.com (8.12.11/8.12.11/Submit) id m14FLcB3002241; Mon, 4 Feb 2008 15:21:38 GMT Original-Path: TEKSAVVY.COM-Free-a2kHrUvQQWlmc!not-for-mail Original-Newsgroups: gnu.emacs.bug User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:q9+5pNnv7B1nORKQpqD2gjNLjsc= Original-X-Complaints-To: abuse@usenetserver.com Original-Lines: 39 Original-X-Trace: 8f59247a72d826b5d3adc02012 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) 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:17475 Archived-At: > 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? 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. .