Mercurial > emacs
comparison src/intervals.c @ 4638:3872f91770fc
(adjust_intervals_for_insertion): If inserting in middle
of interval that is sticky in neither direction, don't copy props.
(merge_properties_sticky): Handle non-list as front-sticky or
rear-nonsticky property.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 15 Aug 1993 03:49:28 +0000 |
parents | d4a36c1669e6 |
children | 1fc792473491 |
comparison
equal
deleted
inserted
replaced
4637:f3b38883ee2d | 4638:3872f91770fc |
---|---|
653 position = BEG + TOTAL_LENGTH (tree); | 653 position = BEG + TOTAL_LENGTH (tree); |
654 eobp = 1; | 654 eobp = 1; |
655 } | 655 } |
656 | 656 |
657 i = find_interval (tree, position); | 657 i = find_interval (tree, position); |
658 | |
659 /* If in middle of an interval which is not sticky either way, | |
660 we must not just give its properties to the insertion. | |
661 So split this interval at the insertion point. */ | |
662 if (! (position == i->position || eobp) | |
663 && END_NONSTICKY_P (i) | |
664 && ! FRONT_STICKY_P (i)) | |
665 { | |
666 temp = split_interval_right (i, position - i->position); | |
667 copy_properties (i, temp); | |
668 i = temp; | |
669 } | |
658 | 670 |
659 /* If we are positioned between intervals, check the stickiness of | 671 /* If we are positioned between intervals, check the stickiness of |
660 both of them. We have to do this too, if we are at BEG or Z. */ | 672 both of them. We have to do this too, if we are at BEG or Z. */ |
661 if (position == i->position || eobp) | 673 if (position == i->position || eobp) |
662 { | 674 { |
746 | 758 |
747 /* Sticky properties get special treatment. */ | 759 /* Sticky properties get special treatment. */ |
748 if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) | 760 if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) |
749 continue; | 761 continue; |
750 | 762 |
751 if (NILP (Fmemq (sym, lrear))) | 763 if (CONSP (lrear) ? NILP (Fmemq (sym, lrear)) : NILP (lrear)) |
752 { | 764 { |
753 /* rear-sticky is dominant, we needn't search in PRIGHT. */ | 765 /* rear-sticky is dominant, we needn't search in PRIGHT. */ |
754 | 766 |
755 props = Fcons (sym, Fcons (Fcar (Fcdr (tail1)), props)); | 767 props = Fcons (sym, Fcons (Fcar (Fcdr (tail1)), props)); |
756 if (! NILP (Fmemq (sym, lfront))) | 768 if ((CONSP (lfront) || NILP (lfront)) |
769 && ! NILP (Fmemq (sym, lfront))) | |
757 front = Fcons (sym, front); | 770 front = Fcons (sym, front); |
758 } | 771 } |
759 else | 772 else |
760 { | 773 { |
761 /* Go through PRIGHT, looking for sym. */ | 774 /* Go through PRIGHT, looking for sym. */ |
762 for (tail2 = pright; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | 775 for (tail2 = pright; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) |
763 if (EQ (sym, Fcar (tail2))) | 776 if (EQ (sym, Fcar (tail2))) |
764 { | 777 { |
765 | 778 |
766 if (! NILP (Fmemq (sym, rfront))) | 779 if (CONSP (rfront) |
780 ? ! NILP (Fmemq (sym, rfront)) : ! NILP (rfront)) | |
767 { | 781 { |
768 /* Nonsticky at the left and sticky at the right, | 782 /* Nonsticky at the left and sticky at the right, |
769 so take the right one. */ | 783 so take the right one. */ |
770 props = Fcons (sym, Fcons (Fcar (Fcdr (tail2)), props)); | 784 props = Fcons (sym, Fcons (Fcar (Fcdr (tail2)), props)); |
771 front = Fcons (sym, front); | 785 front = Fcons (sym, front); |
772 if (! NILP (Fmemq (sym, rrear))) | 786 if ((CONSP (rrear) || NILP (rrear)) |
787 && ! NILP (Fmemq (sym, rrear))) | |
773 rear = Fcons (sym, rear); | 788 rear = Fcons (sym, rear); |
774 } | 789 } |
775 break; | 790 break; |
776 } | 791 } |
777 } | 792 } |
784 /* Sticky properties get special treatment. */ | 799 /* Sticky properties get special treatment. */ |
785 if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) | 800 if (EQ (sym, Qrear_nonsticky) || EQ (sym, Qfront_sticky)) |
786 continue; | 801 continue; |
787 | 802 |
788 /* If it ain't sticky, we don't take it. */ | 803 /* If it ain't sticky, we don't take it. */ |
789 if (NILP (Fmemq (sym, rfront))) | 804 if (CONSP (rfront) |
805 ? NILP (Fmemq (sym, rfront)) : NILP (rfront)) | |
790 continue; | 806 continue; |
791 | 807 |
792 /* If sym is in PLEFT we already got it. */ | 808 /* If sym is in PLEFT we already got it. */ |
793 for (tail1 = pleft; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | 809 for (tail1 = pleft; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) |
794 if (EQ (sym, Fcar (tail1))) | 810 if (EQ (sym, Fcar (tail1))) |
796 | 812 |
797 if (NILP (tail1)) | 813 if (NILP (tail1)) |
798 { | 814 { |
799 props = Fcons (sym, Fcons (Fcar (Fcdr (tail2)), props)); | 815 props = Fcons (sym, Fcons (Fcar (Fcdr (tail2)), props)); |
800 front = Fcons (sym, front); | 816 front = Fcons (sym, front); |
801 if (! NILP (Fmemq (sym, rrear))) | 817 if ((CONSP (rrear) || NILP (rrear)) |
818 && ! NILP (Fmemq (sym, rrear))) | |
802 rear = Fcons (sym, rear); | 819 rear = Fcons (sym, rear); |
803 } | 820 } |
804 } | 821 } |
805 if (! NILP (front)) | 822 if (! NILP (front)) |
806 props = Fcons (Qfront_sticky, Fcons (front, props)); | 823 props = Fcons (Qfront_sticky, Fcons (front, props)); |