Avoid encoding file names run through dostounix_filename on MS-Windows.
[bpt/emacs.git] / src / textprop.c
index 132c2ff..c1f6e59 100644 (file)
@@ -1,6 +1,6 @@
 /* Interface code for dealing with text properties.
-   Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
-                 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1993-1995, 1997, 1999-2013 Free Software Foundation,
+   Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,16 +18,13 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
-#include <setjmp.h>
+
 #include "lisp.h"
 #include "intervals.h"
+#include "character.h"
 #include "buffer.h"
 #include "window.h"
 
-#ifndef NULL
-#define NULL (void *)0
-#endif
-
 /* Test for membership, allowing for t (actually any non-cons) to mean the
    universal set.  */
 
@@ -48,16 +45,19 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 \f
 /* Types of hooks.  */
-Lisp_Object Qmouse_left;
-Lisp_Object Qmouse_entered;
+static Lisp_Object Qmouse_left;
+static Lisp_Object Qmouse_entered;
 Lisp_Object Qpoint_left;
 Lisp_Object Qpoint_entered;
 Lisp_Object Qcategory;
 Lisp_Object Qlocal_map;
 
 /* Visual properties text (including strings) may have.  */
-Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple;
-Lisp_Object Qinvisible, Qread_only, Qintangible, Qmouse_face;
+static Lisp_Object Qforeground, Qbackground, Qunderline;
+Lisp_Object Qfont;
+static Lisp_Object Qstipple;
+Lisp_Object Qinvisible, Qintangible, Qmouse_face;
+static Lisp_Object Qread_only;
 Lisp_Object Qminibuffer_prompt;
 
 /* Sticky properties */
@@ -68,25 +68,17 @@ Lisp_Object Qfront_sticky, Qrear_nonsticky;
    traversing plists.  */
 #define PLIST_ELT_P(o1, o2) (CONSP (o1) && ((o2)=XCDR (o1), CONSP (o2)))
 
-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
    to be run later by report_interval_modification.  */
-Lisp_Object interval_insert_behind_hooks;
-Lisp_Object interval_insert_in_front_hooks;
-
-static void text_read_only P_ ((Lisp_Object)) NO_RETURN;
+static Lisp_Object interval_insert_behind_hooks;
+static Lisp_Object interval_insert_in_front_hooks;
 
 
 /* Signal a `text-read-only' error.  This function makes it easier
    to capture that error in GDB by putting a breakpoint on it.  */
 
-static void
-text_read_only (propval)
-     Lisp_Object propval;
+static _Noreturn void
+text_read_only (Lisp_Object propval)
 {
   if (STRINGP (propval))
     xsignal1 (Qtext_read_only, propval);
@@ -94,8 +86,18 @@ text_read_only (propval)
   xsignal0 (Qtext_read_only);
 }
 
+/* Prepare to modify the region of BUFFER from START to END.  */
+
+static void
+modify_region (Lisp_Object buffer, Lisp_Object start, Lisp_Object end)
+{
+  struct buffer *buf = XBUFFER (buffer), *old = current_buffer;
+
+  set_buffer_internal (buf);
+  modify_region_1 (XINT (start), XINT (end), true);
+  set_buffer_internal (old);
+}
 
-\f
 /* Extract the interval at the position pointed to by BEGIN from
    OBJECT, a string or buffer.  Additionally, check that the positions
    pointed to by BEGIN and END are within the bounds of OBJECT, and
@@ -114,7 +116,7 @@ text_read_only (propval)
    Fprevious_property_change which call this function with BEGIN == END.
    Handle this case specially.
 
-   If FORCE is soft (0), it's OK to return NULL_INTERVAL.  Otherwise,
+   If FORCE is soft (0), it's OK to return NULL.  Otherwise,
    create an interval tree for OBJECT if one doesn't exist, provided
    the object actually contains text.  In the current design, if there
    is no text, there can be no text properties.  */
@@ -123,12 +125,10 @@ text_read_only (propval)
 #define hard 1
 
 INTERVAL
-validate_interval_range (object, begin, end, force)
-     Lisp_Object object, *begin, *end;
-     int force;
+validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *end, int force)
 {
   register INTERVAL i;
-  int searchpos;
+  ptrdiff_t searchpos;
 
   CHECK_STRING_OR_BUFFER (object);
   CHECK_NUMBER_COERCE_MARKER (*begin);
@@ -137,7 +137,7 @@ validate_interval_range (object, begin, end, force)
   /* If we are asked for a point, but from a subr which operates
      on a range, then return nothing.  */
   if (EQ (*begin, *end) && begin != end)
-    return NULL_INTERVAL;
+    return NULL;
 
   if (XINT (*begin) > XINT (*end))
     {
@@ -154,17 +154,17 @@ validate_interval_range (object, begin, end, force)
       if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end)
            && XINT (*end) <= BUF_ZV (b)))
        args_out_of_range (*begin, *end);
-      i = BUF_INTERVALS (b);
+      i = buffer_intervals (b);
 
       /* If there's no text, there are no properties.  */
       if (BUF_BEGV (b) == BUF_ZV (b))
-       return NULL_INTERVAL;
+       return NULL;
 
       searchpos = XINT (*begin);
     }
   else
     {
-      int len = SCHARS (object);
+      ptrdiff_t len = SCHARS (object);
 
       if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
             && XINT (*end) <= len))
@@ -172,15 +172,15 @@ validate_interval_range (object, begin, end, force)
       XSETFASTINT (*begin, XFASTINT (*begin));
       if (begin != end)
        XSETFASTINT (*end, XFASTINT (*end));
-      i = STRING_INTERVALS (object);
+      i = string_intervals (object);
 
       if (len == 0)
-       return NULL_INTERVAL;
+       return NULL;
 
       searchpos = XINT (*begin);
     }
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return (force ? create_root_interval (object) : i);
 
   return find_interval (i, searchpos);
@@ -191,8 +191,7 @@ validate_interval_range (object, begin, end, force)
    is even numbered and thus suitable as a plist.  */
 
 static Lisp_Object
