* undo boundaries
@ 2008-03-15 17:16 Nikolaj Schumacher
2008-03-16 13:38 ` martin rudalics
0 siblings, 1 reply; 2+ messages in thread
From: Nikolaj Schumacher @ 2008-03-15 17:16 UTC (permalink / raw)
To: bug-gnu-emacs
Hello,
according I brief discussion on help-gnu-emacs, this appears to be a bug in
Emacs 22:
(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.
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: undo boundaries
2008-03-15 17:16 undo boundaries Nikolaj Schumacher
@ 2008-03-16 13:38 ` martin rudalics
0 siblings, 0 replies; 2+ messages in thread
From: martin rudalics @ 2008-03-16 13:38 UTC (permalink / raw)
To: Nikolaj Schumacher; +Cc: bug-gnu-emacs
> (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")))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-16 13:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-15 17:16 undo boundaries Nikolaj Schumacher
2008-03-16 13:38 ` martin rudalics
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).