[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: undo boundaries
From: |
martin rudalics |
Subject: |
Re: undo boundaries |
Date: |
Sun, 16 Mar 2008 14:38:19 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
> (defun test ()
> (interactive)
> (insert "a")
> (undo-boundary)
> (insert "b"))
>
> If I do M-x test, I get:
> ab
> ^
>
> Then, if I undo once in Emacs 22, I get:
> a
> ^
>
> What I was expecting (and what happens in Emacs 21):
> a
> ^
>
>
> Also note:
>
> bojohan+news@dd.chalmers.se (Johan Bockgård) wrote:
>
>
>>The likely suspect is this change:
>>
>>undo.c
>>revision 1.55
>>date: 2002-04-04 22:42:56 +0200; author: monnier;
>>(record_point): New fun.
>>(record_delete, record_insert): Use it.
Your example is a bit contrived. If you do
a M-: (undo-boundary) RET b
subsequent undoing behaves as expected. Hence, the culprit is probably
`execute-extended-command'.
FWIW, your problem is caused by the (insert "b"). Due to the preceding
(undo-boundary) record_point called by record_insert sets at_boundary to
1, the test last_point_position != pt succeeds, and last_point_position
(the position of `point' before `test' is executed) gets recorded in
undo_list. However, that position (in your example the position before
the "a") is inherently wrong here since it gets recorded _after_ the
insertion of "a". Maybe someone wants to debug this to verify my claim.
We could try to convince record_insert and record_delete to set another
variable, say last_point_position_is_valid, to nil, set that variable to
t at the time last_point_position is recorded in the command loop, and
inhibit point recording when last_point_position_is_valid is nil.
BTW, with Emacs 23 you can use
(defun test ()
(interactive)
(let ((undo-inhibit-record-point t))
(insert "a")
(undo-boundary)
(insert "b")))
- undo boundaries, Nikolaj Schumacher, 2008/03/15
- Re: undo boundaries,
martin rudalics <=