Fix parallel "make install" on MS-Windows.
[bpt/emacs.git] / src / textprop.c
index cd89efe..688b32e 100644 (file)
@@ -1,5 +1,5 @@
 /* Interface code for dealing with text properties.
-   Copyright (C) 1993-1995, 1997, 1999-2011 Free Software Foundation, Inc.
+   Copyright (C) 1993-1995, 1997, 1999-2012 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -47,16 +47,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 */
@@ -69,10 +72,12 @@ Lisp_Object Qfront_sticky, Qrear_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 Lisp_Object interval_insert_behind_hooks;
+static Lisp_Object interval_insert_in_front_hooks;
 
 static void text_read_only (Lisp_Object) NO_RETURN;
+static Lisp_Object Fprevious_property_change (Lisp_Object, Lisp_Object,
+                                             Lisp_Object);
 
 
 /* Signal a `text-read-only' error.  This function makes it easier
@@ -228,7 +233,7 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL 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;
          }
@@ -243,7 +248,7 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL i)
 /* Return nonzero if the plist of interval I has any of the
    properties of PLIST, regardless of their values.  */
 
-static INLINE int
+static inline int
 interval_has_some_properties (Lisp_Object plist, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym;
@@ -265,7 +270,7 @@ interval_has_some_properties (Lisp_Object plist, INTERVAL i)
 /* Return nonzero if the plist of interval I has any of the
    property names in LIST, regardless of their values.  */
 
-static INLINE int
+static inline int
 interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
 {
   register Lisp_Object tail1, tail2, sym;
@@ -494,7 +499,7 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object
 /* Remove all properties from interval I.  Return non-zero
    if this changes the interval.  */
 
-static INLINE int
+static inline int
 erase_properties (INTERVAL i)
 {
   if (NILP (i->plist))
@@ -509,7 +514,7 @@ erase_properties (INTERVAL i)
    POSITION is BEG-based.  */
 
 INTERVAL
-interval_of (int position, Lisp_Object object)
+interval_of (EMACS_INT position, Lisp_Object object)
 {
   register INTERVAL i;
   EMACS_INT beg, end;
@@ -608,7 +613,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
     }
   if (BUFFERP (object))
     {
-      int noverlays;
+      ptrdiff_t noverlays;
       Lisp_Object *overlay_vec;
       struct buffer *obuf = current_buffer;
 
@@ -833,8 +838,8 @@ In a buffer, it runs to (point-min), and the value cannot be less than that.
 The property values are compared with `eq'.
 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 LIMIT.  */)
+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.  */)
   (Lisp_Object position, Lisp_Object prop, Lisp_Object object, Lisp_Object limit)
 {
   if (STRINGP (object))
@@ -1343,15 +1348,18 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
   register EMACS_INT s, len;
   INTERVAL unchanged;
 
-  s = XINT (start);
-  len = XINT (end) - s;
-  if (len == 0)
-    return;
-  if (len < 0)
+  if (XINT (start) < XINT (end))
+    {
+      s = XINT (start);
+      len = XINT (end) - s;
+    }
+  else if (XINT (end) < XINT (start))
     {
-      s = s + len;
-      len = - len;
+      s = XINT (end);
+      len = XINT (start) - s;
     }
+  else
+    return;
 
   if (i == 0)
     i = find_interval (BUF_INTERVALS (XBUFFER (buffer)), s);
@@ -1379,8 +1387,8 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
       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 ();
@@ -1412,6 +1420,7 @@ set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object propertie
 
       i = next_interval (i);
     }
+  while (len > 0);
 }
 
 DEFUN ("remove-text-properties", Fremove_text_properties,
@@ -1616,7 +1625,7 @@ 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
@@ -1652,7 +1661,7 @@ 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
@@ -1698,10 +1707,14 @@ 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.  */
     {
@@ -1750,15 +1763,9 @@ text_property_stickiness (Lisp_Object prop, Lisp_Object pos, Lisp_Object 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'.
@@ -2006,7 +2013,8 @@ call_mod_hooks (Lisp_Object list, Lisp_Object start, Lisp_Object end)
    those hooks in order, with START and END - 1 as arguments.  */
 
 void
-verify_interval_modification (struct buffer *buf, int start, int end)
+verify_interval_modification (struct buffer *buf,
+                             EMACS_INT start, EMACS_INT end)
 {
   register INTERVAL intervals = BUF_INTERVALS (buf);
   register INTERVAL i;
@@ -2219,16 +2227,18 @@ This also inhibits the use of the `intangible' text property.  */);
 
   DEFVAR_LISP ("text-property-default-nonsticky",
               Vtext_property_default_nonsticky,
-              doc: /* Alist of properties vs the corresponding non-stickinesses.
+              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);
@@ -2238,45 +2248,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);
@@ -2297,6 +2289,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); */
 }