(adjust_markers_for_delete): Update ->bytepos instead of ->bufpos,
but don't adjust for the gap.
(adjust_markers_for_insert): Likewise.
adjust_markers_gap_motion (from, to, amount)
register int from, to, amount;
{
adjust_markers_gap_motion (from, to, amount)
register int from, to, amount;
{
+ /* Now that a marker has a bytepos, not counting the gap,
+ nothing needs to be done here. */
+#if 0
Lisp_Object marker;
register struct Lisp_Marker *m;
register int mpos;
Lisp_Object marker;
register struct Lisp_Marker *m;
register int mpos;
while (!NILP (marker))
{
m = XMARKER (marker);
while (!NILP (marker))
{
m = XMARKER (marker);
if (amount > 0)
{
if (mpos > to && mpos < to + amount)
if (amount > 0)
{
if (mpos > to && mpos < to + amount)
m->bufpos = mpos;
marker = m->chain;
}
m->bufpos = mpos;
marker = m->chain;
}
}
/* Adjust all markers for a deletion
}
/* Adjust all markers for a deletion
abort ();
/* If the marker is after the deletion,
abort ();
/* If the marker is after the deletion,
- its bufpos needs no change because the deleted text
- becomes gap; but its charpos needs to be decreased. */
+ relocate by number of chars / bytes deleted. */
- m->charpos -= to - from;
+ {
+ m->charpos -= to - from;
+ m->bytepos -= to_byte - from_byte;
+ }
- /* Here's the case where a marker is inside text being deleted.
- We take advantage of the fact that the deletion is at the gap. */
+ /* Here's the case where a marker is inside text being deleted. */
else if (charpos > from)
{
record_marker_adjustment (marker, from - charpos);
m->charpos = from;
else if (charpos > from)
{
record_marker_adjustment (marker, from - charpos);
m->charpos = from;
- /* The gap must be at or after FROM_BYTE when we do a deletion. */
- m->bufpos = from_byte;
+ m->bytepos = from_byte;
}
/* In a single-byte buffer, a marker's two positions must be equal. */
if (Z == Z_BYTE)
{
}
/* In a single-byte buffer, a marker's two positions must be equal. */
if (Z == Z_BYTE)
{
- register int i = m->bufpos;
+ register int i = m->bytepos;
/* We use FROM_BYTE here instead of GPT_BYTE
because FROM_BYTE is where the gap will be after the deletion. */
if (i > from_byte + coming_gap_size)
i -= coming_gap_size;
else if (i > from_byte)
i = from_byte;
/* We use FROM_BYTE here instead of GPT_BYTE
because FROM_BYTE is where the gap will be after the deletion. */
if (i > from_byte + coming_gap_size)
i -= coming_gap_size;
else if (i > from_byte)
i = from_byte;
if (m->charpos != i)
abort ();
if (m->charpos != i)
abort ();
consisting of NCHARS chars, which are NBYTES bytes.
We have to relocate the charpos of every marker that points
consisting of NCHARS chars, which are NBYTES bytes.
We have to relocate the charpos of every marker that points
- after the insertion (but not their bufpos).
+ after the insertion (but not their bytepos).
When a marker points at the insertion point,
we advance it if either its insertion-type is t
When a marker points at the insertion point,
we advance it if either its insertion-type is t
while (!NILP (marker))
{
register struct Lisp_Marker *m = XMARKER (marker);
while (!NILP (marker))
{
register struct Lisp_Marker *m = XMARKER (marker);
- if (m->bufpos == from_byte
+ if (m->bytepos == from_byte
&& (m->insertion_type || before_markers))
{
&& (m->insertion_type || before_markers))
{
m->charpos += nchars;
if (m->insertion_type)
adjusted = 1;
}
m->charpos += nchars;
if (m->insertion_type)
adjusted = 1;
}
- else if (m->bufpos > from_byte)
- m->charpos += nchars;
+ else if (m->bytepos > from_byte)
+ {
+ m->bytepos += nbytes;
+ m->charpos += nchars;
+ }
/* In a single-byte buffer, a marker's two positions must be equal. */
if (Z == Z_BYTE)
{
/* In a single-byte buffer, a marker's two positions must be equal. */
if (Z == Z_BYTE)
{
- register int i = m->bufpos;
+ register int i = m->bytepos;
if (i > GPT_BYTE + GAP_SIZE)
i -= GAP_SIZE;
else if (i > GPT_BYTE)
i = GPT_BYTE;
if (i > GPT_BYTE + GAP_SIZE)
i -= GAP_SIZE;
else if (i > GPT_BYTE)
i = GPT_BYTE;
if (m->charpos != i)
abort ();
if (m->charpos != i)
abort ();