summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2000-05-22 00:19:43 +0000
committerKenichi Handa <handa@m17n.org>2000-05-22 00:19:43 +0000
commitadee4f912ad6593dc92dd04ea1f8e0f9ef315ccb (patch)
tree13918205ac63a6922d269dead3d109b0e36d627f
parentd7e00792f2da10db36cfed619a19c8715bc74063 (diff)
downloademacs-adee4f912ad6593dc92dd04ea1f8e0f9ef315ccb.tar.gz
(adjust_markers_for_replace): Fix previous change.
(adjust_after_replace): If PREV_TEXT is nil, call adjust_markers_for_insert, not adjust_markers_for_replace.
-rw-r--r--src/insdel.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/insdel.c b/src/insdel.c
index a2756e4e2ed..101e74207c4 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -462,7 +462,8 @@ adjust_point (nchars, nbytes)
/* Adjust markers for a replacement of a text at FROM (FROM_BYTE) of
length OLD_CHARS (OLD_BYTES) to a new text of length NEW_CHARS
- (NEW_BYTES). */
+ (NEW_BYTES). It is assumed that OLD_CHARS > 0, i.e., this is not
+ an insertion. */
static void
adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
@@ -478,17 +479,12 @@ adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
{
register struct Lisp_Marker *m = XMARKER (marker);
- if (m->bytepos >= prev_to_byte
- && (old_bytes != 0
- /* If this is an insertion (replacing 0 chars),
- reject the case of a marker that is at the
- insertion point and should stay before the insertion. */
- || m->bytepos > from_byte || m->insertion_type))
+ if (m->bytepos >= prev_to_byte)
{
- m->charpos = min (from + new_chars, m->charpos + diff_chars);
- m->bytepos = min (from_byte + new_bytes, m->bytepos + diff_bytes);
+ m->charpos += diff_chars;
+ m->bytepos += diff_bytes;
}
- else if (m->bytepos >= from_byte)
+ else if (m->bytepos > from_byte)
{
m->charpos = from;
m->bytepos = from_byte;
@@ -1277,8 +1273,12 @@ adjust_after_replace (from, from_byte, prev_text, len, len_byte)
GPT += len; GPT_BYTE += len_byte;
if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
- adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
- len, len_byte);
+ if (nchars_del > 0)
+ adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del,
+ len, len_byte);
+ else
+ adjust_markers_for_insert (from, from_byte,
+ from + len, from_byte + len_byte, 0);
if (! EQ (current_buffer->undo_list, Qt))
{