Mercurial > emacs
comparison src/insdel.c @ 14479:69fa625812a4
(adjust_markers): When a marker is inside text
being deleted, call record_marker_adjustment for it.
(del_range_1): Call adjust_markers before record_delete.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 03 Feb 1996 18:06:29 +0000 |
parents | ee40177f6c68 |
children | d6106d651a71 |
comparison
equal
deleted
inserted
replaced
14478:cb600acfe4f6 | 14479:69fa625812a4 |
---|---|
208 adjust_markers (GPT + GAP_SIZE, pos + 1 + GAP_SIZE, - GAP_SIZE); | 208 adjust_markers (GPT + GAP_SIZE, pos + 1 + GAP_SIZE, - GAP_SIZE); |
209 GPT = pos + 1; | 209 GPT = pos + 1; |
210 QUIT; | 210 QUIT; |
211 } | 211 } |
212 | 212 |
213 /* Add `amount' to the position of every marker in the current buffer | 213 /* Add AMOUNT to the position of every marker in the current buffer |
214 whose current position is between `from' (exclusive) and `to' (inclusive). | 214 whose current position is between FROM (exclusive) and TO (inclusive). |
215 | |
215 Also, any markers past the outside of that interval, in the direction | 216 Also, any markers past the outside of that interval, in the direction |
216 of adjustment, are first moved back to the near end of the interval | 217 of adjustment, are first moved back to the near end of the interval |
217 and then adjusted by `amount'. */ | 218 and then adjusted by AMOUNT. |
219 | |
220 When the latter adjustment is done, if AMOUNT is negative, | |
221 we record the adjustment for undo. (This case happens only for | |
222 deletion.) */ | |
218 | 223 |
219 static void | 224 static void |
220 adjust_markers (from, to, amount) | 225 adjust_markers (from, to, amount) |
221 register int from, to, amount; | 226 register int from, to, amount; |
222 { | 227 { |
235 if (mpos > to && mpos < to + amount) | 240 if (mpos > to && mpos < to + amount) |
236 mpos = to + amount; | 241 mpos = to + amount; |
237 } | 242 } |
238 else | 243 else |
239 { | 244 { |
245 /* Here's the case where a marker is inside text being deleted. | |
246 AMOUNT can be negative for gap motion, too, | |
247 but then this range contains no markers. */ | |
240 if (mpos > from + amount && mpos <= from) | 248 if (mpos > from + amount && mpos <= from) |
241 mpos = from + amount; | 249 { |
250 record_marker_adjustment (marker, from + amount - mpos); | |
251 mpos = from + amount; | |
252 } | |
242 } | 253 } |
243 if (mpos > from && mpos <= to) | 254 if (mpos > from && mpos <= to) |
244 mpos += amount; | 255 mpos += amount; |
245 m->bufpos = mpos; | 256 m->bufpos = mpos; |
246 marker = m->chain; | 257 marker = m->chain; |
653 gap_left (to, 0); | 664 gap_left (to, 0); |
654 | 665 |
655 if (prepare) | 666 if (prepare) |
656 prepare_to_modify_buffer (from, to); | 667 prepare_to_modify_buffer (from, to); |
657 | 668 |
669 /* Relocate all markers pointing into the new, larger gap | |
670 to point at the end of the text before the gap. | |
671 This has to be done before recording the deletion, | |
672 so undo handles this after reinserting the text. */ | |
673 adjust_markers (to + GAP_SIZE, to + GAP_SIZE, - numdel - GAP_SIZE); | |
674 | |
658 record_delete (from, numdel); | 675 record_delete (from, numdel); |
659 MODIFF++; | 676 MODIFF++; |
660 | 677 |
661 /* Relocate point as if it were a marker. */ | 678 /* Relocate point as if it were a marker. */ |
662 if (from < PT) | 679 if (from < PT) |
663 adjust_point (from - (PT < to ? PT : to)); | 680 adjust_point (from - (PT < to ? PT : to)); |
664 | 681 |
665 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ | 682 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ |
666 offset_intervals (current_buffer, from, - numdel); | 683 offset_intervals (current_buffer, from, - numdel); |
667 | |
668 /* Relocate all markers pointing into the new, larger gap | |
669 to point at the end of the text before the gap. */ | |
670 adjust_markers (to + GAP_SIZE, to + GAP_SIZE, - numdel - GAP_SIZE); | |
671 | 684 |
672 /* Adjust the overlay center as needed. This must be done after | 685 /* Adjust the overlay center as needed. This must be done after |
673 adjusting the markers that bound the overlays. */ | 686 adjusting the markers that bound the overlays. */ |
674 adjust_overlays_for_delete (from, numdel); | 687 adjust_overlays_for_delete (from, numdel); |
675 | 688 |