aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1996-02-03 18:06:29 +0000
committerRichard M. Stallman1996-02-03 18:06:29 +0000
commit8948d3170a7d786664da33c009da0c7194b345c3 (patch)
treec938058efe9ea5a7bb424ca83032968cf99b8dbf /src
parent45f83af208e6181d2bede9fca1ca3af9eb39991d (diff)
downloademacs-8948d3170a7d786664da33c009da0c7194b345c3.tar.gz
emacs-8948d3170a7d786664da33c009da0c7194b345c3.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/insdel.c b/src/insdel.c
index a22fb10fb54..1058de734de 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -210,11 +210,16 @@ gap_right (pos)
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
219static void 224static void
220adjust_markers (from, to, amount) 225adjust_markers (from, to, amount)
@@ -237,8 +242,14 @@ adjust_markers (from, 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;
@@ -655,6 +666,12 @@ del_range_1 (from, to, prepare)
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
@@ -665,10 +682,6 @@ del_range_1 (from, to, prepare)
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 684
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
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);