From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] fix/undo-point-in-wrong-place 6b3cfe4 4/4: Prepare for record now separate function. Date: Mon, 23 Nov 2015 17:41:28 +0000 Message-ID: <87k2p8aa0n.fsf@russet.org.uk> 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 1448300538 21677 80.91.229.3 (23 Nov 2015 17:42:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 23 Nov 2015 17:42:18 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 23 18:42:17 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 1a0v84-0007ZV-Ig for ged-emacs-devel@m.gmane.org; Mon, 23 Nov 2015 18:42:16 +0100 Original-Received: from localhost ([::1]:33776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0v85-0004Io-6W for ged-emacs-devel@m.gmane.org; Mon, 23 Nov 2015 12:42:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0v7N-0003dZ-Ju for emacs-devel@gnu.org; Mon, 23 Nov 2015 12:41:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0v7K-00086f-1E for emacs-devel@gnu.org; Mon, 23 Nov 2015 12:41:33 -0500 Original-Received: from cheviot22.ncl.ac.uk ([128.240.234.22]:39236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0v7J-00086U-SV for emacs-devel@gnu.org; Mon, 23 Nov 2015 12:41:29 -0500 Original-Received: from smtpauth-vm.ncl.ac.uk ([10.8.233.129] helo=smtpauth.ncl.ac.uk) by cheviot22.ncl.ac.uk with esmtp (Exim 4.63) (envelope-from ) id 1a0v7J-0002eF-DA; Mon, 23 Nov 2015 17:41:29 +0000 Original-Received: from jangai.ncl.ac.uk ([10.66.67.223] helo=localhost) by smtpauth.ncl.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1a0v7J-0002pV-0W; Mon, 23 Nov 2015 17:41:29 +0000 In-Reply-To: (Stefan Monnier's message of "Sun, 22 Nov 2015 00:21:27 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 128.240.234.22 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:195129 Archived-At: Stefan Monnier writes: >> 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). Yep, you are right. Although, the strange thing is, this should be enough to solve the problem with a "kill-region" command (which needs record_point to work). Except that this doesn't work because, AFAICT, the value of point gets changed *before* we get to the record_delete. delete-backward-char works without using record_point, as does kill-word. I think it is buffer-substring--filter that is to blame which resets point to the start of the region immediately before deleting it. > 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". Ah, yes. > > 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. > I've pushed an alternative solution (yes, I know I said I would just do what you told me, but I could not resist). There is already last_point_position and prev_buffer variables which do this, as far as I can tell. Phil