diff options
| author | Joseph Arceneaux | 1992-09-30 01:11:20 +0000 |
|---|---|---|
| committer | Joseph Arceneaux | 1992-09-30 01:11:20 +0000 |
| commit | 7855e674d72674171da39af1f4206f091e5d15c8 (patch) | |
| tree | 538fc36b88198865bab44f8d3895706f988f4333 /src | |
| parent | 3f9e2e5121d21175914ec838e90f42c337a74dcf (diff) | |
| download | emacs-7855e674d72674171da39af1f4206f091e5d15c8.tar.gz emacs-7855e674d72674171da39af1f4206f091e5d15c8.zip | |
Mods to Ferase_text_properties
Diffstat (limited to 'src')
| -rw-r--r-- | src/textprop.c | 80 |
1 files changed, 59 insertions, 21 deletions
diff --git a/src/textprop.c b/src/textprop.c index 350ceec9b1c..1600928fde6 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -557,6 +557,7 @@ Otherwise return nil.") | |||
| 557 | unchanged = i; | 557 | unchanged = i; |
| 558 | i = split_interval_right (unchanged, s - unchanged->position + 1); | 558 | i = split_interval_right (unchanged, s - unchanged->position + 1); |
| 559 | set_properties (properties, i); | 559 | set_properties (properties, i); |
| 560 | |||
| 560 | if (LENGTH (i) > len) | 561 | if (LENGTH (i) > len) |
| 561 | { | 562 | { |
| 562 | i = split_interval_right (i, len); | 563 | i = split_interval_right (i, len); |
| @@ -572,7 +573,7 @@ Otherwise return nil.") | |||
| 572 | i = next_interval (i); | 573 | i = next_interval (i); |
| 573 | } | 574 | } |
| 574 | 575 | ||
| 575 | while (1) | 576 | while (len > 0) |
| 576 | { | 577 | { |
| 577 | if (LENGTH (i) >= len) | 578 | if (LENGTH (i) >= len) |
| 578 | { | 579 | { |
| @@ -694,6 +695,7 @@ range START to END. Returns t if any change was made, nil otherwise.") | |||
| 694 | Lisp_Object object, start, end; | 695 | Lisp_Object object, start, end; |
| 695 | { | 696 | { |
| 696 | register INTERVAL i, unchanged; | 697 | register INTERVAL i, unchanged; |
| 698 | register prev_changed = NULL_INTERVAL; | ||
| 697 | register int s, len, modified; | 699 | register int s, len, modified; |
| 698 | 700 | ||
| 699 | i = validate_interval_range (object, &start, &end, soft); | 701 | i = validate_interval_range (object, &start, &end, soft); |
| @@ -702,46 +704,82 @@ range START to END. Returns t if any change was made, nil otherwise.") | |||
| 702 | 704 | ||
| 703 | s = XINT (start); | 705 | s = XINT (start); |
| 704 | len = XINT (end) - s; | 706 | len = XINT (end) - s; |
| 707 | |||
| 705 | if (i->position != s) | 708 | if (i->position != s) |
| 706 | { | 709 | { |
| 707 | int got = LENGTH (i) - (s - i->position); | 710 | register int got; |
| 711 | unchanged = i; | ||
| 708 | 712 | ||
| 709 | if (got > len) | 713 | /* If there are properties here, then this text will be modified. */ |
| 714 | if (!NILP (i->plist)) | ||
| 710 | { | 715 | { |
| 711 | if (NILP (i->plist)) | ||
| 712 | return Qnil; | ||
| 713 | |||
| 714 | unchanged = i; | ||
| 715 | i = split_interval_right (unchanged, s - unchanged->position + 1); | 716 | i = split_interval_right (unchanged, s - unchanged->position + 1); |
| 716 | i = split_interval_right (i, len + 1); | 717 | i->plist = Qnil; |
| 717 | copy_properties (unchanged, i); | ||
| 718 | return Qt; | ||
| 719 | } | ||
| 720 | |||
| 721 | if (! NILP (i->plist)) | ||
| 722 | { | ||
| 723 | i = split_interval_right (i, s - i->position + 1); | ||
| 724 | modified++; | 718 | modified++; |
| 719 | |||
| 720 | if (LENGTH (i) > len) | ||
| 721 | { | ||
| 722 | i = split_interval_right (i, len + 1); | ||
| 723 | copy_properties (unchanged, i); | ||
| 724 | return Qt; | ||
| 725 | } | ||
| 726 | |||
| 727 | if (LENGTH (i) == len) | ||
| 728 | return Qt; | ||
| 729 | |||
| 730 | got = LENGTH (i); | ||
| 725 | } | 731 | } |
| 732 | /* If the text of i is without any properties, and contains | ||
| 733 | LEN or more characters, then we return witout changing anything.*/ | ||
| 734 | else if (LENGTH (i) - (s - i->position) <= len) | ||
| 735 | return Qnil; | ||
| 736 | else | ||
| 737 | got = LENGTH (i) - (s - i->position); | ||
| 726 | 738 | ||
| 727 | len -= got; | 739 | len -= got; |
| 740 | prev_changed = i; | ||
| 728 | i = next_interval (i); | 741 | i = next_interval (i); |
| 729 | } | 742 | } |
| 730 | 743 | ||
| 731 | /* We are starting at the beginning of an interval */ | 744 | /* We are starting at the beginning of an interval, I. */ |
| 732 | while (len > 0) | 745 | while (len > 0) |
| 733 | { | 746 | { |
| 734 | if (LENGTH (i) > len) | 747 | if (LENGTH (i) >= len) |
| 735 | { | 748 | { |
| 736 | if (NILP (i->plist)) | 749 | /* If this last interval is exactly the right length, |
| 737 | return modified ? Qt : Qnil; | 750 | or is already without properties, then there's nothing |
| 751 | to do except merge it if possible. */ | ||
| 752 | if (NILP (i->plist) || LENGTH (i) == len) | ||
| 753 | { | ||
| 754 | if (! NULL_INTERVAL_P (prev_changed)) | ||
| 755 | merge_interval_left (i); | ||
| 738 | 756 | ||
| 757 | return modified ? Qt : Qnil; | ||
| 758 | } | ||
| 759 | |||
| 760 | /* Here we know the last interval is longer than LEN and | ||
| 761 | has properties. */ | ||
| 739 | i = split_interval_left (i, len + 1); | 762 | i = split_interval_left (i, len + 1); |
| 740 | return Qt; | 763 | modified += erase_properties (i); |
| 764 | if (! NULL_INTERVAL_P (prev_changed)) | ||
| 765 | merge_interval_left (i); | ||
| 766 | |||
| 767 | return modified ? Qt : Qnil; | ||
| 741 | } | 768 | } |
| 742 | 769 | ||
| 743 | len -= LENGTH (i); | 770 | len -= LENGTH (i); |
| 744 | modified += erase_properties (i); | 771 | if (NULL_INTERVAL_P (prev_changed)) |
| 772 | { | ||
| 773 | modified += erase_properties (i); | ||
| 774 | prev_changed = i; | ||
| 775 | } | ||
| 776 | else | ||
| 777 | { | ||
| 778 | if (! NULL_INTERVAL_P (i)) | ||
| 779 | modified++; | ||
| 780 | prev_changed = i = merge_interval_left (i); | ||
| 781 | } | ||
| 782 | |||
| 745 | i = next_interval (i); | 783 | i = next_interval (i); |
| 746 | } | 784 | } |
| 747 | 785 | ||