]> code.delx.au - gnu-emacs/blobdiff - src/textprop.c
(lisp, shortlisp): Add lao.elc.
[gnu-emacs] / src / textprop.c
index 0ef85117eaceaee1a65af7538c51f3667cc0dec6..3e667825d4b57069053d60df5e524c36d3da6c19 100644 (file)
@@ -299,14 +299,9 @@ set_properties (properties, interval, object)
        if (! EQ (property_value (properties, XCONS (sym)->car),
                  XCONS (value)->car))
          {
-           modify_region (XBUFFER (object),
-                          interval->position,
-                          interval->position + LENGTH (interval));
            record_property_change (interval->position, LENGTH (interval),
                                    XCONS (sym)->car, XCONS (value)->car,
                                    object);
-           signal_after_change (interval->position, LENGTH (interval),
-                                LENGTH (interval));
          }
 
       /* For each new property that has no value at all in the old plist,
@@ -316,14 +311,9 @@ set_properties (properties, interval, object)
           sym = XCONS (value)->cdr)
        if (EQ (property_value (interval->plist, XCONS (sym)->car), Qunbound))
          {
-           modify_region (XBUFFER (object),
-                          interval->position,
-                          interval->position + LENGTH (interval));
            record_property_change (interval->position, LENGTH (interval),
                                    XCONS (sym)->car, Qnil,
                                    object);
-           signal_after_change (interval->position, LENGTH (interval),
-                                LENGTH (interval));
          }
     }
 
@@ -386,12 +376,8 @@ add_properties (plist, i, object)
            /* Record this change in the buffer, for undo purposes.  */
            if (BUFFERP (object))
              {
-               modify_region (XBUFFER (object),
-                              i->position,
-                              i->position + LENGTH (i));
                record_property_change (i->position, LENGTH (i),
                                        sym1, Fcar (this_cdr), object);
-               signal_after_change (i->position, LENGTH (i), LENGTH (i));
              }
 
            /* I's property has a different value -- change it */
@@ -405,12 +391,8 @@ add_properties (plist, i, object)
          /* Record this change in the buffer, for undo purposes.  */
          if (BUFFERP (object))
            {
-             modify_region (XBUFFER (object),
-                            i->position,
-                            i->position + LENGTH (i));
              record_property_change (i->position, LENGTH (i),
                                      sym1, Qnil, object);
-             signal_after_change (i->position, LENGTH (i), LENGTH (i));
            }
          i->plist = Fcons (sym1, Fcons (val1, i->plist));
          changed++;
