[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] fix/undo-point-in-wrong-place 6b3cfe4 4/4: Prepare for
From: |
Phillip Lord |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Stefan Monnier <address@hidden> 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