comparison src/intervals.c @ 16708:7b139b59bda4

(merge_properties_sticky): Don't discard explicit nil properties. Don't put on a front-sticky property if we inherit one from the category that does the job.
author Richard M. Stallman <rms@gnu.org>
date Tue, 17 Dec 1996 07:25:35 +0000
parents 82898b671633
children 2ecf4bb329a8
comparison
equal deleted inserted replaced
16707:cad3a4d09d58 16708:7b139b59bda4
896 merge_properties_sticky (pleft, pright) 896 merge_properties_sticky (pleft, pright)
897 Lisp_Object pleft, pright; 897 Lisp_Object pleft, pright;
898 { 898 {
899 register Lisp_Object props, front, rear; 899 register Lisp_Object props, front, rear;
900 Lisp_Object lfront, lrear, rfront, rrear; 900 Lisp_Object lfront, lrear, rfront, rrear;
901 register Lisp_Object tail1, tail2, sym, lval, rval; 901 register Lisp_Object tail1, tail2, sym, lval, rval, cat;
902 int use_left, use_right; 902 int use_left, use_right;
903 int lpresent;
903 904
904 props = Qnil; 905 props = Qnil;
905 front = Qnil; 906 front = Qnil;
906 rear = Qnil; 907 rear = Qnil;
907 lfront = textget (pleft, Qfront_sticky); 908 lfront = textget (pleft, Qfront_sticky);
920 921
921 rval = Fcar (Fcdr (tail1)); 922 rval = Fcar (Fcdr (tail1));
922 for (tail2 = pleft; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) 923 for (tail2 = pleft; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
923 if (EQ (sym, Fcar (tail2))) 924 if (EQ (sym, Fcar (tail2)))
924 break; 925 break;
925 lval = (NILP (tail2) ? Qnil : Fcar( Fcdr (tail2))); 926
926 927 /* Indicate whether the property is explicitly defined on the left.
927 use_left = ! TMEM (sym, lrear); 928 (We know it is defined explicitly on the right
929 because otherwise we don't get here.) */
930 lpresent = ! NILP (tail2);
931 lval = (NILP (tail2) ? Qnil : Fcar (Fcdr (tail2)));
932
933 use_left = ! TMEM (sym, lrear) && lpresent;
928 use_right = TMEM (sym, rfront); 934 use_right = TMEM (sym, rfront);
929 if (use_left && use_right) 935 if (use_left && use_right)
930 { 936 {
931 use_left = ! NILP (lval); 937 if (NILP (lval))
932 use_right = ! NILP (rval); 938 use_left = 0;
939 else if (NILP (rval))
940 use_right = 0;
933 } 941 }
934 if (use_left) 942 if (use_left)
935 { 943 {
936 /* We build props as (value sym ...) rather than (sym value ...) 944 /* We build props as (value sym ...) rather than (sym value ...)
937 because we plan to nreverse it when we're done. */ 945 because we plan to nreverse it when we're done. */
938 if (! NILP (lval)) 946 props = Fcons (lval, Fcons (sym, props));
939 props = Fcons (lval, Fcons (sym, props));
940 if (TMEM (sym, lfront)) 947 if (TMEM (sym, lfront))
941 front = Fcons (sym, front); 948 front = Fcons (sym, front);
942 if (TMEM (sym, lrear)) 949 if (TMEM (sym, lrear))
943 rear = Fcons (sym, rear); 950 rear = Fcons (sym, rear);
944 } 951 }
945 else if (use_right) 952 else if (use_right)
946 { 953 {
947 if (! NILP (rval)) 954 props = Fcons (rval, Fcons (sym, props));
948 props = Fcons (rval, Fcons (sym, props));
949 if (TMEM (sym, rfront)) 955 if (TMEM (sym, rfront))
950 front = Fcons (sym, front); 956 front = Fcons (sym, front);
951 if (TMEM (sym, rrear)) 957 if (TMEM (sym, rrear))
952 rear = Fcons (sym, rear); 958 rear = Fcons (sym, rear);
953 } 959 }
972 lval = Fcar (Fcdr (tail2)); 978 lval = Fcar (Fcdr (tail2));
973 979
974 /* Since rval is known to be nil in this loop, the test simplifies. */ 980 /* Since rval is known to be nil in this loop, the test simplifies. */
975 if (! TMEM (sym, lrear)) 981 if (! TMEM (sym, lrear))
976 { 982 {
977 if (! NILP (lval)) 983 props = Fcons (lval, Fcons (sym, props));
978 props = Fcons (lval, Fcons (sym, props));
979 if (TMEM (sym, lfront)) 984 if (TMEM (sym, lfront))
980 front = Fcons (sym, front); 985 front = Fcons (sym, front);
981 } 986 }
982 else if (TMEM (sym, rfront)) 987 else if (TMEM (sym, rfront))
983 { 988 {
989 } 994 }
990 } 995 }
991 props = Fnreverse (props); 996 props = Fnreverse (props);
992 if (! NILP (rear)) 997 if (! NILP (rear))
993 props = Fcons (Qrear_nonsticky, Fcons (Fnreverse (rear), props)); 998 props = Fcons (Qrear_nonsticky, Fcons (Fnreverse (rear), props));
994 if (! NILP (front)) 999
1000 cat = textget (props, Qcategory);
1001 if (! NILP (front)
1002 &&
1003 /* If we have inherited a front-stick category property that is t,
1004 we don't need to set up a detailed one. */
1005 ! (! NILP (cat) && SYMBOLP (cat)
1006 && EQ (Fget (cat, Qfront_sticky), Qt)))
995 props = Fcons (Qfront_sticky, Fcons (Fnreverse (front), props)); 1007 props = Fcons (Qfront_sticky, Fcons (Fnreverse (front), props));
996 return props; 1008 return props;
997 } 1009 }
998 1010
999 1011