@@ -446,13 +428,9 @@ remove_properties (plist, i, object)
        {
          if (BUFFERP (object))
            {
-             modify_region (XBUFFER (object),
-                            i->position,
-                            i->position + LENGTH (i));
              record_property_change (i->position, LENGTH (i),
                                      sym, Fcar (Fcdr (current_plist)),
                                      object);
-             signal_after_change (i->position, LENGTH (i), LENGTH (i));
            }
 
          current_plist = Fcdr (Fcdr (current_plist));
@@ -469,12 +447,8 @@ remove_properties (plist, i, object)
            {
              if (BUFFERP (object))
                {
-                 modify_region (XBUFFER (object),
-                                i->position,
-                                i->position + LENGTH (i));
                  record_property_change (i->position, LENGTH (i),
                                          sym, Fcar (Fcdr (this)), object);
-                 signal_after_change (i->position, LENGTH (i), LENGTH (i));
                }
 
              Fsetcdr (Fcdr (tail2), Fcdr (Fcdr (this)));
@@ -610,7 +584,57 @@ overlays are considered only if they are associated with OBJECT.")
      simpler case.  */
   return (Fget_text_property (position, prop, object));
 }
+\f
+DEFUN ("next-char-property-change", Fnext_char_property_change,
+       Snext_char_property_change, 1, 2, 0,
+  "Return the position of next text property or overlay change.\n\
+This scans characters forward from POSITION in OBJECT till it finds\n\
+a change in some text property, or the beginning or end of an overlay,\n\
+and returns the position of that.\n\
+If none is found, the function returns (point-max).\n\
+\n\
+If the optional third argument LIMIT is non-nil, don't search\n\
+past position LIMIT; return LIMIT if nothing is found before LIMIT.")
+  (position, limit)
+     Lisp_Object position, limit;
+{
+  Lisp_Object temp;
 
+  temp = Fnext_overlay_change (position);
+  if (! NILP (limit))
+    {
+      CHECK_NUMBER (limit, 2);
+      if (XINT (limit) < XINT (temp))
+       temp = limit;
+    }
+  return Fnext_property_change (position, Qnil, temp);
+}
+
+DEFUN ("previous-char-property-change", Fprevious_char_property_change,
+       Sprevious_char_property_change, 1, 2, 0,
+  "Return the position of previous text property or overlay change.\n\
+Scans characters backward from POSITION in OBJECT till it finds\n\
+a change in some text property, or the beginning or end of an overlay,\n\
+and returns the position of that.\n\
+If none is found, the function returns (point-max).\n\
+\n\
+If the optional third argument LIMIT is non-nil, don't search\n\
+past position LIMIT; return LIMIT if nothing is found before LIMIT.")
+  (position, limit)
+     Lisp_Object position, limit;
+{
+  Lisp_Object temp;
+
+  temp = Fprevious_overlay_change (position);
+  if (! NILP (limit))
+    {
+      CHECK_NUMBER (limit, 2);
+      if (XINT (limit) > XINT (temp))
+       temp = limit;
+    }
+  return Fprevious_property_change (position, Qnil, temp);
+}
+\f
 DEFUN ("next-property-change", Fnext_property_change,
        Snext_property_change, 1, 3, 0,
   "Return the position of next property change.\n\
@@ -839,7 +863,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
                     - (STRINGP (object))));
   return position;
 }
-
+\f
 /* Callers note, this can GC when OBJECT is a buffer (or nil).  */
 
 DEFUN ("add-text-properties", Fadd_text_properties,
@@ -897,6 +921,9 @@ Return t if any property value actually changed, nil otherwise.")
        }
     }
 
+  if (BUFFERP (object))
+    modify_region (XBUFFER (object), XINT (start), XINT (end));
+
   /* We are at the beginning of interval I, with LEN chars to scan.  */
   for (;;)
     {
@@ -911,11 +938,20 @@ Return t if any property value actually changed, nil otherwise.")
          UNGCPRO;
 
          if (interval_has_all_properties (properties, i))
-           return modified ? Qt : Qnil;
+           {
+             if (BUFFERP (object))
+               signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                    XINT (end) - XINT (start));
+
+             return modified ? Qt : Qnil;
+           }
 
          if (LENGTH (i) == len)
            {
              add_properties (properties, i, object);
+             if (BUFFERP (object))
+               signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                    XINT (end) - XINT (start));
              return Qt;
            }
 
@@ -924,6 +960,9 @@ Return t if any property value actually changed, nil otherwise.")
          i = split_interval_left (unchanged, len);
          copy_properties (unchanged, i);
          add_properties (properties, i, object);
+         if (BUFFERP (object))
+           signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                XINT (end) - XINT (start));
          return Qt;
        }
 
@@ -964,6 +1003,7 @@ is the string or buffer containing the text.")
   register INTERVAL prev_changed = NULL_INTERVAL;
   register int s, len;
   Lisp_Object ostart, oend;
+  int have_modified = 0;
 
   ostart = start;
   oend = end;
@@ -979,6 +1019,9 @@ is the string or buffer containing the text.")
       && XFASTINT (start) == 0
       && XFASTINT (end) == XSTRING (object)->size)
     {
+      if (! XSTRING (object)->intervals)
+       return Qt;
+
       XSTRING (object)->intervals = 0;
       return Qt;
     }
