marker = m->chain;
}
}
+
+/* Adjust all markers for a byte combining of NBYTES at char position
+ FROM and byte position FROM_BYTE. */
+
+static void
+adjust_markers_for_combining (from, from_byte, nbytes)
+ register int from, from_byte, nbytes;
+{
+ Lisp_Object marker;
+ register struct Lisp_Marker *m;
+ register int bytepos;
+ register int to_byte = from_byte + nbytes;
+
+ marker = BUF_MARKERS (current_buffer);
+
+ while (!NILP (marker))
+ {
+ m = XMARKER (marker);
+ bytepos = m->bytepos;
+
+ if (bytepos >= to_byte)
+ {
+ record_marker_adjustment (marker, - nbytes);
+ m->charpos -= nbytes;
+ }
+ else if (bytepos > from_byte)
+ {
+ record_marker_adjustment (marker, from - m->charpos);
+ m->charpos = from;
+ m->bytepos = to_byte;
+ }
+ else if (bytepos == from_byte)
+ {
+ m->bytepos = to_byte;
+ }
+
+ marker = m->chain;
+ }
+}
\f
/* Adjust all markers for calling record_delete for combining bytes.
whose range in bytes is FROM_BYTE to TO_BYTE.
m->charpos = from;
m->bytepos = from_byte;
}
- else if (m->bytepos == from_byte)
- {
- if (combined_before_bytes)
- {
- DEC_BOTH (m->charpos, m->bytepos);
- INC_BOTH (m->charpos, m->bytepos);
- }
- }
marker = m->chain;
}
int pos, pos_byte, nbytes;
{
/* Adjust all markers. */
- adjust_markers_for_delete (pos, pos_byte, pos + nbytes, pos_byte);
+ adjust_markers_for_combining (pos, pos_byte, nbytes);
adjust_overlays_for_delete (pos, nbytes);
from_byte + combined_after_bytes);
if (! EQ (current_buffer->undo_list, Qt))
- record_delete (from, deletion);
+ record_delete (from + len, deletion);
}
if (combined_before_bytes)
int adjusted_inschars;
INTERVAL intervals;
int outgoing_insbytes = insbytes;
+ Lisp_Object deletion;
CHECK_MARKERS ();
if (to < GPT)
gap_left (to, to_byte, 0);
- {
- Lisp_Object deletion;
- deletion = Qnil;
-
- if (! EQ (current_buffer->undo_list, Qt))
- deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1);
+ deletion = Qnil;
- if (markers)
- /* Relocate all markers pointing into the new, larger gap
- to point at the end of the text before the gap.
- Do this before recording the deletion,
- so that undo handles this after reinserting the text. */
- adjust_markers_for_delete (from, from_byte, to, to_byte);
+ if (! EQ (current_buffer->undo_list, Qt))
+ deletion = make_buffer_string_both (from, from_byte, to, to_byte, 1);
- if (! EQ (current_buffer->undo_list, Qt))
- record_delete (from, deletion);
- }
+ if (markers)
+ /* Relocate all markers pointing into the new, larger gap
+ to point at the end of the text before the gap.
+ Do this before recording the deletion,
+ so that undo handles this after reinserting the text. */
+ adjust_markers_for_delete (from, from_byte, to, to_byte);
GAP_SIZE += nbytes_del;
ZV -= nchars_del;
from + combined_after_bytes,
from_byte + combined_after_bytes);
if (! EQ (current_buffer->undo_list, Qt))
- record_delete (from, deletion);
+ record_delete (from + inschars, deletion);
}
if (combined_before_bytes)
record_delete (from - 1, deletion);
}
- record_insert (from - !!combined_before_bytes,
- inschars - combined_before_bytes + !!combined_before_bytes);
+ if (! EQ (current_buffer->undo_list, Qt))
+ {
+ record_delete (from - !!combined_before_bytes, deletion);
+ record_insert (from - !!combined_before_bytes,
+ (inschars - combined_before_bytes
+ + !!combined_before_bytes));
+ }
GAP_SIZE -= outgoing_insbytes;
GPT += inschars;