Mercurial > emacs
comparison src/insdel.c @ 43218:a4b638169822
(make_gap_smaller): Preserve BEG_UNCHANGED during gap
reduction. This fixes a display problem where stray newlines were
inserted in the window (corrected by C-l). Clarified code (IMHO).
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sat, 09 Feb 2002 22:57:25 +0000 |
parents | e95258418289 |
children | e70fd49212a0 46d69e409b5b |
comparison
equal
deleted
inserted
replaced
43217:cafac76a491b | 43218:a4b638169822 |
---|---|
582 Lisp_Object tem; | 582 Lisp_Object tem; |
583 int real_gap_loc; | 583 int real_gap_loc; |
584 int real_gap_loc_byte; | 584 int real_gap_loc_byte; |
585 int real_Z; | 585 int real_Z; |
586 int real_Z_byte; | 586 int real_Z_byte; |
587 int old_gap_size; | 587 int real_beg_unchanged; |
588 int new_gap_size; | |
588 | 589 |
589 /* Make sure the gap is at least 20 bytes. */ | 590 /* Make sure the gap is at least 20 bytes. */ |
590 if (GAP_SIZE - nbytes_removed < 20) | 591 if (GAP_SIZE - nbytes_removed < 20) |
591 nbytes_removed = GAP_SIZE - 20; | 592 nbytes_removed = GAP_SIZE - 20; |
592 | 593 |
594 tem = Vinhibit_quit; | 595 tem = Vinhibit_quit; |
595 Vinhibit_quit = Qt; | 596 Vinhibit_quit = Qt; |
596 | 597 |
597 real_gap_loc = GPT; | 598 real_gap_loc = GPT; |
598 real_gap_loc_byte = GPT_BYTE; | 599 real_gap_loc_byte = GPT_BYTE; |
599 old_gap_size = GAP_SIZE; | 600 new_gap_size = GAP_SIZE - nbytes_removed; |
600 real_Z = Z; | 601 real_Z = Z; |
601 real_Z_byte = Z_BYTE; | 602 real_Z_byte = Z_BYTE; |
603 real_beg_unchanged = BEG_UNCHANGED; | |
602 | 604 |
603 /* Pretend that the last unwanted part of the gap is the entire gap, | 605 /* Pretend that the last unwanted part of the gap is the entire gap, |
604 and that the first desired part of the gap is part of the buffer | 606 and that the first desired part of the gap is part of the buffer |
605 text. */ | 607 text. */ |
606 bzero (GPT_ADDR, GAP_SIZE - nbytes_removed); | 608 bzero (GPT_ADDR, new_gap_size); |
607 GPT += GAP_SIZE - nbytes_removed; | 609 GPT += new_gap_size; |
608 GPT_BYTE += GAP_SIZE - nbytes_removed; | 610 GPT_BYTE += new_gap_size; |
609 Z += GAP_SIZE - nbytes_removed; | 611 Z += new_gap_size; |
610 Z_BYTE += GAP_SIZE - nbytes_removed; | 612 Z_BYTE += new_gap_size; |
611 GAP_SIZE = nbytes_removed; | 613 GAP_SIZE = nbytes_removed; |
612 | 614 |
613 /* Move the unwanted pretend gap to the end of the buffer. This | 615 /* Move the unwanted pretend gap to the end of the buffer. This |
614 adjusts the markers properly too. */ | 616 adjusts the markers properly too. */ |
615 gap_right (Z, Z_BYTE); | 617 gap_right (Z, Z_BYTE); |
616 | 618 |
617 enlarge_buffer_text (current_buffer, -nbytes_removed); | 619 enlarge_buffer_text (current_buffer, -nbytes_removed); |
618 | 620 |
619 /* Now restore the desired gap. */ | 621 /* Now restore the desired gap. */ |
620 GAP_SIZE = old_gap_size - nbytes_removed; | 622 GAP_SIZE = new_gap_size; |
621 GPT = real_gap_loc; | 623 GPT = real_gap_loc; |
622 GPT_BYTE = real_gap_loc_byte; | 624 GPT_BYTE = real_gap_loc_byte; |
623 Z = real_Z; | 625 Z = real_Z; |
624 Z_BYTE = real_Z_byte; | 626 Z_BYTE = real_Z_byte; |
627 BEG_UNCHANGED = real_beg_unchanged; | |
625 | 628 |
626 /* Put an anchor. */ | 629 /* Put an anchor. */ |
627 *(Z_ADDR) = 0; | 630 *(Z_ADDR) = 0; |
628 | 631 |
629 Vinhibit_quit = tem; | 632 Vinhibit_quit = tem; |