@@ -1005,6 +1048,9 @@ is the string or buffer containing the text.")
   s = XINT (start);
   len = XINT (end) - s;
 
+  if (BUFFERP (object))
+    modify_region (XBUFFER (object), XINT (start), XINT (end));
+
   if (i->position != s)
     {
       unchanged = i;
@@ -1015,13 +1061,23 @@ is the string or buffer containing the text.")
          copy_properties (unchanged, i);
          i = split_interval_left (i, len);
          set_properties (properties, i, object);
+         if (BUFFERP (object))
+           signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                XINT (end) - XINT (start));
+
          return Qt;
        }
 
       set_properties (properties, i, object);
 
       if (LENGTH (i) == len)
-       return Qt;
+       {
+         if (BUFFERP (object))
+           signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                XINT (end) - XINT (start));
+
+         return Qt;
+       }
 
       prev_changed = i;
       len -= LENGTH (i);
@@ -1045,6 +1101,9 @@ is the string or buffer containing the text.")
          set_properties (properties, i, object);
          if (!NULL_INTERVAL_P (prev_changed))
            merge_interval_left (i);
+         if (BUFFERP (object))
+           signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                XINT (end) - XINT (start));
          return Qt;
        }
 
@@ -1062,6 +1121,9 @@ is the string or buffer containing the text.")
       i = next_interval (i);
     }
 
+  if (BUFFERP (object))
+    signal_after_change (XINT (start), XINT (end) - XINT (start),
+                        XINT (end) - XINT (start));
   return Qt;
 }
 
@@ -1112,6 +1174,9 @@ Return t if any property was actually removed, nil otherwise.")
        }
     }
 
+  if (BUFFERP (object))
+    modify_region (XBUFFER (object), XINT (start), XINT (end));
+
   /* We are at the beginning of an interval, with len to scan */
   for (;;)
     {
@@ -1126,6 +1191,9 @@ Return t if any property was actually removed, nil otherwise.")
          if (LENGTH (i) == len)
            {
              remove_properties (properties, i, object);
+             if (BUFFERP (object))
+               signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                    XINT (end) - XINT (start));
              return Qt;
            }
 
@@ -1134,6 +1202,9 @@ Return t if any property was actually removed, nil otherwise.")
          i = split_interval_left (i, len);
          copy_properties (unchanged, i);
          remove_properties (properties, i, object);
+         if (BUFFERP (object))
+           signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                XINT (end) - XINT (start));
          return Qt;
        }
 
@@ -1142,7 +1213,7 @@ Return t if any property was actually removed, nil otherwise.")
       i = next_interval (i);
     }
 }
-
+\f
 DEFUN ("text-property-any", Ftext_property_any,
        Stext_property_any, 4, 5, 0,
   "Check text from START to END for property PROPERTY equalling VALUE.\n\
@@ -1214,7 +1285,7 @@ containing the text.")
     }
   return Qnil;
 }
-
+\f
 #if 0 /* You can use set-text-properties for this.  */
 
 DEFUN ("erase-text-properties", Ferase_text_properties,
@@ -1338,7 +1409,7 @@ is the string or buffer containing the text.")
    Return t if any property value actually changed, nil otherwise.  */
 
 /* Note this can GC when DEST is a buffer.  */
-
+\f
 Lisp_Object
 copy_text_properties (start, end, src, pos, dest, prop)
        Lisp_Object start, end, src, pos, dest, prop;
@@ -1696,6 +1767,8 @@ This also inhibits the use of the `intangible' text property.");
   defsubr (&Stext_properties_at);
   defsubr (&Sget_text_property);
   defsubr (&Sget_char_property);
+  defsubr (&Snext_char_property_change);
+  defsubr (&Sprevious_char_property_change);
   defsubr (&Snext_property_change);
   defsubr (&Snext_single_property_change);
   defsubr (&Sprevious_property_change);