Fringe cleanup.
[bpt/emacs.git] / src / textprop.c
index f49d670..c56db05 100644 (file)
@@ -123,9 +123,9 @@ validate_interval_range (object, begin, end, force)
   register INTERVAL i;
   int searchpos;
 
-  CHECK_STRING_OR_BUFFER (object, 0);
-  CHECK_NUMBER_COERCE_MARKER (*begin, 0);
-  CHECK_NUMBER_COERCE_MARKER (*end, 0);
+  CHECK_STRING_OR_BUFFER (object);
+  CHECK_NUMBER_COERCE_MARKER (*begin);
+  CHECK_NUMBER_COERCE_MARKER (*end);
 
   /* If we are asked for a point, but from a subr which operates
      on a range, then return nothing.  */
@@ -505,7 +505,7 @@ interval_of (position, object)
   else if (EQ (object, Qt))
     return NULL_INTERVAL;
 
-  CHECK_STRING_OR_BUFFER (object, 0);
+  CHECK_STRING_OR_BUFFER (object);
 
   if (BUFFERP (object))
     {
@@ -589,7 +589,7 @@ get_char_property_and_overlay (position, prop, object, overlay)
 {
   struct window *w = 0;
 
-  CHECK_NUMBER_COERCE_MARKER (position, 0);
+  CHECK_NUMBER_COERCE_MARKER (position);
 
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
@@ -655,6 +655,7 @@ get_char_property_and_overlay (position, prop, object, overlay)
 
 DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
        doc: /* Return the value of POSITION's property PROP, in OBJECT.
+Both overlay properties and text properties are checked.
 OBJECT is optional and defaults to the current buffer.
 If POSITION is at the end of OBJECT, the value is nil.
 If OBJECT is a buffer, then overlay properties are considered as well as
@@ -686,7 +687,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   temp = Fnext_overlay_change (position);
   if (! NILP (limit))
     {
-      CHECK_NUMBER (limit, 2);
+      CHECK_NUMBER (limit);
       if (XINT (limit) < XINT (temp))
        temp = limit;
     }
@@ -711,7 +712,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   temp = Fprevious_overlay_change (position);
   if (! NILP (limit))
     {
-      CHECK_NUMBER (limit, 2);
+      CHECK_NUMBER (limit);
       if (XINT (limit) > XINT (temp))
        temp = limit;
     }
@@ -750,7 +751,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       int count = specpdl_ptr - specpdl;
 
       if (! NILP (object))
-       CHECK_BUFFER (object, 0);
+       CHECK_BUFFER (object);
       
       if (BUFFERP (object) && current_buffer != XBUFFER (object))
        {
@@ -763,7 +764,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       if (NILP (limit))
        XSETFASTINT (limit, BUF_ZV (current_buffer));
       else
-       CHECK_NUMBER_COERCE_MARKER (limit, 0);
+       CHECK_NUMBER_COERCE_MARKER (limit);
 
       for (;;)
        {
@@ -815,7 +816,7 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       int count = specpdl_ptr - specpdl;
 
       if (! NILP (object))
-       CHECK_BUFFER (object, 0);
+       CHECK_BUFFER (object);
       
       if (BUFFERP (object) && current_buffer != XBUFFER (object))
        {
@@ -826,7 +827,7 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       if (NILP (limit))
        XSETFASTINT (limit, BUF_BEGV (current_buffer));
       else
-       CHECK_NUMBER_COERCE_MARKER (limit, 0);
+       CHECK_NUMBER_COERCE_MARKER (limit);
 
       if (XFASTINT (position) <= XFASTINT (limit))
        position = limit;
@@ -883,7 +884,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     XSETBUFFER (object, current_buffer);
 
   if (! NILP (limit) && ! EQ (limit, Qt))
-    CHECK_NUMBER_COERCE_MARKER (limit, 0);
+    CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
 
@@ -977,7 +978,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     XSETBUFFER (object, current_buffer);
 
   if (!NILP (limit))
-    CHECK_NUMBER_COERCE_MARKER (limit, 0);
+    CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
   if (NULL_INTERVAL_P (i))
@@ -1018,7 +1019,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     XSETBUFFER (object, current_buffer);
 
   if (!NILP (limit))
-    CHECK_NUMBER_COERCE_MARKER (limit, 0);
+    CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
   if (NULL_INTERVAL_P (i))
@@ -1064,7 +1065,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     XSETBUFFER (object, current_buffer);
 
   if (!NILP (limit))
-    CHECK_NUMBER_COERCE_MARKER (limit, 0);
+    CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
 
@@ -1289,12 +1290,37 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
        return Qnil;
     }
 
-  s = XINT (start);
-  len = XINT (end) - s;
-
   if (BUFFERP (object))
     modify_region (XBUFFER (object), XINT (start), XINT (end));
 
+  set_text_properties_1 (start, end, properties, object, i);
+
+  if (BUFFERP (object) && !NILP (signal_after_change_p))
+    signal_after_change (XINT (start), XINT (end) - XINT (start),
+                        XINT (end) - XINT (start));
+  return Qt;
+}
+
+/* Replace properties of text from START to END with new list of
+   properties PROPERTIES.  BUFFER is the buffer containing
+   the text.  This does not obey any hooks.
+   You can provide the interval that START is located in as I,
+   or pass NULL for I and this function will find it.  */
+
+void
+set_text_properties_1 (start, end, properties, buffer, i)
+     Lisp_Object start, end, properties, buffer;
+     INTERVAL i;
+{
+  register INTERVAL prev_changed = NULL_INTERVAL;
+  register int s, len;
+  INTERVAL unchanged;
+
+  s = XINT (start);
+  len = XINT (end) - s;
+  if (i == 0)
+    i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);
+
   if (i->position != s)
     {
       unchanged = i;
@@ -1304,24 +1330,14 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
        {
          copy_properties (unchanged, i);
          i = split_interval_left (i, len);
-         set_properties (properties, i, object);
-         if (BUFFERP (object) && !NILP (signal_after_change_p))
-           signal_after_change (XINT (start), XINT (end) - XINT (start),
-                                XINT (end) - XINT (start));
-
-         return Qt;
+         set_properties (properties, i, buffer);
+         return;
        }
 
-      set_properties (properties, i, object);
+      set_properties (properties, i, buffer);
 
       if (LENGTH (i) == len)
-       {
-         if (BUFFERP (object) && !NILP (signal_after_change_p))
-           signal_after_change (XINT (start), XINT (end) - XINT (start),
-                                XINT (end) - XINT (start));
-
-         return Qt;
-       }
+       return;
 
       prev_changed = i;
       len -= LENGTH (i);
@@ -1342,13 +1358,10 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
          /* We have to call set_properties even if we are going to
             merge the intervals, so as to make the undo records
             and cause redisplay to happen.  */
-         set_properties (properties, i, object);
+         set_properties (properties, i, buffer);
          if (!NULL_INTERVAL_P (prev_changed))
            merge_interval_left (i);
-         if (BUFFERP (object) && !NILP (signal_after_change_p))
-           signal_after_change (XINT (start), XINT (end) - XINT (start),
-                                XINT (end) - XINT (start));
-         return Qt;
+         return;
        }
 
       len -= LENGTH (i);
@@ -1356,7 +1369,7 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
       /* We have to call set_properties even if we are going to
         merge the intervals, so as to make the undo records
         and cause redisplay to happen.  */
-      set_properties (properties, i, object);
+      set_properties (properties, i, buffer);
       if (NULL_INTERVAL_P (prev_changed))
        prev_changed = i;
       else
@@ -1364,11 +1377,6 @@ set_text_properties (start, end, properties, object, signal_after_change_p)
 
       i = next_interval (i);
     }
-
-  if (BUFFERP (object) && !NILP (signal_after_change_p))
-    signal_after_change (XINT (start), XINT (end) - XINT (start),
-                        XINT (end) - XINT (start));
-  return Qt;
 }
 
 DEFUN ("remove-text-properties", Fremove_text_properties,
@@ -1561,7 +1569,7 @@ copy_text_properties (start, end, src, pos, dest, prop)
   if (NULL_INTERVAL_P (i))
     return Qnil;
 
-  CHECK_NUMBER_COERCE_MARKER (pos, 0);
+  CHECK_NUMBER_COERCE_MARKER (pos);
   {
     Lisp_Object dest_start, dest_end;