Upgraded to mh-e version 6.1.1.
[bpt/emacs.git] / src / textprop.c
index 928c9f9..84479fc 100644 (file)
@@ -70,6 +70,7 @@ Lisp_Object Qfront_sticky, Qrear_nonsticky;
 
 Lisp_Object Vinhibit_point_motion_hooks;
 Lisp_Object Vdefault_text_properties;
+Lisp_Object Vchar_property_alias_alist;
 Lisp_Object Vtext_property_default_nonsticky;
 
 /* verify_interval_modification saves insertion hooks here
@@ -157,17 +158,17 @@ validate_interval_range (object, begin, end, force)
     }
   else
     {
-      register struct Lisp_String *s = XSTRING (object);
+      int len = SCHARS (object);
 
       if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
-            && XINT (*end) <= s->size))
+            && XINT (*end) <= len))
        args_out_of_range (*begin, *end);
       XSETFASTINT (*begin, XFASTINT (*begin));
       if (begin != end)
        XSETFASTINT (*end, XFASTINT (*end));
-      i = s->intervals;
+      i = STRING_INTERVALS (object);
 
-      if (s->size == 0)
+      if (len == 0)
        return NULL_INTERVAL;
 
       searchpos = XINT (*begin);
@@ -452,23 +453,23 @@ remove_properties (plist, list, i, object)
   register Lisp_Object tail1, tail2, sym, current_plist;
   register int changed = 0;
 
-  /* Nonzero means tail1 is a list, otherwise it is a plist.  */
-  int use_list;
+  /* Nonzero means tail1 is a plist, otherwise it is a list.  */
+  int use_plist;
 
   current_plist = i->plist;
 
   if (! NILP (plist))
-    tail1 = plist, use_list = 0;
+    tail1 = plist, use_plist = 1;
   else
-    tail1 = list, use_list = 1;
+    tail1 = list, use_plist = 0;
 
   /* Go through each element of LIST or PLIST.  */
-  while (! NILP (tail1))
+  while (CONSP (tail1))
     {
       sym = XCAR (tail1);
 
       /* First, remove the symbol if it's at the head of the list */
-      while (! NILP (current_plist) && EQ (sym, XCAR (current_plist)))
+      while (CONSP (current_plist) && EQ (sym, XCAR (current_plist)))
        {
          if (BUFFERP (object))
            record_property_change (i->position, LENGTH (i),
@@ -485,7 +486,7 @@ remove_properties (plist, list, i, object)
        {
          register Lisp_Object this;
          this = XCDR (XCDR (tail2));
-         if (EQ (sym, XCAR (this)))
+         if (CONSP (this) && EQ (sym, XCAR (this)))
            {
              if (BUFFERP (object))
                record_property_change (i->position, LENGTH (i),
@@ -498,10 +499,9 @@ remove_properties (plist, list, i, object)
        }
 
       /* Advance thru TAIL1 one way or the other.  */
-      if (use_list)
+      tail1 = XCDR (tail1);
+      if (use_plist && CONSP (tail1))
        tail1 = XCDR (tail1);
-      else
-       tail1 = XCDR (XCDR (tail1));
     }
 
   if (changed)
@@ -553,11 +553,9 @@ interval_of (position, object)
     }
   else
     {
-      register struct Lisp_String *s = XSTRING (object);
-
       beg = 0;
-      end = s->size;
-      i = s->intervals;
+      end = SCHARS (object);
+      i = STRING_INTERVALS (object);
     }
 
   if (!(beg <= position && position <= end))
@@ -776,7 +774,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       if (NILP (position))
        {
          if (NILP (limit))
-           position = make_number (XSTRING (object)->size);
+           position = make_number (SCHARS (object));
          else
            position = limit;
        }
@@ -784,7 +782,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   else
     {
       Lisp_Object initial_value, value;
-      int count = specpdl_ptr - specpdl;
+      int count = SPECPDL_INDEX ();
 
       if (! NILP (object))
        CHECK_BUFFER (object);
@@ -842,14 +840,14 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       if (NILP (position))
        {
          if (NILP (limit))
-           position = make_number (XSTRING (object)->size);
+           position = make_number (SCHARS (object));
          else
            position = limit;
        }
     }
   else
     {
-      int count = specpdl_ptr - specpdl;
+      int count = SPECPDL_INDEX ();
 
       if (! NILP (object))
        CHECK_BUFFER (object);
@@ -935,7 +933,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
        
       if (NULL_INTERVAL_P (next))
        XSETFASTINT (position, (STRINGP (object)
-                               ? XSTRING (object)->size
+                               ? SCHARS (object)
                                : BUF_ZV (XBUFFER (object))));
       else
        XSETFASTINT (position, next->position);
@@ -955,7 +953,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     return limit;
   if (NILP (limit))
     XSETFASTINT (limit, (STRINGP (object)
-                        ? XSTRING (object)->size
+                        ? SCHARS (object)
                         : BUF_ZV (XBUFFER (object))));
   if (!(next->position < XFASTINT (limit)))
     return limit;
@@ -1035,7 +1033,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     return limit;
   if (NILP (limit))
     XSETFASTINT (limit, (STRINGP (object)
-                        ? XSTRING (object)->size
+                        ? SCHARS (object)
                         : BUF_ZV (XBUFFER (object))));
   if (!(next->position < XFASTINT (limit)))
     return limit;
@@ -1306,12 +1304,12 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
      get rid of its intervals.  */
   if (NILP (properties) && STRINGP (object)
       && XFASTINT (start) == 0
-      && XFASTINT (end) == XSTRING (object)->size)
+      && XFASTINT (end) == SCHARS (object))
     {
-      if (! XSTRING (object)->intervals)
+      if (! STRING_INTERVALS (object))
        return Qt;
 
-      XSTRING (object)->intervals = 0;
+      STRING_SET_INTERVALS (object, NULL_INTERVAL);
       return Qt;
     }
 
@@ -2178,6 +2176,15 @@ The value of a property in this list is seen as the value for every
 character that does not have its own value for that property.  */);
   Vdefault_text_properties = Qnil;
 
+  DEFVAR_LISP ("char-property-alias-alist", &Vchar_property_alias_alist,
+              doc: /* Alist of alternative properties for properties without a value.
+Each element should look like (PROPERTY ALTERNATIVE1 ALTERNATIVE2...).
+If a piece of text has no direct value for a particular property, then
+this alist is consulted.  If that property appears in the alist, then
+the first non-nil value from the associated alternative properties is
+returned. */);
+  Vchar_property_alias_alist = Qnil;
+
   DEFVAR_LISP ("inhibit-point-motion-hooks", &Vinhibit_point_motion_hooks,
               doc: /* If non-nil, don't run `point-left' and `point-entered' text properties.
 This also inhibits the use of the `intangible' text property.  */);