-validate_plist (list)
-     Lisp_Object list;
+validate_plist (Lisp_Object list)
 {
   if (NILP (list))
     return Qnil;
@@ -218,9 +217,7 @@ validate_plist (list)
    with the same values, of list PLIST.  */
 
 static int
-interval_has_all_properties (plist, i)
-     Lisp_Object plist;
-     INTERVAL i;
+interval_has_all_properties (Lisp_Object plist, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym1;
   register int found;
@@ -240,7 +237,7 @@ interval_has_all_properties (plist, i)
            if (! EQ (Fcar (XCDR (tail1)), Fcar (XCDR (tail2))))
              return 0;
 
-           /* Property has same value on both lists;  go to next one.  */
+           /* Property has same value on both lists; go to next one.  */
            found = 1;
            break;
          }
@@ -255,10 +252,8 @@ interval_has_all_properties (plist, i)
 /* Return nonzero if the plist of interval I has any of the
    properties of PLIST, regardless of their values.  */
 
-static INLINE int
-interval_has_some_properties (plist, i)
-     Lisp_Object plist;
-     INTERVAL i;
+static int
+interval_has_some_properties (Lisp_Object plist, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym;
 
@@ -279,17 +274,15 @@ interval_has_some_properties (plist, i)
 /* Return nonzero if the plist of interval I has any of the
    property names in LIST, regardless of their values.  */
 
-static INLINE int
-interval_has_some_properties_list (list, i)
-     Lisp_Object list;
-     INTERVAL i;
+static int
+interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym;
 
   /* Go through each element of LIST.  */
   for (tail1 = list; CONSP (tail1); tail1 = XCDR (tail1))
     {
-      sym = Fcar (tail1);
+      sym = XCAR (tail1);
 
       /* Go through i's plist, looking for tail1 */
       for (tail2 = i->plist; CONSP (tail2); tail2 = XCDR (XCDR (tail2)))
@@ -305,8 +298,7 @@ interval_has_some_properties_list (list, i)
 /* Return the value of PROP in property-list PLIST, or Qunbound if it
    has none.  */
 static Lisp_Object
-property_value (plist, prop)
-     Lisp_Object plist, prop;
+property_value (Lisp_Object plist, Lisp_Object prop)
 {
   Lisp_Object value;
 
@@ -324,9 +316,7 @@ property_value (plist, prop)
    OBJECT is the string or buffer that INTERVAL belongs to.  */
 
 static void
-set_properties (properties, interval, object)
-     Lisp_Object properties, object;
-     INTERVAL interval;
+set_properties (Lisp_Object properties, INTERVAL interval, Lisp_Object object)
 {
   Lisp_Object sym, value;
 
@@ -359,7 +349,7 @@ set_properties (properties, interval, object)
     }
 
   /* Store new properties.  */
-  interval->plist = Fcopy_sequence (properties);
+  set_interval_plist (interval, Fcopy_sequence (properties));
 }
 
 /* Add the properties of PLIST to the interval I, or set
@@ -372,10 +362,7 @@ set_properties (properties, interval, object)
    are actually added to I's plist) */
 
 static int
-add_properties (plist, i, object)
-     Lisp_Object plist;
-     INTERVAL i;
-     Lisp_Object object;
+add_properties (Lisp_Object plist, INTERVAL i, Lisp_Object object)
 {
   Lisp_Object tail1, tail2, sym1, val1;
   register int changed = 0;
@@ -435,7 +422,7 @@ add_properties (plist, i, object)
              record_property_change (i->position, LENGTH (i),
                                      sym1, Qnil, object);
            }
-         i->plist = Fcons (sym1, Fcons (val1, i->plist));
+         set_interval_plist (i, Fcons (sym1, Fcons (val1, i->plist)));
          changed++;
        }
     }
@@ -451,10 +438,7 @@ add_properties (plist, i, object)
    OBJECT is the string or buffer containing I.  */
 
 static int
-remove_properties (plist, list, i, object)
-     Lisp_Object plist, list;
-     INTERVAL i;
-     Lisp_Object object;
+remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object object)
 {
   register Lisp_Object tail1, tail2, sym, current_plist;
   register int changed = 0;
@@ -511,41 +495,23 @@ remove_properties (plist, list, i, object)
     }
 
   if (changed)
-    i->plist = current_plist;
+    set_interval_plist (i, current_plist);
   return changed;
 }
-
-#if 0
-/* Remove all properties from interval I.  Return non-zero
-   if this changes the interval.  */
-
-static INLINE int
-erase_properties (i)
-     INTERVAL i;
-{
-  if (NILP (i->plist))
-    return 0;
-
-  i->plist = Qnil;
-  return 1;
-}
-#endif
 \f
 /* Returns the interval of POSITION in OBJECT.
    POSITION is BEG-based.  */
 
 INTERVAL
-interval_of (position, object)
-     int position;
-     Lisp_Object object;
+interval_of (ptrdiff_t position, Lisp_Object object)
 {
   register INTERVAL i;
-  int beg, end;
+  ptrdiff_t beg, end;
 
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   else if (EQ (object, Qt))
-    return NULL_INTERVAL;
+    return NULL;
 
   CHECK_STRING_OR_BUFFER (object);
 
@@ -555,19 +521,19 @@ interval_of (position, object)
 
       beg = BUF_BEGV (b);
       end = BUF_ZV (b);
-      i = BUF_INTERVALS (b);
+      i = buffer_intervals (b);
     }
   else
     {
       beg = 0;
       end = SCHARS (object);
-      i = STRING_INTERVALS (object);
+      i = string_intervals (object);
     }
 
   if (!(beg <= position && position <= end))
     args_out_of_range (make_number (position), make_number (position));
-  if (beg == end || NULL_INTERVAL_P (i))
-    return NULL_INTERVAL;
+  if (beg == end || !i)
+    return NULL;
 
   return find_interval (i, position);
 }
@@ -579,8 +545,7 @@ If the optional second argument OBJECT is a buffer (or nil, which means
 the current buffer), POSITION is a buffer position (integer or marker).
 If OBJECT is a string, POSITION is a 0-based index into it.
 If POSITION is at the end of OBJECT, the value is nil.  */)
-     (position, object)
-     Lisp_Object position, object;
+  (Lisp_Object position, Lisp_Object object)
 {
   register INTERVAL i;
 
@@ -588,7 +553,7 @@ If POSITION is at the end of OBJECT, the value is nil.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &position, &position, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
   /* If POSITION is at the end of the interval,
      it means it's the end of OBJECT.
@@ -602,11 +567,10 @@ If POSITION is at the end of OBJECT, the value is nil.  */)
 
 DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0,
        doc: /* Return the value of POSITION's property PROP, in OBJECT.
-OBJECT is optional and defaults to the current buffer.
+OBJECT should be a buffer or a string; if omitted or nil, it defaults
+to the current buffer.
 If POSITION is at the end of OBJECT, the value is nil.  */)
