diff options
| author | Richard M. Stallman | 1996-02-03 18:07:27 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-02-03 18:07:27 +0000 |
| commit | 714bced97609934cef99d8fa674a0a5cab20d9e3 (patch) | |
| tree | 4eb2c685945d694393b65d3fe4028d6a0291aadc /src | |
| parent | 8948d3170a7d786664da33c009da0c7194b345c3 (diff) | |
| download | emacs-714bced97609934cef99d8fa674a0a5cab20d9e3.tar.gz emacs-714bced97609934cef99d8fa674a0a5cab20d9e3.zip | |
(record_marker_adjustment): New function.
(Fprimitive_undo): Handle marker-adjustment elements.
Diffstat (limited to 'src')
| -rw-r--r-- | src/undo.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/undo.c b/src/undo.c index 0e6116500a4..d2cc1d2dcd4 100644 --- a/src/undo.c +++ b/src/undo.c | |||
| @@ -128,6 +128,31 @@ record_delete (beg, length) | |||
| 128 | current_buffer->undo_list); | 128 | current_buffer->undo_list); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | /* Record the fact that MARKER is about to be adjusted by ADJUSTMENT. | ||
| 132 | This is done only when a marker points within text being deleted, | ||
| 133 | because that's the only case where an automatic marker adjustment | ||
| 134 | won't be inverted automatically by undoing the buffer modification. */ | ||
| 135 | |||
| 136 | record_marker_adjustment (marker, adjustment) | ||
| 137 | Lisp_Object marker; | ||
| 138 | int adjustment; | ||
| 139 | { | ||
| 140 | if (EQ (current_buffer->undo_list, Qt)) | ||
| 141 | return; | ||
| 142 | |||
| 143 | /* Allocate a cons cell to be the undo boundary after this command. */ | ||
| 144 | if (NILP (pending_boundary)) | ||
| 145 | pending_boundary = Fcons (Qnil, Qnil); | ||
| 146 | |||
| 147 | if (current_buffer != XBUFFER (last_undo_buffer)) | ||
| 148 | Fundo_boundary (); | ||
| 149 | XSETBUFFER (last_undo_buffer, current_buffer); | ||
| 150 | |||
| 151 | current_buffer->undo_list | ||
| 152 | = Fcons (Fcons (marker, make_number (adjustment)), | ||
| 153 | current_buffer->undo_list); | ||
| 154 | } | ||
| 155 | |||
| 131 | /* Record that a replacement is about to take place, | 156 | /* Record that a replacement is about to take place, |
| 132 | for LENGTH characters at location BEG. | 157 | for LENGTH characters at location BEG. |
| 133 | The replacement does not change the number of characters. */ | 158 | The replacement does not change the number of characters. */ |
| @@ -463,6 +488,15 @@ Return what remains of the list.") | |||
| 463 | SET_PT (pos); | 488 | SET_PT (pos); |
| 464 | } | 489 | } |
| 465 | } | 490 | } |
| 491 | else if (MARKERP (car) && INTEGERP (cdr)) | ||
| 492 | { | ||
| 493 | /* (MARKER . INTEGER) means a marker MARKER | ||
| 494 | was adjusted by INTEGER. */ | ||
| 495 | if (XMARKER (car)->buffer) | ||
| 496 | Fset_marker (car, | ||
| 497 | make_number (marker_position (car) - XINT (cdr)), | ||
| 498 | Fmarker_buffer (car)); | ||
| 499 | } | ||
| 466 | } | 500 | } |
| 467 | } | 501 | } |
| 468 | arg--; | 502 | arg--; |