From: Richard M. Stallman Date: Sat, 3 Feb 1996 18:06:29 +0000 (+0000) Subject: (adjust_markers): When a marker is inside text X-Git-Tag: emacs-19.34~1381 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8948d3170a7d786664da33c009da0c7194b345c3;p=emacs.git (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. --- 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) QUIT; } -/* Add `amount' to the position of every marker in the current buffer - whose current position is between `from' (exclusive) and `to' (inclusive). +/* Add AMOUNT to the position of every marker in the current buffer + whose current position is between FROM (exclusive) and TO (inclusive). + Also, any markers past the outside of that interval, in the direction of adjustment, are first moved back to the near end of the interval - and then adjusted by `amount'. */ + and then adjusted by AMOUNT. + + When the latter adjustment is done, if AMOUNT is negative, + we record the adjustment for undo. (This case happens only for + deletion.) */ static void adjust_markers (from, to, amount) @@ -237,8 +242,14 @@ adjust_markers (from, to, amount) } else { + /* Here's the case where a marker is inside text being deleted. + AMOUNT can be negative for gap motion, too, + but then this range contains no markers. */ if (mpos > from + amount && mpos <= from) - mpos = from + amount; + { + record_marker_adjustment (marker, from + amount - mpos); + mpos = from + amount; + } } if (mpos > from && mpos <= to) mpos += amount; @@ -655,6 +666,12 @@ del_range_1 (from, to, prepare) if (prepare) prepare_to_modify_buffer (from, to); + /* Relocate all markers pointing into the new, larger gap + to point at the end of the text before the gap. + This has to be done before recording the deletion, + so undo handles this after reinserting the text. */ + adjust_markers (to + GAP_SIZE, to + GAP_SIZE, - numdel - GAP_SIZE); + record_delete (from, numdel); MODIFF++; @@ -665,10 +682,6 @@ del_range_1 (from, to, prepare) /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ offset_intervals (current_buffer, from, - numdel); - /* Relocate all markers pointing into the new, larger gap - to point at the end of the text before the gap. */ - adjust_markers (to + GAP_SIZE, to + GAP_SIZE, - numdel - GAP_SIZE); - /* Adjust the overlay center as needed. This must be done after adjusting the markers that bound the overlays. */ adjust_overlays_for_delete (from, numdel);