all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* undo boundaries
@ 2008-03-15 11:39 Nikolaj Schumacher
  0 siblings, 0 replies; 5+ messages in thread
From: Nikolaj Schumacher @ 2008-03-15 11:39 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I'm trying to use undo boundaries, but I'm unable to explain its
behavior.

For example:

(defun test ()
  (interactive)
  (insert "a")
  (undo-boundary)
  (insert "b"))

If I do M-x test, I get:
ab
  ^

But if I undo once, I get:
a
^

What I was expecting:
a
 ^

Is this a bug or is there a reason for this behavior?


regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: undo boundaries
       [not found] <mailman.8949.1205581280.18990.help-gnu-emacs@gnu.org>
@ 2008-03-15 12:25 ` Johan Bockgård
  2008-03-15 13:19   ` Johan Bockgård
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Bockgård @ 2008-03-15 12:25 UTC (permalink / raw)
  To: help-gnu-emacs

Nikolaj Schumacher <n_schumacher@web.de> writes:

> I'm trying to use undo boundaries, but I'm unable to explain its
> behavior.
>
> For example:
>
> (defun test ()
>   (interactive)
>   (insert "a")
>   (undo-boundary)
>   (insert "b"))
>
> If I do M-x test, I get:
> ab
>   ^
>
> But if I undo once, I get:
> a
> ^
>
> What I was expecting:
> a
>  ^
>
> Is this a bug or is there a reason for this behavior?

A bug, IMO.  Emacs 21 does what you expect.

-- 
Johan Bockgård


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: undo boundaries
  2008-03-15 12:25 ` undo boundaries Johan Bockgård
@ 2008-03-15 13:19   ` Johan Bockgård
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Bockgård @ 2008-03-15 13:19 UTC (permalink / raw)
  To: emacs-devel; +Cc: help-gnu-emacs


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.


bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

> Nikolaj Schumacher <n_schumacher@web.de> writes:
>
>> I'm trying to use undo boundaries, but I'm unable to explain its
>> behavior.
>>
>> For example:
>>
>> (defun test ()
>>   (interactive)
>>   (insert "a")
>>   (undo-boundary)
>>   (insert "b"))
>>
>> If I do M-x test, I get:
>> ab
>>   ^
>>
>> But if I undo once, I get:
>> a
>> ^
>>
>> What I was expecting:
>> a
>>  ^
>>
>> Is this a bug or is there a reason for this behavior?
>
> A bug, IMO.  Emacs 21 does what you expect.

-- 
Johan Bockgård





^ permalink raw reply	[flat|nested] 5+ messages in thread

* undo boundaries
@ 2008-03-15 17:16 Nikolaj Schumacher
  2008-03-16 13:38 ` martin rudalics
  0 siblings, 1 reply; 5+ 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] 5+ messages in thread

* Re: undo boundaries
  2008-03-15 17:16 Nikolaj Schumacher
@ 2008-03-16 13:38 ` martin rudalics
  0 siblings, 0 replies; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2008-03-16 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.8949.1205581280.18990.help-gnu-emacs@gnu.org>
2008-03-15 12:25 ` undo boundaries Johan Bockgård
2008-03-15 13:19   ` Johan Bockgård
2008-03-15 17:16 Nikolaj Schumacher
2008-03-16 13:38 ` martin rudalics
  -- strict thread matches above, loose matches on Subject: below --
2008-03-15 11:39 Nikolaj Schumacher

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.