From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] fix/undo-point-in-wrong-place 6b3cfe4 4/4: Prepare for record now separate function. Date: Sun, 22 Nov 2015 00:21:27 -0500 Message-ID: References: <20151120221320.21643.45342@vcs.savannah.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1448169706 14395 80.91.229.3 (22 Nov 2015 05:21:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 22 Nov 2015 05:21:46 +0000 (UTC) Cc: Phillip Lord To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 22 06:21:37 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a0N5k-0003hA-QG for ged-emacs-devel@m.gmane.org; Sun, 22 Nov 2015 06:21:36 +0100 Original-Received: from localhost ([::1]:54847 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0N5k-00061k-LV for ged-emacs-devel@m.gmane.org; Sun, 22 Nov 2015 00:21:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0N5h-00061c-S2 for emacs-devel@gnu.org; Sun, 22 Nov 2015 00:21:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0N5e-0000wF-Oo for emacs-devel@gnu.org; Sun, 22 Nov 2015 00:21:33 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:59965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0N5e-0000w3-II for emacs-devel@gnu.org; Sun, 22 Nov 2015 00:21:30 -0500 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id tAM5LR0d025836; Sun, 22 Nov 2015 00:21:28 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 6A5F7AE22C; Sun, 22 Nov 2015 00:21:27 -0500 (EST) In-Reply-To: (Phillip Lord's message of "Fri, 20 Nov 2015 22:13:24 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5497=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5497> : inlines <4017> : streams <1542083> : uri <2087361> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:194983 Archived-At: > PT is the position of point that will naturally occur as a result of the > undo record that will be added just after this command terminates. */ This comment is invalidated by your change. > + record_point (beg + SCHARS (string)); Hmm I thought the sign on sbeg took care of this case already (i.e. the record_point should only record something when point was neither at the beginning nor at the end of the deleted string). As for the source of the bug (i.e. what change caused the new behavior): in the old code, undo-boundary was called right before every command (whether there was a need to push a boundary or not), so contrary to the comment in the code, last_boundary_position was actually recording "position of point at beginning of the command" rather than "position of point last time we inserted a boundary". So the hunk below should recover the old behavior (well, more or less: it wouldn't compile as is, but I hope you get the idea). But to fix it right, we should rename these vars and adjust their comment to better reflect the way they're really used. Stefan diff --git a/src/keyboard.c b/src/keyboard.c index 849066c..125091e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1448,6 +1448,8 @@ command_loop_1 (void) /* Ensure that we have added appropriate undo-boundaries as a result of changes from the last command. */ call0 (Qundo_auto__add_boundary); + last_boundary_position = PT; + last_boundary_buffer = current_buffer; call1 (Qcommand_execute, Vthis_command);