diff options
| author | Richard M. Stallman | 1998-01-02 21:29:48 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-02 21:29:48 +0000 |
| commit | 80f6e77c7037b05f63482242ba482da01ab51314 (patch) | |
| tree | 0130878f03b347cc8d772d4d755135219c8db037 /src | |
| parent | 6ced1284f381c5f77b77db086ea62ede046718a0 (diff) | |
| download | emacs-80f6e77c7037b05f63482242ba482da01ab51314.tar.gz emacs-80f6e77c7037b05f63482242ba482da01ab51314.zip | |
(adjust_markers_gap_motion): Now a no-op.
(adjust_markers_for_delete): Update ->bytepos instead of ->bufpos,
but don't adjust for the gap.
(adjust_markers_for_insert): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/insdel.c b/src/insdel.c index 1d69d541001..ae05a5ffe87 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -283,6 +283,9 @@ static void | |||
| 283 | adjust_markers_gap_motion (from, to, amount) | 283 | adjust_markers_gap_motion (from, to, amount) |
| 284 | register int from, to, amount; | 284 | register int from, to, amount; |
| 285 | { | 285 | { |
| 286 | /* Now that a marker has a bytepos, not counting the gap, | ||
| 287 | nothing needs to be done here. */ | ||
| 288 | #if 0 | ||
| 286 | Lisp_Object marker; | 289 | Lisp_Object marker; |
| 287 | register struct Lisp_Marker *m; | 290 | register struct Lisp_Marker *m; |
| 288 | register int mpos; | 291 | register int mpos; |
| @@ -292,7 +295,7 @@ adjust_markers_gap_motion (from, to, amount) | |||
| 292 | while (!NILP (marker)) | 295 | while (!NILP (marker)) |
| 293 | { | 296 | { |
| 294 | m = XMARKER (marker); | 297 | m = XMARKER (marker); |
| 295 | mpos = m->bufpos; | 298 | mpos = m->bytepos; |
| 296 | if (amount > 0) | 299 | if (amount > 0) |
| 297 | { | 300 | { |
| 298 | if (mpos > to && mpos < to + amount) | 301 | if (mpos > to && mpos < to + amount) |
| @@ -319,6 +322,7 @@ adjust_markers_gap_motion (from, to, amount) | |||
| 319 | m->bufpos = mpos; | 322 | m->bufpos = mpos; |
| 320 | marker = m->chain; | 323 | marker = m->chain; |
| 321 | } | 324 | } |
| 325 | #endif | ||
| 322 | } | 326 | } |
| 323 | 327 | ||
| 324 | /* Adjust all markers for a deletion | 328 | /* Adjust all markers for a deletion |
| @@ -349,32 +353,34 @@ adjust_markers_for_delete (from, from_byte, to, to_byte) | |||
| 349 | abort (); | 353 | abort (); |
| 350 | 354 | ||
| 351 | /* If the marker is after the deletion, | 355 | /* If the marker is after the deletion, |
| 352 | its bufpos needs no change because the deleted text | 356 | relocate by number of chars / bytes deleted. */ |
| 353 | becomes gap; but its charpos needs to be decreased. */ | ||
| 354 | if (charpos > to) | 357 | if (charpos > to) |
| 355 | m->charpos -= to - from; | 358 | { |
| 359 | m->charpos -= to - from; | ||
| 360 | m->bytepos -= to_byte - from_byte; | ||
| 361 | } | ||
| 356 | 362 | ||
| 357 | /* Here's the case where a marker is inside text being deleted. | 363 | /* Here's the case where a marker is inside text being deleted. */ |
| 358 | We take advantage of the fact that the deletion is at the gap. */ | ||
| 359 | else if (charpos > from) | 364 | else if (charpos > from) |
| 360 | { | 365 | { |
| 361 | record_marker_adjustment (marker, from - charpos); | 366 | record_marker_adjustment (marker, from - charpos); |
| 362 | m->charpos = from; | 367 | m->charpos = from; |
| 363 | /* The gap must be at or after FROM_BYTE when we do a deletion. */ | 368 | m->bytepos = from_byte; |
| 364 | m->bufpos = from_byte; | ||
| 365 | } | 369 | } |
| 366 | 370 | ||
| 367 | /* In a single-byte buffer, a marker's two positions must be equal. */ | 371 | /* In a single-byte buffer, a marker's two positions must be equal. */ |
| 368 | if (Z == Z_BYTE) | 372 | if (Z == Z_BYTE) |
| 369 | { | 373 | { |
| 370 | register int i = m->bufpos; | 374 | register int i = m->bytepos; |
| 371 | 375 | ||
| 376 | #if 0 | ||
| 372 | /* We use FROM_BYTE here instead of GPT_BYTE | 377 | /* We use FROM_BYTE here instead of GPT_BYTE |
| 373 | because FROM_BYTE is where the gap will be after the deletion. */ | 378 | because FROM_BYTE is where the gap will be after the deletion. */ |
| 374 | if (i > from_byte + coming_gap_size) | 379 | if (i > from_byte + coming_gap_size) |
| 375 | i -= coming_gap_size; | 380 | i -= coming_gap_size; |
| 376 | else if (i > from_byte) | 381 | else if (i > from_byte) |
| 377 | i = from_byte; | 382 | i = from_byte; |
| 383 | #endif | ||
| 378 | 384 | ||
| 379 | if (m->charpos != i) | 385 | if (m->charpos != i) |
| 380 | abort (); | 386 | abort (); |
| @@ -388,7 +394,7 @@ adjust_markers_for_delete (from, from_byte, to, to_byte) | |||
| 388 | consisting of NCHARS chars, which are NBYTES bytes. | 394 | consisting of NCHARS chars, which are NBYTES bytes. |
| 389 | 395 | ||
| 390 | We have to relocate the charpos of every marker that points | 396 | We have to relocate the charpos of every marker that points |
| 391 | after the insertion (but not their bufpos). | 397 | after the insertion (but not their bytepos). |
| 392 | 398 | ||
| 393 | When a marker points at the insertion point, | 399 | When a marker points at the insertion point, |
| 394 | we advance it if either its insertion-type is t | 400 | we advance it if either its insertion-type is t |
| @@ -408,26 +414,31 @@ adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers) | |||
| 408 | while (!NILP (marker)) | 414 | while (!NILP (marker)) |
| 409 | { | 415 | { |
| 410 | register struct Lisp_Marker *m = XMARKER (marker); | 416 | register struct Lisp_Marker *m = XMARKER (marker); |
| 411 | if (m->bufpos == from_byte | 417 | if (m->bytepos == from_byte |
| 412 | && (m->insertion_type || before_markers)) | 418 | && (m->insertion_type || before_markers)) |
| 413 | { | 419 | { |
| 414 | m->bufpos += nbytes; | 420 | m->bytepos += nbytes; |
| 415 | m->charpos += nchars; | 421 | m->charpos += nchars; |
| 416 | if (m->insertion_type) | 422 | if (m->insertion_type) |
| 417 | adjusted = 1; | 423 | adjusted = 1; |
| 418 | } | 424 | } |
| 419 | else if (m->bufpos > from_byte) | 425 | else if (m->bytepos > from_byte) |
| 420 | m->charpos += nchars; | 426 | { |
| 427 | m->bytepos += nbytes; | ||
| 428 | m->charpos += nchars; | ||
| 429 | } | ||
| 421 | 430 | ||
| 422 | /* In a single-byte buffer, a marker's two positions must be equal. */ | 431 | /* In a single-byte buffer, a marker's two positions must be equal. */ |
| 423 | if (Z == Z_BYTE) | 432 | if (Z == Z_BYTE) |
| 424 | { | 433 | { |
| 425 | register int i = m->bufpos; | 434 | register int i = m->bytepos; |
| 426 | 435 | ||
| 436 | #if 0 | ||
| 427 | if (i > GPT_BYTE + GAP_SIZE) | 437 | if (i > GPT_BYTE + GAP_SIZE) |
| 428 | i -= GAP_SIZE; | 438 | i -= GAP_SIZE; |
| 429 | else if (i > GPT_BYTE) | 439 | else if (i > GPT_BYTE) |
| 430 | i = GPT_BYTE; | 440 | i = GPT_BYTE; |
| 441 | #endif | ||
| 431 | 442 | ||
| 432 | if (m->charpos != i) | 443 | if (m->charpos != i) |
| 433 | abort (); | 444 | abort (); |