Declare Lisp_Object Q* variables to be 'static' if not exproted.
[bpt/emacs.git] / src / textprop.c
index 88e869b..b3bb064 100644 (file)
@@ -1,6 +1,5 @@
 /* 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 Free Software Foundation, Inc.
+   Copyright (C) 1993-1995, 1997, 1999-2011 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -48,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 */
@@ -68,17 +70,13 @@ 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 (Lisp_Object) NO_RETURN;
+INFUN (Fprevious_property_change, 3);
 
 
 /* Signal a `text-read-only' error.  This function makes it easier
@@ -501,8 +499,7 @@ remove_properties (Lisp_Object plist, Lisp_Object list, INTERVAL i, Lisp_Object
    if this changes the interval.  */
 
 static INLINE int
-erase_properties (i)
-     INTERVAL i;
+erase_properties (INTERVAL i)
 {
   if (NILP (i->plist))
     return 0;
@@ -551,7 +548,7 @@ interval_of (int position, Lisp_Object object)
   return find_interval (i, position);
 }
 \f
-DEFUN ("text-properties-at", Ftext_properties_at,
+DEFUE ("text-properties-at", Ftext_properties_at,
        Stext_properties_at, 1, 2, 0,
        doc: /* Return the list of properties of the character at POSITION in OBJECT.
 If the optional second argument OBJECT is a buffer (or nil, which means
@@ -578,7 +575,7 @@ If POSITION is at the end of OBJECT, the value is nil.  */)
   return i->plist;
 }
 
-DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0,
+DEFUE ("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.
 If POSITION is at the end of OBJECT, the value is nil.  */)
@@ -653,7 +650,7 @@ get_char_property_and_overlay (Lisp_Object position, register Lisp_Object prop,
   return Fget_text_property (position, prop, object);
 }
 
-DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
+DEFUE ("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.
@@ -690,7 +687,7 @@ POSITION is at the end of OBJECT, both car and cdr are nil.  */)
 }
 
 \f
-DEFUN ("next-char-property-change", Fnext_char_property_change,
+DEFUE ("next-char-property-change", Fnext_char_property_change,
        Snext_char_property_change, 1, 2, 0,
        doc: /* Return the position of next text property or overlay change.
 This scans characters forward in the current buffer from POSITION till
@@ -715,7 +712,7 @@ LIMIT is a no-op if it is greater than (point-max).  */)
   return Fnext_property_change (position, Qnil, temp);
 }
 
-DEFUN ("previous-char-property-change", Fprevious_char_property_change,
+DEFUE ("previous-char-property-change", Fprevious_char_property_change,
        Sprevious_char_property_change, 1, 2, 0,
        doc: /* Return the position of previous text property or overlay change.
 Scans characters backward in the current buffer from POSITION till it
@@ -741,7 +738,7 @@ LIMIT is a no-op if it is less than (point-min).  */)
 }
 
 
-DEFUN ("next-single-char-property-change", Fnext_single_char_property_change,
+DEFUE ("next-single-char-property-change", Fnext_single_char_property_change,
        Snext_single_char_property_change, 2, 4, 0,
        doc: /* Return the position of next text property or overlay change for a specific property.
 Scans characters forward from POSITION till it finds
@@ -824,7 +821,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   return position;
 }
 
-DEFUN ("previous-single-char-property-change",
+DEFUE ("previous-single-char-property-change",
        Fprevious_single_char_property_change,
        Sprevious_single_char_property_change, 2, 4, 0,
        doc: /* Return the position of previous text property or overlay change for a specific property.
@@ -917,7 +914,7 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
   return position;
 }
 \f
-DEFUN ("next-property-change", Fnext_property_change,
+DEFUE ("next-property-change", Fnext_property_change,
        Snext_property_change, 1, 3, 0,
        doc: /* Return the position of next property change.
 Scans characters forward from POSITION in OBJECT till it finds
@@ -981,38 +978,7 @@ 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 (EMACS_INT beg, EMACS_INT 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,
+DEFUE ("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.
 Scans characters forward from POSITION till it finds
@@ -1060,7 +1026,7 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT.  */)
     return make_number (next->position);
 }
 
