/* Interface code for dealing with text properties.
- Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002
+ Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of GNU Emacs.
}
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,
/* Return the direction from which the text-property PROP would be
inherited by any new text inserted at POS: 1 if it would be
inherited from the char after POS, -1 if it would be inherited from
- the char before POS, and 0 if from neither. */
+ the char before POS, and 0 if from neither.
+ BUFFER can be either a buffer or nil (meaning current buffer). */
int
-text_property_stickiness (prop, pos)
- Lisp_Object prop;
- Lisp_Object pos;
+text_property_stickiness (prop, pos, buffer)
+ Lisp_Object prop, pos, buffer;
{
Lisp_Object prev_pos, front_sticky;
int is_rear_sticky = 1, is_front_sticky = 0; /* defaults */
- if (XINT (pos) > BEGV)
+ if (NILP (buffer))
+ XSETBUFFER (buffer, current_buffer);
+
+ if (XINT (pos) > BUF_BEGV (XBUFFER (buffer)))
/* Consider previous character. */
{
Lisp_Object rear_non_sticky;
prev_pos = make_number (XINT (pos) - 1);
- rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, Qnil);
+ rear_non_sticky = Fget_text_property (prev_pos, Qrear_nonsticky, buffer);
if (!NILP (CONSP (rear_non_sticky)
? Fmemq (prop, rear_non_sticky)
}
/* Consider following character. */
- front_sticky = Fget_text_property (pos, Qfront_sticky, Qnil);
+ front_sticky = Fget_text_property (pos, Qfront_sticky, buffer);
if (EQ (front_sticky, Qt)
|| (CONSP (front_sticky)
disambiguate. Basically, rear-sticky wins, _except_ if the
property that would be inherited has a value of nil, in which case
front-sticky wins. */
- if (XINT (pos) == BEGV || NILP (Fget_text_property (prev_pos, prop, Qnil)))
+ if (XINT (pos) == BUF_BEGV (XBUFFER (buffer))
+ || NILP (Fget_text_property (prev_pos, prop, buffer)))
return 1;
else
return -1;
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);
/* defsubr (&Serase_text_properties); */
/* defsubr (&Scopy_text_properties); */
}
+
+/* arch-tag: 454cdde8-5f86-4faa-a078-101e3625d479
+ (do not change this comment) */