diff options
Diffstat (limited to 'src/insdel.c')
| -rw-r--r-- | src/insdel.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/insdel.c b/src/insdel.c index 52a017a62a2..905249d6714 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -388,14 +388,13 @@ make_gap_larger (ptrdiff_t nbytes_added) | |||
| 388 | ptrdiff_t real_gap_loc_byte; | 388 | ptrdiff_t real_gap_loc_byte; |
| 389 | ptrdiff_t old_gap_size; | 389 | ptrdiff_t old_gap_size; |
| 390 | ptrdiff_t current_size = Z_BYTE - BEG_BYTE + GAP_SIZE; | 390 | ptrdiff_t current_size = Z_BYTE - BEG_BYTE + GAP_SIZE; |
| 391 | enum { enough_for_a_while = 2000 }; | ||
| 392 | 391 | ||
| 393 | if (BUF_BYTES_MAX - current_size < nbytes_added) | 392 | if (BUF_BYTES_MAX - current_size < nbytes_added) |
| 394 | buffer_overflow (); | 393 | buffer_overflow (); |
| 395 | 394 | ||
| 396 | /* If we have to get more space, get enough to last a while; | 395 | /* If we have to get more space, get enough to last a while; |
| 397 | but do not exceed the maximum buffer size. */ | 396 | but do not exceed the maximum buffer size. */ |
| 398 | nbytes_added = min (nbytes_added + enough_for_a_while, | 397 | nbytes_added = min (nbytes_added + GAP_BYTES_DFL, |
| 399 | BUF_BYTES_MAX - current_size); | 398 | BUF_BYTES_MAX - current_size); |
| 400 | 399 | ||
| 401 | enlarge_buffer_text (current_buffer, nbytes_added); | 400 | enlarge_buffer_text (current_buffer, nbytes_added); |
| @@ -413,8 +412,7 @@ make_gap_larger (ptrdiff_t nbytes_added) | |||
| 413 | GPT_BYTE = Z_BYTE + GAP_SIZE; | 412 | GPT_BYTE = Z_BYTE + GAP_SIZE; |
| 414 | GAP_SIZE = nbytes_added; | 413 | GAP_SIZE = nbytes_added; |
| 415 | 414 | ||
| 416 | /* Move the new gap down to be consecutive with the end of the old one. | 415 | /* Move the new gap down to be consecutive with the end of the old one. */ |
| 417 | This adjusts the markers properly too. */ | ||
| 418 | gap_left (real_gap_loc + old_gap_size, real_gap_loc_byte + old_gap_size, 1); | 416 | gap_left (real_gap_loc + old_gap_size, real_gap_loc_byte + old_gap_size, 1); |
| 419 | 417 | ||
| 420 | /* Now combine the two into one large gap. */ | 418 | /* Now combine the two into one large gap. */ |
| @@ -443,9 +441,9 @@ make_gap_smaller (ptrdiff_t nbytes_removed) | |||
| 443 | ptrdiff_t real_beg_unchanged; | 441 | ptrdiff_t real_beg_unchanged; |
| 444 | ptrdiff_t new_gap_size; | 442 | ptrdiff_t new_gap_size; |
| 445 | 443 | ||
| 446 | /* Make sure the gap is at least 20 bytes. */ | 444 | /* Make sure the gap is at least GAP_BYTES_MIN bytes. */ |
| 447 | if (GAP_SIZE - nbytes_removed < 20) | 445 | if (GAP_SIZE - nbytes_removed < GAP_BYTES_MIN) |
| 448 | nbytes_removed = GAP_SIZE - 20; | 446 | nbytes_removed = GAP_SIZE - GAP_BYTES_MIN; |
| 449 | 447 | ||
| 450 | /* Prevent quitting in move_gap. */ | 448 | /* Prevent quitting in move_gap. */ |
| 451 | tem = Vinhibit_quit; | 449 | tem = Vinhibit_quit; |
| @@ -468,8 +466,7 @@ make_gap_smaller (ptrdiff_t nbytes_removed) | |||
| 468 | Z_BYTE += new_gap_size; | 466 | Z_BYTE += new_gap_size; |
| 469 | GAP_SIZE = nbytes_removed; | 467 | GAP_SIZE = nbytes_removed; |
| 470 | 468 | ||
| 471 | /* Move the unwanted pretend gap to the end of the buffer. This | 469 | /* Move the unwanted pretend gap to the end of the buffer. */ |
| 472 | adjusts the markers properly too. */ | ||
| 473 | gap_right (Z, Z_BYTE); | 470 | gap_right (Z, Z_BYTE); |
| 474 | 471 | ||
| 475 | enlarge_buffer_text (current_buffer, -nbytes_removed); | 472 | enlarge_buffer_text (current_buffer, -nbytes_removed); |
| @@ -500,7 +497,20 @@ make_gap (ptrdiff_t nbytes_added) | |||
| 500 | make_gap_smaller (-nbytes_added); | 497 | make_gap_smaller (-nbytes_added); |
| 501 | #endif | 498 | #endif |
| 502 | } | 499 | } |
| 503 | 500 | ||
| 501 | /* Add NBYTES to B's gap. It's enough to temporarily | ||
| 502 | fake current_buffer and avoid real switch to B. */ | ||
| 503 | |||
| 504 | void | ||
| 505 | make_gap_1 (struct buffer *b, ptrdiff_t nbytes) | ||
| 506 | { | ||
| 507 | struct buffer *oldb = current_buffer; | ||
| 508 | |||
| 509 | current_buffer = b; | ||
| 510 | make_gap (nbytes); | ||
| 511 | current_buffer = oldb; | ||
| 512 | } | ||
| 513 | |||
| 504 | /* Copy NBYTES bytes of text from FROM_ADDR to TO_ADDR. | 514 | /* Copy NBYTES bytes of text from FROM_ADDR to TO_ADDR. |
| 505 | FROM_MULTIBYTE says whether the incoming text is multibyte. | 515 | FROM_MULTIBYTE says whether the incoming text is multibyte. |
| 506 | TO_MULTIBYTE says whether to store the text as multibyte. | 516 | TO_MULTIBYTE says whether to store the text as multibyte. |