-DEFUN ("previous-property-change", Fprevious_property_change,
+DEFUE ("previous-property-change", Fprevious_property_change,
        Sprevious_property_change, 1, 3, 0,
        doc: /* Return the position of previous property change.
 Scans characters backwards from POSITION in OBJECT till it finds
@@ -1107,7 +1073,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
     return make_number (previous->position + LENGTH (previous));
 }
 
-DEFUN ("previous-single-property-change", Fprevious_single_property_change,
+DEFUE ("previous-single-property-change", Fprevious_single_property_change,
        Sprevious_single_property_change, 2, 4, 0,
        doc: /* Return the position of previous property change for a specific property.
 Scans characters backward from POSITION till it finds
@@ -1161,7 +1127,7 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.  */)
 \f
 /* Callers note, this can GC when OBJECT is a buffer (or nil).  */
 
-DEFUN ("add-text-properties", Fadd_text_properties,
+DEFUE ("add-text-properties", Fadd_text_properties,
        Sadd_text_properties, 3, 4, 0,
        doc: /* Add properties to the text from START to END.
 The third argument PROPERTIES is a property list
@@ -1270,7 +1236,7 @@ Return t if any property value actually changed, nil otherwise.  */)
 
 /* Callers note, this can GC when OBJECT is a buffer (or nil).  */
 
-DEFUN ("put-text-property", Fput_text_property,
+DEFUE ("put-text-property", Fput_text_property,
        Sput_text_property, 4, 5, 0,
        doc: /* Set one property of the text from START to END.
 The third and fourth arguments PROPERTY and VALUE
@@ -1286,7 +1252,7 @@ markers).  If OBJECT is a string, START and END are 0-based indices into it.  */
   return Qnil;
 }
 
-DEFUN ("set-text-properties", Fset_text_properties,
+DEFUE ("set-text-properties", Fset_text_properties,
        Sset_text_properties, 3, 4, 0,
        doc: /* Completely replace properties of text from START to END.
 The third argument PROPERTIES is the new property list.
@@ -1417,8 +1383,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 ();
@@ -1450,9 +1416,10 @@ 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,
+DEFUE ("remove-text-properties", Fremove_text_properties,
        Sremove_text_properties, 3, 4, 0,
        doc: /* Remove some properties from text from START to END.
 The third argument PROPERTIES is a property list
@@ -1542,7 +1509,7 @@ Use `set-text-properties' if you want to remove all text properties.  */)
     }
 }
 
-DEFUN ("remove-list-of-text-properties", Fremove_list_of_text_properties,
+DEFUE ("remove-list-of-text-properties", Fremove_list_of_text_properties,
        Sremove_list_of_text_properties, 3, 4, 0,
        doc: /* Remove some properties from text from START to END.
 The third argument LIST-OF-PROPERTIES is a list of property names to remove.
@@ -1604,17 +1571,19 @@ Return t if any property was actually removed, nil otherwise.  */)
       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);
@@ -1624,20 +1593,20 @@ Return t if any property was actually removed, nil otherwise.  */)
                                     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;
+         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 (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))
@@ -1650,7 +1619,7 @@ Return t if any property was actually removed, nil otherwise.  */)
     }
 }
 \f
-DEFUN ("text-property-any", Ftext_property_any,
+DEFUE ("text-property-any", Ftext_property_any,
        Stext_property_any, 4, 5, 0,
        doc: /* Check text from START to END for property PROPERTY equalling VALUE.
 If so, return the position of the first character whose property PROPERTY
@@ -2233,13 +2202,13 @@ report_interval_modification (Lisp_Object start, Lisp_Object end)
 void
 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
@@ -2248,13 +2217,13 @@ 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,
+              Vtext_property_default_nonsticky,
               doc: /* Alist of properties vs the corresponding non-stickinesses.
 Each element has the form (PROPERTY . NONSTICKINESS).
 
@@ -2336,6 +2305,3 @@ inherits it if NONSTICKINESS is nil.  The `front-sticky' and
 /*  defsubr (&Serase_text_properties); */
 /*  defsubr (&Scopy_text_properties); */
 }
-
-/* arch-tag: 454cdde8-5f86-4faa-a078-101e3625d479
-   (do not change this comment) */