/* Interface code for dealing with text properties.
- Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003
- Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003,
+ 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Emacs.
You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
#include <config.h>
#include "lisp.h"
}
if (BUFFERP (object))
{
- int posn = XINT (position);
int noverlays;
- Lisp_Object *overlay_vec, tem;
- int len;
+ Lisp_Object *overlay_vec;
struct buffer *obuf = current_buffer;
set_buffer_temp (XBUFFER (object));
- /* First try with room for 40 overlays. */
- len = 40;
- overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
-
- noverlays = overlays_at (posn, 0, &overlay_vec, &len,
- NULL, NULL, 0);
-
- /* If there are more than 40,
- make enough space for all, and try again. */
- if (noverlays > len)
- {
- len = noverlays;
- overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
- noverlays = overlays_at (posn, 0, &overlay_vec, &len,
- NULL, NULL, 0);
- }
+ GET_OVERLAYS_AT (XINT (position), overlay_vec, noverlays, NULL, 0);
noverlays = sort_overlays (overlay_vec, noverlays, w);
set_buffer_temp (obuf);
/* Now check the overlays in order of decreasing priority. */
while (--noverlays >= 0)
{
- tem = Foverlay_get (overlay_vec[noverlays], prop);
+ Lisp_Object tem = Foverlay_get (overlay_vec[noverlays], prop);
if (!NILP (tem))
{
if (overlay)
{
return get_char_property_and_overlay (position, prop, object, 0);
}
+
+DEFUN ("get-char-property-and-overlay", Fget_char_property_and_overlay,
+ Sget_char_property_and_overlay, 2, 3, 0,
+ doc: /* Like `get-char-property', but with extra overlay information.
+Return a cons whose car is the return value of `get-char-property'
+with the same arguments, that is, the value of POSITION's property
+PROP in OBJECT, and whose cdr is the overlay in which the property was
+found, or nil, if it was found as a text property or not found at all.
+OBJECT is optional and defaults to the current buffer. OBJECT may be
+a string, a buffer or a window. For strings, the cdr of the return
+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 overlay;
+ Lisp_Object val
+ = get_char_property_and_overlay (position, prop, object, &overlay);
+ return Fcons(val, overlay);
+}
+
\f
DEFUN ("next-char-property-change", Fnext_char_property_change,
Snext_char_property_change, 1, 2, 0,
overlay, and returns the position of that.
If none is found, the function returns (point-max).
-If the optional third argument LIMIT is non-nil, don't search
+If the optional second argument LIMIT is non-nil, don't search
past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
(position, limit)
Lisp_Object position, limit;
temp = Fnext_overlay_change (position);
if (! NILP (limit))
{
- CHECK_NUMBER (limit);
+ CHECK_NUMBER_COERCE_MARKER (limit);
if (XINT (limit) < XINT (temp))
temp = limit;
}
overlay, and returns the position of that.
If none is found, the function returns (point-max).
-If the optional third argument LIMIT is non-nil, don't search
+If the optional second argument LIMIT is non-nil, don't search
past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
(position, limit)
Lisp_Object position, limit;
temp = Fprevious_overlay_change (position);
if (! NILP (limit))
{
- CHECK_NUMBER (limit);
+ CHECK_NUMBER_COERCE_MARKER (limit);
if (XINT (limit) > XINT (temp))
temp = limit;
}
if (NILP (limit))
position = make_number (SCHARS (object));
else
- position = limit;
+ {
+ CHECK_NUMBER (limit);
+ position = limit;
+ }
}
}
else
Fset_buffer (object);
}
+ CHECK_NUMBER_COERCE_MARKER (position);
+
initial_value = Fget_char_property (position, prop, object);
if (NILP (limit))
if (NILP (limit))
position = make_number (SCHARS (object));
else
- position = limit;
+ {
+ CHECK_NUMBER (limit);
+ position = limit;
+ }
}
}
else
Fset_buffer (object);
}
+ CHECK_NUMBER_COERCE_MARKER (position);
+
if (NILP (limit))
XSETFASTINT (limit, BUF_BEGV (current_buffer));
else
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 overrides NONSTICKINESS. */);
- Vtext_property_default_nonsticky = Qnil;
+ /* Text property `syntax-table' should be nonsticky by default. */
+ Vtext_property_default_nonsticky
+ = Fcons (Fcons (intern ("syntax-table"), Qt), Qnil);
staticpro (&interval_insert_behind_hooks);
staticpro (&interval_insert_in_front_hooks);
defsubr (&Stext_properties_at);
defsubr (&Sget_text_property);
defsubr (&Sget_char_property);
+ defsubr (&Sget_char_property_and_overlay);
defsubr (&Snext_char_property_change);
defsubr (&Sprevious_char_property_change);
defsubr (&Snext_single_char_property_change);