[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about markers, replace-match, and undo
From: |
Richard Stallman |
Subject: |
Re: question about markers, replace-match, and undo |
Date: |
Sat, 28 Apr 2007 00:07:18 -0400 |
I have some text, with a marker before it and a marker after it. For
instance, the first marker is at position 41, just before `m', and the
second is at position 48, just after `s':
41 48
mnopqrs
I match this text, and then call (replace-match "ABC"), with the result that
the first marker is still at position 41 and the second marker is now at
position 44, just after `C', which is what I would expect and what I want:
41 44
ABC
I use `undo', and the result is that both markers are now at position 41:
41
41
mnopqrs
That is definitely a bug. Does this fix it?
*** insdel.c 02 Mar 2007 03:28:13 -0500 1.190
--- insdel.c 27 Apr 2007 23:55:23 -0400
***************
*** 1603,1610 ****
if (! EQ (current_buffer->undo_list, Qt))
{
record_delete (from, deletion);
- record_insert (from, inschars);
}
GAP_SIZE -= outgoing_insbytes;
--- 1603,1614 ----
if (! EQ (current_buffer->undo_list, Qt))
{
+ /* Record the insertion first, so that when we undo,
+ the deletion will be undone first. Thus, undo
+ will insert before deleting, and thus will keep
+ the markers before and after this text separate. */
+ record_insert (from + SCHARS (deletion), inschars);
record_delete (from, deletion);
}
GAP_SIZE -= outgoing_insbytes;
- question about markers, replace-match, and undo, Drew Adams, 2007/04/27
- Re: question about markers, replace-match, and undo, Johan Bockgård, 2007/04/27
- Re: question about markers, replace-match, and undo,
Richard Stallman <=
- RE: question about markers, replace-match, and undo, Drew Adams, 2007/04/28
- Re: question about markers, replace-match, and undo, Richard Stallman, 2007/04/29
- Re: question about markers, replace-match, and undo, Johan Bockgård, 2007/04/29
- RE: question about markers, replace-match, and undo, Drew Adams, 2007/04/29
- Re: question about markers, replace-match, and undo, Richard Stallman, 2007/04/30