-     (position, prop, object)
-     Lisp_Object position, object;
-     Lisp_Object prop;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object)
 {
   return textget (Ftext_properties_at (position, object), prop);
 }
@@ -623,10 +587,7 @@ If POSITION is at the end of OBJECT, the value is nil.  */)
    window-specific overlays are considered only if they are associated
    with OBJECT. */
 Lisp_Object
-get_char_property_and_overlay (position, prop, object, overlay)
-     Lisp_Object position, object;
-     register Lisp_Object prop;
-     Lisp_Object *overlay;
+get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop, Lisp_Object object, Lisp_Object *overlay)
 {
   struct window *w = 0;
 
@@ -642,7 +603,7 @@ get_char_property_and_overlay (position, prop, object, overlay)
     }
   if (BUFFERP (object))
     {
-      int noverlays;
+      ptrdiff_t noverlays;
       Lisp_Object *overlay_vec;
       struct buffer *obuf = current_buffer;
 
@@ -689,9 +650,7 @@ If OBJECT is a buffer, then overlay properties are considered as well as
 text properties.
 If OBJECT is a window, then that window's buffer is used, but window-specific
 overlays are considered only if they are associated with OBJECT.  */)
-     (position, prop, object)
-     Lisp_Object position, object;
-     register Lisp_Object prop;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object)
 {
   return get_char_property_and_overlay (position, prop, object, 0);
 }
@@ -710,9 +669,7 @@ value is always nil, since strings do not have overlays.  If OBJECT is
 a window, then that window's buffer is used, but window-specific
 overlays are considered only if they are associated with OBJECT.  If
 POSITION is at the end of OBJECT, both car and cdr are nil.  */)
-     (position, prop, object)
-     Lisp_Object position, object;
-     register Lisp_Object prop;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object)
 {
   Lisp_Object overlay;
   Lisp_Object val
@@ -732,8 +689,7 @@ If none is found up to (point-max), the function returns (point-max).
 If the optional second argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.
 LIMIT is a no-op if it is greater than (point-max).  */)
-     (position, limit)
-     Lisp_Object position, limit;
+  (Lisp_Object position, Lisp_Object limit)
 {
   Lisp_Object temp;
 
@@ -758,8 +714,7 @@ If none is found since (point-min), the function returns (point-min).
 If the optional second argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.
 LIMIT is a no-op if it is less than (point-min).  */)
