Mercurial > emacs
comparison src/insdel.c @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 23a1cea22d13 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 /* Buffer insertion/deletion and gap motion for GNU Emacs. | 1 /* Buffer insertion/deletion and gap motion for GNU Emacs. |
2 Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 2001 | 2 Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, |
3 Free Software Foundation, Inc. | 3 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GNU Emacs. | 5 This file is part of GNU Emacs. |
6 | 6 |
7 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with GNU Emacs; see the file COPYING. If not, write to | 18 along with GNU Emacs; see the file COPYING. If not, write to |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02111-1307, USA. */ | 20 Boston, MA 02110-1301, USA. */ |
21 | 21 |
22 | 22 |
23 #include <config.h> | 23 #include <config.h> |
24 #include "lisp.h" | 24 #include "lisp.h" |
25 #include "intervals.h" | 25 #include "intervals.h" |
77 else | 77 else |
78 | 78 |
79 void | 79 void |
80 check_markers () | 80 check_markers () |
81 { | 81 { |
82 register Lisp_Object tail; | 82 register struct Lisp_Marker *tail; |
83 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); | 83 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
84 | 84 |
85 tail = BUF_MARKERS (current_buffer); | 85 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next) |
86 | 86 { |
87 while (! NILP (tail)) | 87 if (tail->buffer->text != current_buffer->text) |
88 { | |
89 if (XMARKER (tail)->buffer->text != current_buffer->text) | |
90 abort (); | 88 abort (); |
91 if (XMARKER (tail)->charpos > Z) | 89 if (tail->charpos > Z) |
92 abort (); | 90 abort (); |
93 if (XMARKER (tail)->bytepos > Z_BYTE) | 91 if (tail->bytepos > Z_BYTE) |
94 abort (); | 92 abort (); |
95 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (XMARKER (tail)->bytepos))) | 93 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos))) |
96 abort (); | 94 abort (); |
97 | |
98 tail = XMARKER (tail)->chain; | |
99 } | 95 } |
100 } | 96 } |
101 | 97 |
102 /* Move gap to position CHARPOS. | 98 /* Move gap to position CHARPOS. |
103 Note that this can quit! */ | 99 Note that this can quit! */ |
348 { | 344 { |
349 Lisp_Object marker; | 345 Lisp_Object marker; |
350 register struct Lisp_Marker *m; | 346 register struct Lisp_Marker *m; |
351 register int charpos; | 347 register int charpos; |
352 | 348 |
353 marker = BUF_MARKERS (current_buffer); | 349 for (m = BUF_MARKERS (current_buffer); m; m = m->next) |
354 | 350 { |
355 while (!NILP (marker)) | |
356 { | |
357 m = XMARKER (marker); | |
358 charpos = m->charpos; | 351 charpos = m->charpos; |
359 | 352 |
360 if (charpos > Z) | 353 if (charpos > Z) |
361 abort (); | 354 abort (); |
362 | 355 |
369 } | 362 } |
370 /* 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. */ |
371 else if (charpos > from) | 364 else if (charpos > from) |
372 { | 365 { |
373 if (! m->insertion_type) | 366 if (! m->insertion_type) |
374 /* Normal markers will end up at the beginning of the | 367 { /* Normal markers will end up at the beginning of the |
375 re-inserted text after undoing a deletion, and must be | 368 re-inserted text after undoing a deletion, and must be |
376 adjusted to move them to the correct place. */ | 369 adjusted to move them to the correct place. */ |
370 XSETMISC (marker, m); | |
377 record_marker_adjustment (marker, from - charpos); | 371 record_marker_adjustment (marker, from - charpos); |
372 } | |
378 else if (charpos < to) | 373 else if (charpos < to) |
379 /* Before-insertion markers will automatically move forward | 374 { /* Before-insertion markers will automatically move forward |
380 upon re-inserting the deleted text, so we have to arrange | 375 upon re-inserting the deleted text, so we have to arrange |
381 for them to move backward to the correct position. */ | 376 for them to move backward to the correct position. */ |
377 XSETMISC (marker, m); | |
382 record_marker_adjustment (marker, charpos - to); | 378 record_marker_adjustment (marker, charpos - to); |
383 | 379 } |
384 m->charpos = from; | 380 m->charpos = from; |
385 m->bytepos = from_byte; | 381 m->bytepos = from_byte; |
386 } | 382 } |
387 /* Here's the case where a before-insertion marker is immediately | 383 /* Here's the case where a before-insertion marker is immediately |
388 before the deleted region. */ | 384 before the deleted region. */ |
390 { | 386 { |
391 /* Undoing the change uses normal insertion, which will | 387 /* Undoing the change uses normal insertion, which will |
392 incorrectly make MARKER move forward, so we arrange for it | 388 incorrectly make MARKER move forward, so we arrange for it |
393 to then move backward to the correct place at the beginning | 389 to then move backward to the correct place at the beginning |
394 of the deleted region. */ | 390 of the deleted region. */ |
391 XSETMISC (marker, m); | |
395 record_marker_adjustment (marker, to - from); | 392 record_marker_adjustment (marker, to - from); |
396 } | 393 } |
397 | |
398 marker = m->chain; | |
399 } | 394 } |
400 } | 395 } |
401 | 396 |
402 | 397 |
403 /* Adjust markers for an insertion that stretches from FROM / FROM_BYTE | 398 /* Adjust markers for an insertion that stretches from FROM / FROM_BYTE |
411 static void | 406 static void |
412 adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers) | 407 adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers) |
413 register int from, from_byte, to, to_byte; | 408 register int from, from_byte, to, to_byte; |
414 int before_markers; | 409 int before_markers; |
415 { | 410 { |
416 Lisp_Object marker; | 411 struct Lisp_Marker *m; |
417 int adjusted = 0; | 412 int adjusted = 0; |
418 int nchars = to - from; | 413 int nchars = to - from; |
419 int nbytes = to_byte - from_byte; | 414 int nbytes = to_byte - from_byte; |
420 | 415 |
421 marker = BUF_MARKERS (current_buffer); | 416 for (m = BUF_MARKERS (current_buffer); m; m = m->next) |
422 | 417 { |
423 while (!NILP (marker)) | |
424 { | |
425 register struct Lisp_Marker *m = XMARKER (marker); | |
426 | |
427 /* In a single-byte buffer, a marker's two positions must be | 418 /* In a single-byte buffer, a marker's two positions must be |
428 equal. */ | 419 equal. */ |
429 if (Z == Z_BYTE) | 420 if (Z == Z_BYTE) |
430 { | 421 { |
431 if (m->charpos != m->bytepos) | 422 if (m->charpos != m->bytepos) |
445 else if (m->bytepos > from_byte) | 436 else if (m->bytepos > from_byte) |
446 { | 437 { |
447 m->bytepos += nbytes; | 438 m->bytepos += nbytes; |
448 m->charpos += nchars; | 439 m->charpos += nchars; |
449 } | 440 } |
450 | |
451 marker = m->chain; | |
452 } | 441 } |
453 | 442 |
454 /* Adjusting only markers whose insertion-type is t may result in | 443 /* Adjusting only markers whose insertion-type is t may result in |
455 disordered overlays in the slot `overlays_before'. */ | 444 - disordered start and end in overlays, and |
445 - disordered overlays in the slot `overlays_before' of current_buffer. */ | |
456 if (adjusted) | 446 if (adjusted) |
457 fix_overlays_before (current_buffer, from, to); | 447 { |
448 fix_start_end_in_overlays(from, to); | |
449 fix_overlays_before (current_buffer, from, to); | |
450 } | |
458 } | 451 } |
459 | 452 |
460 /* Adjust point for an insertion of NBYTES bytes, which are NCHARS characters. | 453 /* Adjust point for an insertion of NBYTES bytes, which are NCHARS characters. |
461 | 454 |
462 This is used only when the value of point changes due to an insert | 455 This is used only when the value of point changes due to an insert |
488 static void | 481 static void |
489 adjust_markers_for_replace (from, from_byte, old_chars, old_bytes, | 482 adjust_markers_for_replace (from, from_byte, old_chars, old_bytes, |
490 new_chars, new_bytes) | 483 new_chars, new_bytes) |
491 int from, from_byte, old_chars, old_bytes, new_chars, new_bytes; | 484 int from, from_byte, old_chars, old_bytes, new_chars, new_bytes; |
492 { | 485 { |
493 Lisp_Object marker = BUF_MARKERS (current_buffer); | 486 register struct Lisp_Marker *m; |
494 int prev_to_byte = from_byte + old_bytes; | 487 int prev_to_byte = from_byte + old_bytes; |
495 int diff_chars = new_chars - old_chars; | 488 int diff_chars = new_chars - old_chars; |
496 int diff_bytes = new_bytes - old_bytes; | 489 int diff_bytes = new_bytes - old_bytes; |
497 | 490 |
498 while (!NILP (marker)) | 491 for (m = BUF_MARKERS (current_buffer); m; m = m->next) |
499 { | 492 { |
500 register struct Lisp_Marker *m = XMARKER (marker); | |
501 | |
502 if (m->bytepos >= prev_to_byte) | 493 if (m->bytepos >= prev_to_byte) |
503 { | 494 { |
504 m->charpos += diff_chars; | 495 m->charpos += diff_chars; |
505 m->bytepos += diff_bytes; | 496 m->bytepos += diff_bytes; |
506 } | 497 } |
507 else if (m->bytepos > from_byte) | 498 else if (m->bytepos > from_byte) |
508 { | 499 { |
509 m->charpos = from; | 500 m->charpos = from; |
510 m->bytepos = from_byte; | 501 m->bytepos = from_byte; |
511 } | 502 } |
512 | |
513 marker = m->chain; | |
514 } | 503 } |
515 | 504 |
516 CHECK_MARKERS (); | 505 CHECK_MARKERS (); |
517 } | 506 } |
518 | 507 |
758 register const unsigned char *string; | 747 register const unsigned char *string; |
759 register int nbytes; | 748 register int nbytes; |
760 { | 749 { |
761 if (nbytes > 0) | 750 if (nbytes > 0) |
762 { | 751 { |
763 int opoint = PT; | 752 int len = chars_in_text (string, nbytes), opoint; |
764 insert_1 (string, nbytes, 0, 1, 0); | 753 insert_1_both (string, len, nbytes, 0, 1, 0); |
765 signal_after_change (opoint, 0, PT - opoint); | 754 opoint = PT - len; |
755 signal_after_change (opoint, 0, len); | |
766 update_compositions (opoint, PT, CHECK_BORDER); | 756 update_compositions (opoint, PT, CHECK_BORDER); |
767 } | 757 } |
768 } | 758 } |
769 | 759 |
770 /* Likewise, but inherit text properties from neighboring characters. */ | 760 /* Likewise, but inherit text properties from neighboring characters. */ |
774 register const unsigned char *string; | 764 register const unsigned char *string; |
775 register int nbytes; | 765 register int nbytes; |
776 { | 766 { |
777 if (nbytes > 0) | 767 if (nbytes > 0) |
778 { | 768 { |
779 int opoint = PT; | 769 int len = chars_in_text (string, nbytes), opoint; |
780 insert_1 (string, nbytes, 1, 1, 0); | 770 insert_1_both (string, len, nbytes, 1, 1, 0); |
781 signal_after_change (opoint, 0, PT - opoint); | 771 opoint = PT - len; |
772 signal_after_change (opoint, 0, len); | |
782 update_compositions (opoint, PT, CHECK_BORDER); | 773 update_compositions (opoint, PT, CHECK_BORDER); |
783 } | 774 } |
784 } | 775 } |
785 | 776 |
786 /* Insert the character C before point. Do not inherit text properties. */ | 777 /* Insert the character C before point. Do not inherit text properties. */ |
822 const unsigned char *string; | 813 const unsigned char *string; |
823 register int nbytes; | 814 register int nbytes; |
824 { | 815 { |
825 if (nbytes > 0) | 816 if (nbytes > 0) |
826 { | 817 { |
827 int opoint = PT; | 818 int len = chars_in_text (string, nbytes), opoint; |
828 | 819 insert_1_both (string, len, nbytes, 0, 1, 1); |
829 insert_1 (string, nbytes, 0, 1, 1); | 820 opoint = PT - len; |
830 signal_after_change (opoint, 0, PT - opoint); | 821 signal_after_change (opoint, 0, len); |
831 update_compositions (opoint, PT, CHECK_BORDER); | 822 update_compositions (opoint, PT, CHECK_BORDER); |
832 } | 823 } |
833 } | 824 } |
834 | 825 |
835 /* Likewise, but inherit text properties from neighboring characters. */ | 826 /* Likewise, but inherit text properties from neighboring characters. */ |
839 const unsigned char *string; | 830 const unsigned char *string; |
840 register int nbytes; | 831 register int nbytes; |
841 { | 832 { |
842 if (nbytes > 0) | 833 if (nbytes > 0) |
843 { | 834 { |
844 int opoint = PT; | 835 int len = chars_in_text (string, nbytes), opoint; |
845 | 836 insert_1_both (string, len, nbytes, 1, 1, 1); |
846 insert_1 (string, nbytes, 1, 1, 1); | 837 opoint = PT - len; |
847 signal_after_change (opoint, 0, PT - opoint); | 838 signal_after_change (opoint, 0, len); |
848 update_compositions (opoint, PT, CHECK_BORDER); | 839 update_compositions (opoint, PT, CHECK_BORDER); |
849 } | 840 } |
850 } | 841 } |
851 | 842 |
852 /* Subroutine used by the insert functions above. */ | 843 /* Subroutine used by the insert functions above. */ |
1066 Lisp_Object string; | 1057 Lisp_Object string; |
1067 register int pos, pos_byte, length, length_byte; | 1058 register int pos, pos_byte, length, length_byte; |
1068 int inherit; | 1059 int inherit; |
1069 { | 1060 { |
1070 int opoint = PT; | 1061 int opoint = PT; |
1062 | |
1063 if (SCHARS (string) == 0) | |
1064 return; | |
1065 | |
1071 insert_from_string_1 (string, pos, pos_byte, length, length_byte, | 1066 insert_from_string_1 (string, pos, pos_byte, length, length_byte, |
1072 inherit, 0); | 1067 inherit, 0); |
1073 signal_after_change (opoint, 0, PT - opoint); | 1068 signal_after_change (opoint, 0, PT - opoint); |
1074 update_compositions (opoint, PT, CHECK_BORDER); | 1069 update_compositions (opoint, PT, CHECK_BORDER); |
1075 } | 1070 } |
1083 Lisp_Object string; | 1078 Lisp_Object string; |
1084 register int pos, pos_byte, length, length_byte; | 1079 register int pos, pos_byte, length, length_byte; |
1085 int inherit; | 1080 int inherit; |
1086 { | 1081 { |
1087 int opoint = PT; | 1082 int opoint = PT; |
1083 | |
1084 if (SCHARS (string) == 0) | |
1085 return; | |
1086 | |
1088 insert_from_string_1 (string, pos, pos_byte, length, length_byte, | 1087 insert_from_string_1 (string, pos, pos_byte, length, length_byte, |
1089 inherit, 1); | 1088 inherit, 1); |
1090 signal_after_change (opoint, 0, PT - opoint); | 1089 signal_after_change (opoint, 0, PT - opoint); |
1091 update_compositions (opoint, PT, CHECK_BORDER); | 1090 update_compositions (opoint, PT, CHECK_BORDER); |
1092 } | 1091 } |
1473 GPT -= len; GPT_BYTE -= len_byte; | 1472 GPT -= len; GPT_BYTE -= len_byte; |
1474 ZV -= len; ZV_BYTE -= len_byte; | 1473 ZV -= len; ZV_BYTE -= len_byte; |
1475 Z -= len; Z_BYTE -= len_byte; | 1474 Z -= len; Z_BYTE -= len_byte; |
1476 adjust_after_replace (from, from_byte, Qnil, newlen, len_byte); | 1475 adjust_after_replace (from, from_byte, Qnil, newlen, len_byte); |
1477 } | 1476 } |
1478 | 1477 |
1479 /* Replace the text from character positions FROM to TO with NEW, | 1478 /* Replace the text from character positions FROM to TO with NEW, |
1480 If PREPARE is nonzero, call prepare_to_modify_buffer. | 1479 If PREPARE is nonzero, call prepare_to_modify_buffer. |
1481 If INHERIT, the newly inserted text should inherit text properties | 1480 If INHERIT, the newly inserted text should inherit text properties |
1482 from the surrounding non-deleted text. */ | 1481 from the surrounding non-deleted text. */ |
1483 | 1482 |
1565 Z -= nchars_del; | 1564 Z -= nchars_del; |
1566 ZV_BYTE -= nbytes_del; | 1565 ZV_BYTE -= nbytes_del; |
1567 Z_BYTE -= nbytes_del; | 1566 Z_BYTE -= nbytes_del; |
1568 GPT = from; | 1567 GPT = from; |
1569 GPT_BYTE = from_byte; | 1568 GPT_BYTE = from_byte; |
1570 *(GPT_ADDR) = 0; /* Put an anchor. */ | 1569 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ |
1571 | 1570 |
1572 if (GPT_BYTE < GPT) | 1571 if (GPT_BYTE < GPT) |
1573 abort (); | 1572 abort (); |
1574 | 1573 |
1575 if (GPT - BEG < BEG_UNCHANGED) | 1574 if (GPT - BEG < BEG_UNCHANGED) |
1650 | 1649 |
1651 signal_after_change (from, nchars_del, GPT - from); | 1650 signal_after_change (from, nchars_del, GPT - from); |
1652 update_compositions (from, GPT, CHECK_BORDER); | 1651 update_compositions (from, GPT, CHECK_BORDER); |
1653 } | 1652 } |
1654 | 1653 |
1654 /* Replace the text from character positions FROM to TO with | |
1655 the text in INS of length INSCHARS. | |
1656 Keep the text properties that applied to the old characters | |
1657 (extending them to all the new chars if there are more new chars). | |
1658 | |
1659 Note that this does not yet handle markers quite right. | |
1660 | |
1661 If MARKERS is nonzero, relocate markers. | |
1662 | |
1663 Unlike most functions at this level, never call | |
1664 prepare_to_modify_buffer and never call signal_after_change. */ | |
1665 | |
1666 void | |
1667 replace_range_2 (from, from_byte, to, to_byte, ins, inschars, insbytes, markers) | |
1668 int from, from_byte, to, to_byte; | |
1669 char *ins; | |
1670 int inschars, insbytes, markers; | |
1671 { | |
1672 int nbytes_del, nchars_del; | |
1673 Lisp_Object temp; | |
1674 | |
1675 CHECK_MARKERS (); | |
1676 | |
1677 nchars_del = to - from; | |
1678 nbytes_del = to_byte - from_byte; | |
1679 | |
1680 if (nbytes_del <= 0 && insbytes == 0) | |
1681 return; | |
1682 | |
1683 /* Make sure point-max won't overflow after this insertion. */ | |
1684 XSETINT (temp, Z_BYTE - nbytes_del + insbytes); | |
1685 if (Z_BYTE - nbytes_del + insbytes != XINT (temp)) | |
1686 error ("Maximum buffer size exceeded"); | |
1687 | |
1688 /* Make sure the gap is somewhere in or next to what we are deleting. */ | |
1689 if (from > GPT) | |
1690 gap_right (from, from_byte); | |
1691 if (to < GPT) | |
1692 gap_left (to, to_byte, 0); | |
1693 | |
1694 GAP_SIZE += nbytes_del; | |
1695 ZV -= nchars_del; | |
1696 Z -= nchars_del; | |
1697 ZV_BYTE -= nbytes_del; | |
1698 Z_BYTE -= nbytes_del; | |
1699 GPT = from; | |
1700 GPT_BYTE = from_byte; | |
1701 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | |
1702 | |
1703 if (GPT_BYTE < GPT) | |
1704 abort (); | |
1705 | |
1706 if (GPT - BEG < BEG_UNCHANGED) | |
1707 BEG_UNCHANGED = GPT - BEG; | |
1708 if (Z - GPT < END_UNCHANGED) | |
1709 END_UNCHANGED = Z - GPT; | |
1710 | |
1711 if (GAP_SIZE < insbytes) | |
1712 make_gap (insbytes - GAP_SIZE); | |
1713 | |
1714 /* Copy the replacement text into the buffer. */ | |
1715 bcopy (ins, GPT_ADDR, insbytes); | |
1716 | |
1717 #ifdef BYTE_COMBINING_DEBUG | |
1718 /* We have copied text into the gap, but we have not marked | |
1719 it as part of the buffer. So we can use the old FROM and FROM_BYTE | |
1720 here, for both the previous text and the following text. | |
1721 Meanwhile, GPT_ADDR does point to | |
1722 the text that has been stored by copy_text. */ | |
1723 if (count_combining_before (GPT_ADDR, insbytes, from, from_byte) | |
1724 || count_combining_after (GPT_ADDR, insbytes, from, from_byte)) | |
1725 abort (); | |
1726 #endif | |
1727 | |
1728 GAP_SIZE -= insbytes; | |
1729 GPT += inschars; | |
1730 ZV += inschars; | |
1731 Z += inschars; | |
1732 GPT_BYTE += insbytes; | |
1733 ZV_BYTE += insbytes; | |
1734 Z_BYTE += insbytes; | |
1735 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | |
1736 | |
1737 if (GPT_BYTE < GPT) | |
1738 abort (); | |
1739 | |
1740 /* Adjust the overlay center as needed. This must be done after | |
1741 adjusting the markers that bound the overlays. */ | |
1742 if (nchars_del != inschars) | |
1743 { | |
1744 adjust_overlays_for_insert (from, inschars); | |
1745 adjust_overlays_for_delete (from + inschars, nchars_del); | |
1746 } | |
1747 | |
1748 /* Adjust markers for the deletion and the insertion. */ | |
1749 if (markers | |
1750 && ! (nchars_del == 1 && inschars == 1 && nbytes_del == insbytes)) | |
1751 adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, | |
1752 inschars, insbytes); | |
1753 | |
1754 offset_intervals (current_buffer, from, inschars - nchars_del); | |
1755 | |
1756 /* Relocate point as if it were a marker. */ | |
1757 if (from < PT && (nchars_del != inschars || nbytes_del != insbytes)) | |
1758 { | |
1759 if (PT < to) | |
1760 /* PT was within the deleted text. Move it to FROM. */ | |
1761 adjust_point (from - PT, from_byte - PT_BYTE); | |
1762 else | |
1763 adjust_point (inschars - nchars_del, insbytes - nbytes_del); | |
1764 } | |
1765 | |
1766 if (insbytes == 0) | |
1767 evaporate_overlays (from); | |
1768 | |
1769 CHECK_MARKERS (); | |
1770 | |
1771 MODIFF++; | |
1772 } | |
1773 | |
1655 /* Delete characters in current buffer | 1774 /* Delete characters in current buffer |
1656 from FROM up to (but not including) TO. | 1775 from FROM up to (but not including) TO. |
1657 If TO comes before FROM, we delete nothing. */ | 1776 If TO comes before FROM, we delete nothing. */ |
1658 | 1777 |
1659 void | 1778 void |
1848 Z_BYTE -= nbytes_del; | 1967 Z_BYTE -= nbytes_del; |
1849 ZV -= nchars_del; | 1968 ZV -= nchars_del; |
1850 Z -= nchars_del; | 1969 Z -= nchars_del; |
1851 GPT = from; | 1970 GPT = from; |
1852 GPT_BYTE = from_byte; | 1971 GPT_BYTE = from_byte; |
1853 *(GPT_ADDR) = 0; /* Put an anchor. */ | 1972 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ |
1854 | 1973 |
1855 if (GPT_BYTE < GPT) | 1974 if (GPT_BYTE < GPT) |
1856 abort (); | 1975 abort (); |
1857 | 1976 |
1858 if (GPT - BEG < BEG_UNCHANGED) | 1977 if (GPT - BEG < BEG_UNCHANGED) |
1928 struct gcpro gcpro1; | 2047 struct gcpro gcpro1; |
1929 preserve_marker = Fcopy_marker (make_number (*preserve_ptr), Qnil); | 2048 preserve_marker = Fcopy_marker (make_number (*preserve_ptr), Qnil); |
1930 GCPRO1 (preserve_marker); | 2049 GCPRO1 (preserve_marker); |
1931 verify_interval_modification (current_buffer, start, end); | 2050 verify_interval_modification (current_buffer, start, end); |
1932 *preserve_ptr = marker_position (preserve_marker); | 2051 *preserve_ptr = marker_position (preserve_marker); |
1933 unchain_marker (preserve_marker); | 2052 unchain_marker (XMARKER (preserve_marker)); |
1934 UNGCPRO; | 2053 UNGCPRO; |
1935 } | 2054 } |
1936 else | 2055 else |
1937 verify_interval_modification (current_buffer, start, end); | 2056 verify_interval_modification (current_buffer, start, end); |
1938 } | 2057 } |
1976 | 2095 |
1977 #define RESTORE_VALUE \ | 2096 #define RESTORE_VALUE \ |
1978 if (! NILP (preserve_marker)) \ | 2097 if (! NILP (preserve_marker)) \ |
1979 { \ | 2098 { \ |
1980 *preserve_ptr = marker_position (preserve_marker); \ | 2099 *preserve_ptr = marker_position (preserve_marker); \ |
1981 unchain_marker (preserve_marker); \ | 2100 unchain_marker (XMARKER (preserve_marker)); \ |
1982 } | 2101 } |
1983 | 2102 |
1984 #define PRESERVE_START_END \ | 2103 #define PRESERVE_START_END \ |
1985 if (NILP (start_marker)) \ | 2104 if (NILP (start_marker)) \ |
1986 start_marker = Fcopy_marker (start, Qnil); \ | 2105 start_marker = Fcopy_marker (start, Qnil); \ |
2073 Vafter_change_functions = after_change_functions; | 2192 Vafter_change_functions = after_change_functions; |
2074 } | 2193 } |
2075 UNGCPRO; | 2194 UNGCPRO; |
2076 } | 2195 } |
2077 | 2196 |
2078 if (!NILP (current_buffer->overlays_before) | 2197 if (current_buffer->overlays_before || current_buffer->overlays_after) |
2079 || !NILP (current_buffer->overlays_after)) | |
2080 { | 2198 { |
2081 PRESERVE_VALUE; | 2199 PRESERVE_VALUE; |
2082 report_overlay_modification (FETCH_START, FETCH_END, 0, | 2200 report_overlay_modification (FETCH_START, FETCH_END, 0, |
2083 FETCH_START, FETCH_END, Qnil); | 2201 FETCH_START, FETCH_END, Qnil); |
2084 } | 2202 } |
2108 /* If we are deferring calls to the after-change functions | 2226 /* If we are deferring calls to the after-change functions |
2109 and there are no before-change functions, | 2227 and there are no before-change functions, |
2110 just record the args that we were going to use. */ | 2228 just record the args that we were going to use. */ |
2111 if (! NILP (Vcombine_after_change_calls) | 2229 if (! NILP (Vcombine_after_change_calls) |
2112 && NILP (Vbefore_change_functions) | 2230 && NILP (Vbefore_change_functions) |
2113 && NILP (current_buffer->overlays_before) | 2231 && !current_buffer->overlays_before |
2114 && NILP (current_buffer->overlays_after)) | 2232 && !current_buffer->overlays_after) |
2115 { | 2233 { |
2116 Lisp_Object elt; | 2234 Lisp_Object elt; |
2117 | 2235 |
2118 if (!NILP (combine_after_change_list) | 2236 if (!NILP (combine_after_change_list) |
2119 && current_buffer != XBUFFER (combine_after_change_buffer)) | 2237 && current_buffer != XBUFFER (combine_after_change_buffer)) |
2174 Vafter_change_functions = after_change_functions; | 2292 Vafter_change_functions = after_change_functions; |
2175 } | 2293 } |
2176 UNGCPRO; | 2294 UNGCPRO; |
2177 } | 2295 } |
2178 | 2296 |
2179 if (!NILP (current_buffer->overlays_before) | 2297 if (current_buffer->overlays_before || current_buffer->overlays_after) |
2180 || !NILP (current_buffer->overlays_after)) | |
2181 report_overlay_modification (make_number (charpos), | 2298 report_overlay_modification (make_number (charpos), |
2182 make_number (charpos + lenins), | 2299 make_number (charpos + lenins), |
2183 1, | 2300 1, |
2184 make_number (charpos), | 2301 make_number (charpos), |
2185 make_number (charpos + lenins), | 2302 make_number (charpos + lenins), |
2276 | 2393 |
2277 void | 2394 void |
2278 syms_of_insdel () | 2395 syms_of_insdel () |
2279 { | 2396 { |
2280 staticpro (&combine_after_change_list); | 2397 staticpro (&combine_after_change_list); |
2398 staticpro (&combine_after_change_buffer); | |
2281 combine_after_change_list = Qnil; | 2399 combine_after_change_list = Qnil; |
2282 combine_after_change_buffer = Qnil; | 2400 combine_after_change_buffer = Qnil; |
2283 | 2401 |
2284 DEFVAR_BOOL ("check-markers-debug-flag", &check_markers_debug_flag, | 2402 DEFVAR_BOOL ("check-markers-debug-flag", &check_markers_debug_flag, |
2285 doc: /* Non-nil means enable debugging checks for invalid marker positions. */); | 2403 doc: /* Non-nil means enable debugging checks for invalid marker positions. */); |
2296 Qinhibit_modification_hooks = intern ("inhibit-modification-hooks"); | 2414 Qinhibit_modification_hooks = intern ("inhibit-modification-hooks"); |
2297 staticpro (&Qinhibit_modification_hooks); | 2415 staticpro (&Qinhibit_modification_hooks); |
2298 | 2416 |
2299 defsubr (&Scombine_after_change_execute); | 2417 defsubr (&Scombine_after_change_execute); |
2300 } | 2418 } |
2419 | |
2420 /* arch-tag: 9b34b886-47d7-465e-a234-299af411b23d | |
2421 (do not change this comment) */ |