aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1993-07-18 06:28:12 +0000
committerJim Blandy1993-07-18 06:28:12 +0000
commitad9c19400fd3e55d6fe78a7aa582bdc94cd8b3cc (patch)
tree0c3525dc43d4de8da313b7fa926769ab0c85e2eb /src
parent23c6349cdd816e4cb0639ad397d8df6aee35cb27 (diff)
downloademacs-ad9c19400fd3e55d6fe78a7aa582bdc94cd8b3cc.tar.gz
emacs-ad9c19400fd3e55d6fe78a7aa582bdc94cd8b3cc.zip
* intervals.c (split_interval_left, split_interval_right): Change
OFFSET argument of these functions to be origin 0, not origin 1. This is what all the callers currently want. * intervals.c, textprop.c: All callers changed. * textprop.c (Ftext_property_not_all): Renamed from Ftext_property_all, and changed sense of return value, so that it returns useful information if not all characters have properties EQ to value. Now all the existential and universal questions can be asked. * textprop.c (syms_of_textprop): Don't forget defsubr for Stext_property_all. * textprop.c (Ftext_property_any, Ftext_property_all): Use EQ to compare property values, not Fequal. * textprop.c (Ftext_property_any, Ftext_property_all): New functions, from David Gillespie. * intervals.h (Ftext_property_any, Ftext_property_all): Declare them.
Diffstat (limited to 'src')
-rw-r--r--src/textprop.c92
1 files changed, 82 insertions, 10 deletions
diff --git a/src/textprop.c b/src/textprop.c
index e16f44c8932..72e0c1a2d25 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -688,7 +688,7 @@ Return t if any property value actually changed, nil otherwise.")
688 else 688 else
689 { 689 {
690 unchanged = i; 690 unchanged = i;
691 i = split_interval_right (unchanged, s - unchanged->position + 1); 691 i = split_interval_right (unchanged, s - unchanged->position);
692 copy_properties (unchanged, i); 692 copy_properties (unchanged, i);
693 } 693 }
694 } 694 }
@@ -712,7 +712,7 @@ Return t if any property value actually changed, nil otherwise.")
712 712
713 /* i doesn't have the properties, and goes past the change limit */ 713 /* i doesn't have the properties, and goes past the change limit */
714 unchanged = i; 714 unchanged = i;
715 i = split_interval_left (unchanged, len + 1); 715 i = split_interval_left (unchanged, len);
716 copy_properties (unchanged, i); 716 copy_properties (unchanged, i);
717 add_properties (properties, i, object); 717 add_properties (properties, i, object);
718 return Qt; 718 return Qt;
@@ -768,12 +768,12 @@ is the string or buffer containing the text.")
768 if (i->position != s) 768 if (i->position != s)
769 { 769 {
770 unchanged = i; 770 unchanged = i;
771 i = split_interval_right (unchanged, s - unchanged->position + 1); 771 i = split_interval_right (unchanged, s - unchanged->position);
772 772
773 if (LENGTH (i) > len) 773 if (LENGTH (i) > len)
774 { 774 {
775 copy_properties (unchanged, i); 775 copy_properties (unchanged, i);
776 i = split_interval_left (i, len + 1); 776 i = split_interval_left (i, len);
777 set_properties (props, i, object); 777 set_properties (props, i, object);
778 return Qt; 778 return Qt;
779 } 779 }
@@ -797,7 +797,7 @@ is the string or buffer containing the text.")
797 if (LENGTH (i) >= len) 797 if (LENGTH (i) >= len)
798 { 798 {
799 if (LENGTH (i) > len) 799 if (LENGTH (i) > len)
800 i = split_interval_left (i, len + 1); 800 i = split_interval_left (i, len);
801 801
802 if (NULL_INTERVAL_P (prev_changed)) 802 if (NULL_INTERVAL_P (prev_changed))
803 set_properties (props, i, object); 803 set_properties (props, i, object);
@@ -863,7 +863,7 @@ Return t if any property was actually removed, nil otherwise.")
863 else 863 else
864 { 864 {
865 unchanged = i; 865 unchanged = i;
866 i = split_interval_right (unchanged, s - unchanged->position + 1); 866 i = split_interval_right (unchanged, s - unchanged->position);
867 copy_properties (unchanged, i); 867 copy_properties (unchanged, i);
868 } 868 }
869 } 869 }
@@ -887,7 +887,7 @@ Return t if any property was actually removed, nil otherwise.")
887 887
888 /* i has the properties, and goes past the change limit */ 888 /* i has the properties, and goes past the change limit */
889 unchanged = i; 889 unchanged = i;
890 i = split_interval_left (i, len + 1); 890 i = split_interval_left (i, len);
891 copy_properties (unchanged, i); 891 copy_properties (unchanged, i);
892 remove_properties (props, i, object); 892 remove_properties (props, i, object);
893 return Qt; 893 return Qt;
@@ -899,6 +899,76 @@ Return t if any property was actually removed, nil otherwise.")
899 } 899 }
900} 900}
901 901
902DEFUN ("text-property-any", Ftext_property_any,
903 Stext_property_any, 4, 5, 0,
904 "Check text from START to END to see if PROP is ever `eq' to VALUE.\n\
905If so, return the position of the first character whose PROP is `eq'\n\
906to VALUE. Otherwise return nil.\n\
907The optional fifth argument, OBJECT, is the string or buffer\n\
908containing the text.")
909 (start, end, prop, value, object)
910 Lisp_Object start, end, prop, value, object;
911{
912 register INTERVAL i;
913 register int e, pos;
914
915 if (NILP (object))
916 XSET (object, Lisp_Buffer, current_buffer);
917 i = validate_interval_range (object, &start, &end, soft);
918 e = XINT (end);
919
920 while (! NULL_INTERVAL_P (i))
921 {
922 if (i->position >= e)
923 break;
924 if (EQ (textget (i->plist, prop), value))
925 {
926 pos = i->position;
927 if (pos < XINT (start))
928 pos = XINT (start);
929 return make_number (pos - (XTYPE (object) == Lisp_String));
930 }
931 i = next_interval (i);
932 }
933 return Qnil;
934}
935
936DEFUN ("text-property-not-all", Ftext_property_not_all,
937 Stext_property_not_all, 4, 5, 0,
938 "Check text from START to END to see if PROP is ever not `eq' to VALUE.\n\
939If so, return the position of the first character whose PROP is not\n\
940`eq' to VALUE. Otherwise, return nil.\n\
941The optional fifth argument, OBJECT, is the string or buffer\n\
942containing the text.")
943 (start, end, prop, value, object)
944 Lisp_Object start, end, prop, value, object;
945{
946 register INTERVAL i;
947 register int s, e;
948
949 if (NILP (object))
950 XSET (object, Lisp_Buffer, current_buffer);
951 i = validate_interval_range (object, &start, &end, soft);
952 if (NULL_INTERVAL_P (i))
953 return (NILP (value) || EQ (start, end)) ? Qt : Qnil;
954 s = XINT (start);
955 e = XINT (end);
956
957 while (! NULL_INTERVAL_P (i))
958 {
959 if (i->position >= e)
960 break;
961 if (! EQ (textget (i->plist, prop), value))
962 {
963 if (i->position > s)
964 s = i->position;
965 return make_number (s - (XTYPE (object) == Lisp_String));
966 }
967 i = next_interval (i);
968 }
969 return Qnil;
970}
971
902#if 0 /* You can use set-text-properties for this. */ 972#if 0 /* You can use set-text-properties for this. */
903 973
904DEFUN ("erase-text-properties", Ferase_text_properties, 974DEFUN ("erase-text-properties", Ferase_text_properties,
@@ -931,13 +1001,13 @@ is the string or buffer containing the text.")
931 /* If there are properties here, then this text will be modified. */ 1001 /* If there are properties here, then this text will be modified. */
932 if (! NILP (i->plist)) 1002 if (! NILP (i->plist))
933 { 1003 {
934 i = split_interval_right (unchanged, s - unchanged->position + 1); 1004 i = split_interval_right (unchanged, s - unchanged->position);
935 i->plist = Qnil; 1005 i->plist = Qnil;
936 modified++; 1006 modified++;
937 1007
938 if (LENGTH (i) > len) 1008 if (LENGTH (i) > len)
939 { 1009 {
940 i = split_interval_right (i, len + 1); 1010 i = split_interval_right (i, len);
941 copy_properties (unchanged, i); 1011 copy_properties (unchanged, i);
942 return Qt; 1012 return Qt;
943 } 1013 }
@@ -977,7 +1047,7 @@ is the string or buffer containing the text.")
977 } 1047 }
978 1048
979 if (LENGTH (i) > len) 1049 if (LENGTH (i) > len)
980 i = split_interval_left (i, len + 1); 1050 i = split_interval_left (i, len);
981 if (! NULL_INTERVAL_P (prev_changed)) 1051 if (! NULL_INTERVAL_P (prev_changed))
982 merge_interval_left (i); 1052 merge_interval_left (i);
983 else 1053 else
@@ -1159,6 +1229,8 @@ percentage by which the left interval tree should not differ from the right.");
1159 defsubr (&Sput_text_property); 1229 defsubr (&Sput_text_property);
1160 defsubr (&Sset_text_properties); 1230 defsubr (&Sset_text_properties);
1161 defsubr (&Sremove_text_properties); 1231 defsubr (&Sremove_text_properties);
1232 defsubr (&Stext_property_any);
1233 defsubr (&Stext_property_not_all);
1162/* defsubr (&Serase_text_properties); */ 1234/* defsubr (&Serase_text_properties); */
1163/* defsubr (&Scopy_text_properties); */ 1235/* defsubr (&Scopy_text_properties); */
1164} 1236}