-     (position, limit)
-     Lisp_Object position, limit;
+  (Lisp_Object position, Lisp_Object limit)
 {
   Lisp_Object temp;
 
@@ -791,8 +746,7 @@ If the property is constant all the way to the end of OBJECT, return the
 last valid position in OBJECT.
 If the optional fourth argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
-     (position, prop, object, limit)
-     Lisp_Object prop, position, object, limit;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
 {
   if (STRINGP (object))
     {
@@ -811,14 +765,14 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   else
     {
       Lisp_Object initial_value, value;
-      int count = SPECPDL_INDEX ();
+      ptrdiff_t count = SPECPDL_INDEX ();
 
       if (! NILP (object))
        CHECK_BUFFER (object);
 
       if (BUFFERP (object) && current_buffer != XBUFFER (object))
        {
-         record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+         record_unwind_current_buffer ();
          Fset_buffer (object);
        }
 
@@ -876,8 +830,7 @@ If the property is constant all the way to the start of OBJECT, return the
 first valid position in OBJECT.
 If the optional fourth argument LIMIT is non-nil, don't search back past
 position LIMIT; return LIMIT if nothing is found before reaching LIMIT.  */)
-     (position, prop, object, limit)
-     Lisp_Object prop, position, object, limit;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
 {
   if (STRINGP (object))
     {
@@ -895,14 +848,14 @@ position LIMIT; return LIMIT if nothing is found before reaching LIMIT.  */)
     }
   else
     {
-      int count = SPECPDL_INDEX ();
+      ptrdiff_t count = SPECPDL_INDEX ();
 
       if (! NILP (object))
        CHECK_BUFFER (object);
 
       if (BUFFERP (object) && current_buffer != XBUFFER (object))
        {
-         record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+         record_unwind_current_buffer ();
          Fset_buffer (object);
        }
 
@@ -965,8 +918,7 @@ If the value is non-nil, it is a position greater than POSITION, never equal.
 
 If the optional third argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
-     (position, object, limit)
-     Lisp_Object position, object, limit;
+  (Lisp_Object position, Lisp_Object object, Lisp_Object limit)
 {
   register INTERVAL i, next;
 
@@ -982,12 +934,12 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
      bother checking further intervals.  */
   if (EQ (limit, Qt))
     {
-      if (NULL_INTERVAL_P (i))
+      if (!i)
        next = i;
       else
        next = next_interval (i);
 
-      if (NULL_INTERVAL_P (next))
+      if (!next)
        XSETFASTINT (position, (STRINGP (object)
                                ? SCHARS (object)
                                : BUF_ZV (XBUFFER (object))));
@@ -996,16 +948,16 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
       return position;
     }
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   next = next_interval (i);
 
-  while (!NULL_INTERVAL_P (next) && intervals_equal (i, next)
+  while (next && intervals_equal (i, next)
         && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next)
+  if (!next
       || (next->position
          >= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1017,38 +969,6 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     return make_number (next->position);
 }
 
-/* Return 1 if there's a change in some property between BEG and END.  */
-
-int
-property_change_between_p (beg, end)
-     int beg, end;
-{
-  register INTERVAL i, next;
-  Lisp_Object object, pos;
-
-  XSETBUFFER (object, current_buffer);
-  XSETFASTINT (pos, beg);
-
-  i = validate_interval_range (object, &pos, &pos, soft);
-  if (NULL_INTERVAL_P (i))
-    return 0;
-
-  next = next_interval (i);
-  while (! NULL_INTERVAL_P (next) && intervals_equal (i, next))
-    {
-      next = next_interval (next);
-      if (NULL_INTERVAL_P (next))
-       return 0;
-      if (next->position >= end)
-       return 0;
-    }
-
-  if (NULL_INTERVAL_P (next))
-    return 0;
-
-  return 1;
-}
-
 DEFUN ("next-single-property-change", Fnext_single_property_change,
        Snext_single_property_change, 2, 4, 0,
        doc: /* Return the position of next property change for a specific property.
@@ -1063,8 +983,7 @@ If the value is non-nil, it is a position greater than POSITION, never equal.
 
 If the optional fourth argument LIMIT is non-nil, don't search
 past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
-     (position, prop, object, limit)
-     Lisp_Object position, prop, object, limit;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
 {
   register INTERVAL i, next;
   register Lisp_Object here_val;
@@ -1076,17 +995,17 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   here_val = textget (i->plist, prop);
   next = next_interval (i);
-  while (! NULL_INTERVAL_P (next)
+  while (next
         && EQ (here_val, textget (next->plist, prop))
         && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next)
+  if (!next
       || (next->position
          >= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1111,8 +1030,7 @@ If the value is non-nil, it is a position less than POSITION, never equal.
 
 If the optional third argument LIMIT is non-nil, don't search
 back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
-     (position, object, limit)
-     Lisp_Object position, object, limit;
+  (Lisp_Object position, Lisp_Object object, Lisp_Object limit)
 {
   register INTERVAL i, previous;
 
@@ -1123,7 +1041,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     CHECK_NUMBER_COERCE_MARKER (limit);
 
   i = validate_interval_range (object, &position, &position, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   /* Start with the interval containing the char before point.  */
@@ -1131,12 +1049,12 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     i = previous_interval (i);
 
   previous = previous_interval (i);
-  while (!NULL_INTERVAL_P (previous) && intervals_equal (previous, i)
+  while (previous && intervals_equal (previous, i)
         && (NILP (limit)
             || (previous->position + LENGTH (previous) > XFASTINT (limit))))
     previous = previous_interval (previous);
 
-  if (NULL_INTERVAL_P (previous)
+  if (!previous
       || (previous->position + LENGTH (previous)
          <= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1160,8 +1078,7 @@ If the value is non-nil, it is a position less than POSITION, never equal.
 
 If the optional fourth argument LIMIT is non-nil, don't search
 back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
-     (position, prop, object, limit)
-     Lisp_Object position, prop, object, limit;
+  (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
 {
   register INTERVAL i, previous;
   register Lisp_Object here_val;
@@ -1175,21 +1092,21 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
   i = validate_interval_range (object, &position, &position, soft);
 
   /* Start with the interval containing the char before point.  */
-  if (!NULL_INTERVAL_P (i) && i->position == XFASTINT (position))
+  if (i && i->position == XFASTINT (position))
     i = previous_interval (i);
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return limit;
 
   here_val = textget (i->plist, prop);
   previous = previous_interval (i);
-  while (!NULL_INTERVAL_P (previous)
+  while (previous
         && EQ (here_val, textget (previous->plist, prop))
         && (NILP (limit)
             || (previous->position + LENGTH (previous) > XFASTINT (limit))))
     previous = previous_interval (previous);
 
-  if (NULL_INTERVAL_P (previous)
+  if (!previous
       || (previous->position + LENGTH (previous)
          <= (INTEGERP (limit)
              ? XFASTINT (limit)
@@ -1210,11 +1127,11 @@ OBJECT is a buffer (or nil, which means the current buffer),
 START and END are buffer positions (integers or markers).
 If OBJECT is a string, START and END are 0-based indices into it.
 Return t if any property value actually changed, nil otherwise.  */)
-     (start, end, properties, object)
-     Lisp_Object start, end, properties, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
 {
   register INTERVAL i, unchanged;
-  register int s, len, modified = 0;
+  register ptrdiff_t s, len;
+  register int modified = 0;
   struct gcpro gcpro1;
 
   properties = validate_plist (properties);
@@ -1225,7 +1142,7 @@ Return t if any property value actually changed, nil otherwise.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &start, &end, hard);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   s = XINT (start);
@@ -1243,7 +1160,7 @@ Return t if any property value actually changed, nil otherwise.  */)
          skip it.  */
       if (interval_has_all_properties (properties, i))
        {
-         int got = (LENGTH (i) - (s - i->position));
+         ptrdiff_t got = (LENGTH (i) - (s - i->position));
          if (got >= len)
            RETURN_UNGCPRO (Qnil);
          len -= got;
@@ -1258,13 +1175,12 @@ Return t if any property value actually changed, nil otherwise.  */)
     }
 
   if (BUFFERP (object))
-    modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+    modify_region (object, start, end);
 
   /* We are at the beginning of interval I, with LEN chars to scan.  */
   for (;;)
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1318,8 +1234,7 @@ specify the property to add.
 If the optional fifth argument OBJECT is a buffer (or nil, which means
 the current buffer), START and END are buffer positions (integers or
 markers).  If OBJECT is a string, START and END are 0-based indices into it.  */)
-     (start, end, property, value, object)
-     Lisp_Object start, end, property, value, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
 {
   Fadd_text_properties (start, end,
                        Fcons (property, Fcons (value, Qnil)),
@@ -1336,8 +1251,7 @@ the current buffer), START and END are buffer positions (integers or
 markers).  If OBJECT is a string, START and END are 0-based indices into it.
 If PROPERTIES is nil, the effect is to remove all properties from
 the designated part of OBJECT.  */)
-     (start, end, properties, object)
-     Lisp_Object start, end, properties, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
 {
   return set_text_properties (start, end, properties, object, Qt);
 }
@@ -1353,8 +1267,7 @@ the designated part of OBJECT.  */)
    otherwise.  */
 
 Lisp_Object
-set_text_properties (start, end, properties, object, coherent_change_p)
-     Lisp_Object start, end, properties, object, coherent_change_p;
+set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, Lisp_Object coherent_change_p)
 {
   register INTERVAL i;
   Lisp_Object ostart, oend;
@@ -1373,16 +1286,16 @@ set_text_properties (start, end, properties, object, coherent_change_p)
       && XFASTINT (start) == 0
       && XFASTINT (end) == SCHARS (object))
     {
-      if (! STRING_INTERVALS (object))
+      if (!string_intervals (object))
        return Qnil;
 
-      STRING_SET_INTERVALS (object, NULL_INTERVAL);
+      set_string_intervals (object, NULL);
       return Qt;
     }
 
   i = validate_interval_range (object, &start, &end, soft);
 
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     {
       /* If buffer has no properties, and we want none, return now.  */
       if (NILP (properties))
@@ -1395,12 +1308,12 @@ set_text_properties (start, end, properties, object, coherent_change_p)
 
       i = validate_interval_range (object, &start, &end, hard);
       /* This can return if start == end.  */
-      if (NULL_INTERVAL_P (i))
+      if (!i)
        return Qnil;
     }
 
   if (BUFFERP (object) && !NILP (coherent_change_p))
-    modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+    modify_region (object, start, end);
 
   set_text_properties_1 (start, end, properties, object, i);
 
@@ -1411,33 +1324,32 @@ set_text_properties (start, end, properties, object, coherent_change_p)
 }
 
 /* Replace properties of text from START to END with new list of
-   properties PROPERTIES.  BUFFER is the buffer containing
+   properties PROPERTIES.  OBJECT is the buffer or string 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.
+   You should provide the interval that START is located in as I.
    START and END can be in any order.  */
 
 void
-set_text_properties_1 (start, end, properties, buffer, i)
-     Lisp_Object start, end, properties, buffer;
-     INTERVAL i;
+set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object, INTERVAL i)
 {
-  register INTERVAL prev_changed = NULL_INTERVAL;
-  register int s, len;
+  register INTERVAL prev_changed = NULL;
+  register ptrdiff_t s, len;
   INTERVAL unchanged;
 
-  s = XINT (start);
-  len = XINT (end) - s;
-  if (len == 0)
-    return;
-  if (len < 0)
+  if (XINT (start) < XINT (end))
     {
-      s = s + len;
-      len = - len;
+      s = XINT (start);
+      len = XINT (end) - s;
     }
+  else if (XINT (end) < XINT (start))
+    {
+      s = XINT (end);
+      len = XINT (start) - s;
+    }
+  else
+    return;
 
-  if (i == 0)
-    i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);
+  eassert (i);
 
   if (i->position != s)
     {
@@ -1448,11 +1360,11 @@ set_text_properties_1 (start, end, properties, buffer, i)
        {
          copy_properties (unchanged, i);
          i = split_interval_left (i, len);
-         set_properties (properties, i, buffer);
+         set_properties (properties, i, object);
          return;
        }
 
-      set_properties (properties, i, buffer);
+      set_properties (properties, i, object);
 
       if (LENGTH (i) == len)
        return;
@@ -1462,11 +1374,10 @@ set_text_properties_1 (start, end, properties, buffer, i)
       i = next_interval (i);
     }
 
-  /* We are starting at the beginning of an interval, I */
-  while (len > 0)
+  /* We are starting at the beginning of an interval I.  LEN is positive.  */
+  do
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1476,8 +1387,8 @@ set_text_properties_1 (start, end, properties, buffer, i)
          /* 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, buffer);
-         if (!NULL_INTERVAL_P (prev_changed))
+         set_properties (properties, i, object);
+         if (prev_changed)
            merge_interval_left (i);
          return;
        }
@@ -1487,14 +1398,15 @@ set_text_properties_1 (start, end, properties, buffer, i)
       /* 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, buffer);
-      if (NULL_INTERVAL_P (prev_changed))
+      set_properties (properties, i, object);
+      if (!prev_changed)
        prev_changed = i;
       else
        prev_changed = i = merge_interval_left (i);
 
       i = next_interval (i);
     }
+  while (len > 0);
 }
 
 DEFUN ("remove-text-properties", Fremove_text_properties,
@@ -1509,17 +1421,17 @@ markers).  If OBJECT is a string, START and END are 0-based indices into it.
 Return t if any property was actually removed, nil otherwise.
 
 Use `set-text-properties' if you want to remove all text properties.  */)
-     (start, end, properties, object)
-     Lisp_Object start, end, properties, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object properties, Lisp_Object object)
 {
   register INTERVAL i, unchanged;
-  register int s, len, modified = 0;
+  register ptrdiff_t s, len;
+  register int modified = 0;
 
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   s = XINT (start);
@@ -1531,7 +1443,7 @@ Use `set-text-properties' if you want to remove all text properties.  */)
          it covers the entire region.  */
       if (! interval_has_some_properties (properties, i))
        {
-         int got = (LENGTH (i) - (s - i->position));
+         ptrdiff_t got = (LENGTH (i) - (s - i->position));
          if (got >= len)
            return Qnil;
          len -= got;
@@ -1548,13 +1460,12 @@ Use `set-text-properties' if you want to remove all text properties.  */)
     }
 
   if (BUFFERP (object))
-    modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+    modify_region (object, start, end);
 
   /* We are at the beginning of an interval, with len to scan */
   for (;;)
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
@@ -1595,11 +1506,11 @@ If the optional fourth argument OBJECT is a buffer (or nil, which means
 the current buffer), START and END are buffer positions (integers or
 markers).  If OBJECT is a string, START and END are 0-based indices into it.
 Return t if any property was actually removed, nil otherwise.  */)
-     (start, end, list_of_properties, object)
-     Lisp_Object start, end, list_of_properties, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object list_of_properties, Lisp_Object object)
 {
   register INTERVAL i, unchanged;
-  register int s, len, modified = 0;
+  register ptrdiff_t s, len;
+  register int modified = 0;
   Lisp_Object properties;
   properties = list_of_properties;
 
@@ -1607,7 +1518,7 @@ Return t if any property was actually removed, nil otherwise.  */)
     XSETBUFFER (object, current_buffer);
 
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   s = XINT (start);
@@ -1619,7 +1530,7 @@ Return t if any property was actually removed, nil otherwise.  */)
          it covers the entire region.  */
       if (! interval_has_some_properties_list (properties, i))
        {
-         int got = (LENGTH (i) - (s - i->position));
+         ptrdiff_t got = (LENGTH (i) - (s - i->position));
          if (got >= len)
            return Qnil;
          len -= got;
@@ -1643,50 +1554,51 @@ Return t if any property was actually removed, nil otherwise.  */)
      and we call signal_after_change before returning if modified != 0. */
   for (;;)
     {
-      if (i == 0)
-       abort ();
+      eassert (i != 0);
 
       if (LENGTH (i) >= len)
        {
          if (! interval_has_some_properties_list (properties, i))
-           if (modified)
-             {
-               if (BUFFERP (object))
-                 signal_after_change (XINT (start), XINT (end) - XINT (start),
-                                      XINT (end) - XINT (start));
-               return Qt;
-             }
-           else
-             return Qnil;
-
-         if (LENGTH (i) == len)
+           {
+             if (modified)
+               {
+                 if (BUFFERP (object))
+                   signal_after_change (XINT (start),
+                                        XINT (end) - XINT (start),
+                                        XINT (end) - XINT (start));
+                 return Qt;
+               }
+             else
+               return Qnil;
+           }
+         else if (LENGTH (i) == len)
            {
              if (!modified && BUFFERP (object))
-               modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+               modify_region (object, start, end);
+             remove_properties (Qnil, properties, i, object);
+             if (BUFFERP (object))
+               signal_after_change (XINT (start), XINT (end) - XINT (start),
+                                    XINT (end) - XINT (start));
+             return Qt;
+           }
+         else
+           { /* i has the properties, and goes past the change limit.  */
+             unchanged = i;
+             i = split_interval_left (i, len);
+             copy_properties (unchanged, i);
+             if (!modified && BUFFERP (object))
+               modify_region (object, start, end);
              remove_properties (Qnil, properties, i, object);
              if (BUFFERP (object))
                signal_after_change (XINT (start), XINT (end) - XINT (start),
                                     XINT (end) - XINT (start));
              return Qt;
            }
-
-         /* i has the properties, and goes past the change limit */
-         unchanged = i;
-         i = split_interval_left (i, len);
-         copy_properties (unchanged, i);
-         if (!modified && BUFFERP (object))
-           modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
-         remove_properties (Qnil, properties, i, object);
-         if (BUFFERP (object))
-           signal_after_change (XINT (start), XINT (end) - XINT (start),
-                                XINT (end) - XINT (start));
-         return Qt;
        }
-
       if (interval_has_some_properties_list (properties, i))
        {
          if (!modified && BUFFERP (object))
-           modify_region (XBUFFER (object), XINT (start), XINT (end), 1);
+           modify_region (object, start, end);
          remove_properties (Qnil, properties, i, object);
          modified = 1;
        }
@@ -1697,26 +1609,25 @@ Return t if any property was actually removed, nil otherwise.  */)
 \f
 DEFUN ("text-property-any", Ftext_property_any,
        Stext_property_any, 4, 5, 0,
-       doc: /* Check text from START to END for property PROPERTY equalling VALUE.
+       doc: /* Check text from START to END for property PROPERTY equaling VALUE.
 If so, return the position of the first character whose property PROPERTY
 is `eq' to VALUE.  Otherwise return nil.
 If the optional fifth argument OBJECT is a buffer (or nil, which means
 the current buffer), START and END are buffer positions (integers or
 markers).  If OBJECT is a string, START and END are 0-based indices into it.  */)
-     (start, end, property, value, object)
-     Lisp_Object start, end, property, value, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
 {
   register INTERVAL i;
-  register int e, pos;
+  register ptrdiff_t e, pos;
 
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return (!NILP (value) || EQ (start, end) ? Qnil : start);
   e = XINT (end);
 
-  while (! NULL_INTERVAL_P (i))
+  while (i)
     {
       if (i->position >= e)
        break;
@@ -1734,27 +1645,26 @@ markers).  If OBJECT is a string, START and END are 0-based indices into it.  */
 
 DEFUN ("text-property-not-all", Ftext_property_not_all,
        Stext_property_not_all, 4, 5, 0,
-       doc: /* Check text from START to END for property PROPERTY not equalling VALUE.
+       doc: /* Check text from START to END for property PROPERTY not equaling VALUE.
 If so, return the position of the first character whose property PROPERTY
 is not `eq' to VALUE.  Otherwise, return nil.
 If the optional fifth argument OBJECT is a buffer (or nil, which means
 the current buffer), START and END are buffer positions (integers or
 markers).  If OBJECT is a string, START and END are 0-based indices into it.  */)
-     (start, end, property, value, object)
-     Lisp_Object start, end, property, value, object;
+  (Lisp_Object start, Lisp_Object end, Lisp_Object property, Lisp_Object value, Lisp_Object object)
 {
   register INTERVAL i;
-  register int s, e;
+  register ptrdiff_t s, e;
 
   if (NILP (object))
     XSETBUFFER (object, current_buffer);
   i = validate_interval_range (object, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return (NILP (value) || EQ (start, end)) ? Qnil : start;
   s = XINT (start);
   e = XINT (end);
 
-  while (! NULL_INTERVAL_P (i))
+  while (i)
     {
       if (i->position >= e)
        break;
@@ -1777,15 +1687,18 @@ markers).  If OBJECT is a string, START and END are 0-based indices into it.  */
    BUFFER can be either a buffer or nil (meaning current buffer).  */
 
 int
-text_property_stickiness (prop, pos, buffer)
-     Lisp_Object prop, pos, buffer;
+text_property_stickiness (Lisp_Object prop, Lisp_Object pos, Lisp_Object buffer)
 {
   Lisp_Object prev_pos, front_sticky;
   int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */
+  Lisp_Object defalt = Fassq (prop, Vtext_property_default_nonsticky);
 
   if (NILP (buffer))
     XSETBUFFER (buffer, current_buffer);
 
+  if (CONSP (defalt) && !NILP (XCDR (defalt)))
+    is_rear_sticky = 0;
+
   if (XINT (pos) > BUF_BEGV (XBUFFER (buffer)))
     /* Consider previous character.  */
     {
@@ -1834,15 +1747,9 @@ text_property_stickiness (prop, pos, buffer)
 }
 
 \f
-/* I don't think this is the right interface to export; how often do you
-   want to do something like this, other than when you're copying objects
-   around?
-
-   I think it would be better to have a pair of functions, one which
-   returns the text properties of a region as a list of ranges and
-   plists, and another which applies such a list to another object.  */
+/* Copying properties between objects. */
 
-/* Add properties from SRC to SRC of SRC, starting at POS in DEST.
+/* Add properties from START to END of SRC, starting at POS in DEST.
    SRC and DEST may each refer to strings or buffers.
    Optional sixth argument PROP causes only that property to be copied.
    Properties are copied to DEST as if by `add-text-properties'.
@@ -1851,26 +1758,29 @@ text_property_stickiness (prop, pos, buffer)
 /* Note this can GC when DEST is a buffer.  */
 
 Lisp_Object
-copy_text_properties (start, end, src, pos, dest, prop)
-       Lisp_Object start, end, src, pos, dest, prop;
+copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src, Lisp_Object pos, Lisp_Object dest, Lisp_Object prop)
 {
   INTERVAL i;
   Lisp_Object res;
   Lisp_Object stuff;
   Lisp_Object plist;
-  int s, e, e2, p, len, modified = 0;
+  ptrdiff_t s, e, e2, p, len;
+  int modified = 0;
   struct gcpro gcpro1, gcpro2;
 
   i = validate_interval_range (src, &start, &end, soft);
-  if (NULL_INTERVAL_P (i))
+  if (!i)
     return Qnil;
 
   CHECK_NUMBER_COERCE_MARKER (pos);
   {
     Lisp_Object dest_start, dest_end;
 
+    e = XINT (pos) + (XINT (end) - XINT (start));
+    if (MOST_POSITIVE_FIXNUM < e)
+      args_out_of_range (pos, end);
     dest_start = pos;
-    XSETFASTINT (dest_end, XINT (dest_start) + (XINT (end) - XINT (start)));
+    XSETFASTINT (dest_end, e);
     /* Apply this to a copy of pos; it will try to increment its arguments,
        which we don't want.  */
     validate_interval_range (dest, &dest_start, &dest_end, soft);
@@ -1911,7 +1821,7 @@ copy_text_properties (start, end, src, pos, dest, prop)
        }
 
       i = next_interval (i);
-      if (NULL_INTERVAL_P (i))
+      if (!i)
        break;
 
       p += len;
@@ -1944,8 +1854,7 @@ copy_text_properties (start, end, src, pos, dest, prop)
    doesn't contain text properties between START and END.  */
 
 Lisp_Object
-text_property_list (object, start, end, prop)
-     Lisp_Object object, start, end, prop;
+text_property_list (Lisp_Object object, Lisp_Object start, Lisp_Object end, Lisp_Object prop)
 {
   struct interval *i;
   Lisp_Object result;
@@ -1953,14 +1862,14 @@ text_property_list (object, start, end, prop)
   result = Qnil;
 
   i = validate_interval_range (object, &start, &end, soft);
-  if (!NULL_INTERVAL_P (i))
+  if (i)
     {
-      int s = XINT (start);
-      int e = XINT (end);
+      ptrdiff_t s = XINT (start);
+      ptrdiff_t e = XINT (end);
 
       while (s < e)
        {
-         int interval_end, len;
+         ptrdiff_t interval_end, len;
          Lisp_Object plist;
 
          interval_end = i->position + LENGTH (i);
@@ -1985,7 +1894,7 @@ text_property_list (object, start, end, prop)
                            result);
 
          i = next_interval (i);
-         if (NULL_INTERVAL_P (i))
+         if (!i)
            break;
          s = i->position;
        }
@@ -2002,8 +1911,7 @@ text_property_list (object, start, end, prop)
    non-zero if OBJECT was modified.  */
 
 int
-add_text_properties_from_list (object, list, delta)
-     Lisp_Object object, list, delta;
+add_text_properties_from_list (Lisp_Object object, Lisp_Object list, Lisp_Object delta)
 {
   struct gcpro gcpro1, gcpro2;
   int modified_p = 0;
@@ -2036,11 +1944,10 @@ add_text_properties_from_list (object, list, delta)
    end-points to NEW_END.  */
 
 Lisp_Object
-extend_property_ranges (list, new_end)
-     Lisp_Object list, new_end;
+extend_property_ranges (Lisp_Object list, Lisp_Object new_end)
 {
   Lisp_Object prev = Qnil, head = list;
-  int max = XINT (new_end);
+  ptrdiff_t max = XINT (new_end);
 
   for (; CONSP (list); prev = list, list = XCDR (list))
     {
@@ -2072,8 +1979,7 @@ extend_property_ranges (list, new_end)
 /* Call the modification hook functions in LIST, each with START and END.  */
 
 static void
-call_mod_hooks (list, start, end)
-     Lisp_Object list, start, end;
+call_mod_hooks (Lisp_Object list, Lisp_Object start, Lisp_Object end)
 {
   struct gcpro gcpro1;
   GCPRO1 (list);
@@ -2094,14 +2000,13 @@ call_mod_hooks (list, start, end)
    those hooks in order, with START and END - 1 as arguments.  */
 
 void
-verify_interval_modification (buf, start, end)
-     struct buffer *buf;
-     int start, end;
+verify_interval_modification (struct buffer *buf,
+                             ptrdiff_t start, ptrdiff_t end)
 {
-  register INTERVAL intervals = BUF_INTERVALS (buf);
-  register INTERVAL i;
+  INTERVAL intervals = buffer_intervals (buf);
+  INTERVAL i;
   Lisp_Object hooks;
-  register Lisp_Object prev_mod_hooks;
+  Lisp_Object prev_mod_hooks;
   Lisp_Object mod_hooks;
   struct gcpro gcpro1;
 
@@ -2112,12 +2017,12 @@ verify_interval_modification (buf, start, end)
   interval_insert_behind_hooks = Qnil;
   interval_insert_in_front_hooks = Qnil;
 
-  if (NULL_INTERVAL_P (intervals))
+  if (!intervals)
     return;
 
   if (start > end)
     {
-      int temp = start;
+      ptrdiff_t temp = start;
       start = end;
       end = temp;
     }
@@ -2153,7 +2058,7 @@ verify_interval_modification (buf, start, end)
             indirectly defined via the category property.  */
          if (i != prev)
            {
-             if (! NULL_INTERVAL_P (i))
+             if (i)
                {
                  after = textget (i->plist, Qread_only);
 
@@ -2173,7 +2078,7 @@ verify_interval_modification (buf, start, end)
                    }
                }
 
-             if (! NULL_INTERVAL_P (prev))
+             if (prev)
                {
                  before = textget (prev->plist, Qread_only);
 
@@ -2193,7 +2098,7 @@ verify_interval_modification (buf, start, end)
                    }
                }
            }
-         else if (! NULL_INTERVAL_P (i))
+         else if (i)
            {
              after = textget (i->plist, Qread_only);
 
@@ -2220,10 +2125,10 @@ verify_interval_modification (buf, start, end)
        }
 
       /* Run both insert hooks (just once if they're the same).  */
-      if (!NULL_INTERVAL_P (prev))
+      if (prev)
        interval_insert_behind_hooks
          = textget (prev->plist, Qinsert_behind_hooks);
-      if (!NULL_INTERVAL_P (i))
+      if (i)
        interval_insert_in_front_hooks
          = textget (i->plist, Qinsert_in_front_hooks);
     }
@@ -2251,7 +2156,7 @@ verify_interval_modification (buf, start, end)
          i = next_interval (i);
        }
       /* Keep going thru the interval containing the char before END.  */
-      while (! NULL_INTERVAL_P (i) && i->position < end);
+      while (i && i->position < end);
 
       if (!inhibit_modification_hooks)
        {
@@ -2274,8 +2179,7 @@ verify_interval_modification (buf, start, end)
    so it can indicate the range of inserted text.  */
 
 void
-report_interval_modification (start, end)
-     Lisp_Object start, end;
+report_interval_modification (Lisp_Object start, Lisp_Object end)
 {
   if (! NILP (interval_insert_behind_hooks))
     call_mod_hooks (interval_insert_behind_hooks, start, end);
@@ -2286,15 +2190,15 @@ report_interval_modification (start, end)
 }
 \f
 void
-syms_of_textprop ()
+syms_of_textprop (void)
 {
-  DEFVAR_LISP ("default-text-properties", &Vdefault_text_properties,
+  DEFVAR_LISP ("default-text-properties", Vdefault_text_properties,
               doc: /* Property-list used as default values.
 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,
+  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
@@ -2303,23 +2207,25 @@ 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,
+  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.  */);
   Vinhibit_point_motion_hooks = Qnil;
 
   DEFVAR_LISP ("text-property-default-nonsticky",
-              &Vtext_property_default_nonsticky,
-              doc: /* Alist of properties vs the corresponding non-stickinesses.
+              Vtext_property_default_nonsticky,
+              doc: /* Alist of properties vs the corresponding non-stickiness.
 Each element has the form (PROPERTY . NONSTICKINESS).
 
 If a character in a buffer has PROPERTY, new text inserted adjacent to
 the character doesn't inherit PROPERTY if NONSTICKINESS is non-nil,
 inherits it if NONSTICKINESS is nil.  The `front-sticky' and
 `rear-nonsticky' properties of the character override NONSTICKINESS.  */);
-  /* Text property `syntax-table' should be nonsticky by default.  */
+  /* Text properties `syntax-table'and `display' should be nonsticky
+     by default.  */
   Vtext_property_default_nonsticky
-    = Fcons (Fcons (intern_c_string ("syntax-table"), Qt), Qnil);
+    = Fcons (Fcons (intern_c_string ("syntax-table"), Qt),
+            Fcons (Fcons (intern_c_string ("display"), Qt), Qnil));
 
   staticpro (&interval_insert_behind_hooks);
   staticpro (&interval_insert_in_front_hooks);
@@ -2329,45 +2235,27 @@ inherits it if NONSTICKINESS is nil.  The `front-sticky' and
 
   /* Common attributes one might give text */
 
-  staticpro (&Qforeground);
-  Qforeground = intern_c_string ("foreground");
-  staticpro (&Qbackground);
-  Qbackground = intern_c_string ("background");
-  staticpro (&Qfont);
-  Qfont = intern_c_string ("font");
-  staticpro (&Qstipple);
-  Qstipple = intern_c_string ("stipple");
-  staticpro (&Qunderline);
-  Qunderline = intern_c_string ("underline");
-  staticpro (&Qread_only);
-  Qread_only = intern_c_string ("read-only");
-  staticpro (&Qinvisible);
-  Qinvisible = intern_c_string ("invisible");
-  staticpro (&Qintangible);
-  Qintangible = intern_c_string ("intangible");
-  staticpro (&Qcategory);
-  Qcategory = intern_c_string ("category");
-  staticpro (&Qlocal_map);
-  Qlocal_map = intern_c_string ("local-map");
-  staticpro (&Qfront_sticky);
-  Qfront_sticky = intern_c_string ("front-sticky");
-  staticpro (&Qrear_nonsticky);
-  Qrear_nonsticky = intern_c_string ("rear-nonsticky");
-  staticpro (&Qmouse_face);
-  Qmouse_face = intern_c_string ("mouse-face");
-  staticpro (&Qminibuffer_prompt);
-  Qminibuffer_prompt = intern_c_string ("minibuffer-prompt");
+  DEFSYM (Qforeground, "foreground");
+  DEFSYM (Qbackground, "background");
+  DEFSYM (Qfont, "font");
+  DEFSYM (Qstipple, "stipple");
+  DEFSYM (Qunderline, "underline");
+  DEFSYM (Qread_only, "read-only");
+  DEFSYM (Qinvisible, "invisible");
+  DEFSYM (Qintangible, "intangible");
+  DEFSYM (Qcategory, "category");
+  DEFSYM (Qlocal_map, "local-map");
+  DEFSYM (Qfront_sticky, "front-sticky");
+  DEFSYM (Qrear_nonsticky, "rear-nonsticky");
+  DEFSYM (Qmouse_face, "mouse-face");
+  DEFSYM (Qminibuffer_prompt, "minibuffer-prompt");
 
   /* Properties that text might use to specify certain actions */
 
-  staticpro (&Qmouse_left);
-  Qmouse_left = intern_c_string ("mouse-left");
-  staticpro (&Qmouse_entered);
-  Qmouse_entered = intern_c_string ("mouse-entered");
-  staticpro (&Qpoint_left);
-  Qpoint_left = intern_c_string ("point-left");
-  staticpro (&Qpoint_entered);
-  Qpoint_entered = intern_c_string ("point-entered");
+  DEFSYM (Qmouse_left, "mouse-left");
+  DEFSYM (Qmouse_entered, "mouse-entered");
+  DEFSYM (Qpoint_left, "point-left");
+  DEFSYM (Qpoint_entered, "point-entered");
 
   defsubr (&Stext_properties_at);
   defsubr (&Sget_text_property);
@@ -2388,9 +2276,4 @@ inherits it if NONSTICKINESS is nil.  The `front-sticky' and
   defsubr (&Sremove_list_of_text_properties);
   defsubr (&Stext_property_any);
   defsubr (&Stext_property_not_all);
-/*  defsubr (&Serase_text_properties); */
-/*  defsubr (&Scopy_text_properties); */
 }
-
-/* arch-tag: 454cdde8-5f86-4faa-a078-101e3625d479
-   (do not change this comment) */