1 /* Interface code for dealing with text properties.
2 Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 #include "intervals.h"
28 #define NULL (void *)0
31 /* Test for membership, allowing for t (actually any non-cons) to mean the
34 #define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set))
37 /* NOTES: previous- and next- property change will have to skip
38 zero-length intervals if they are implemented. This could be done
39 inside next_interval and previous_interval.
41 set_properties needs to deal with the interval property cache.
43 It is assumed that for any interval plist, a property appears
44 only once on the list. Although some code i.e., remove_properties,
45 handles the more general case, the uniqueness of properties is
46 necessary for the system to remain consistent. This requirement
47 is enforced by the subrs installing properties onto the intervals. */
49 /* The rest of the file is within this conditional */
50 #ifdef USE_TEXT_PROPERTIES
53 Lisp_Object Qmouse_left
;
54 Lisp_Object Qmouse_entered
;
55 Lisp_Object Qpoint_left
;
56 Lisp_Object Qpoint_entered
;
57 Lisp_Object Qcategory
;
58 Lisp_Object Qlocal_map
;
60 /* Visual properties text (including strings) may have. */
61 Lisp_Object Qforeground
, Qbackground
, Qfont
, Qunderline
, Qstipple
;
62 Lisp_Object Qinvisible
, Qread_only
, Qintangible
;
64 /* Sticky properties */
65 Lisp_Object Qfront_sticky
, Qrear_nonsticky
;
67 /* If o1 is a cons whose cdr is a cons, return non-zero and set o2 to
68 the o1's cdr. Otherwise, return zero. This is handy for
70 #define PLIST_ELT_P(o1, o2) (CONSP (o1) && ((o2)=XCONS (o1)->cdr, CONSP (o2)))
72 Lisp_Object Vinhibit_point_motion_hooks
;
73 Lisp_Object Vdefault_text_properties
;
75 /* verify_interval_modification saves insertion hooks here
76 to be run later by report_interval_modification. */
77 Lisp_Object interval_insert_behind_hooks
;
78 Lisp_Object interval_insert_in_front_hooks
;
80 /* Extract the interval at the position pointed to by BEGIN from
81 OBJECT, a string or buffer. Additionally, check that the positions
82 pointed to by BEGIN and END are within the bounds of OBJECT, and
83 reverse them if *BEGIN is greater than *END. The objects pointed
84 to by BEGIN and END may be integers or markers; if the latter, they
85 are coerced to integers.
87 When OBJECT is a string, we increment *BEGIN and *END
88 to make them origin-one.
90 Note that buffer points don't correspond to interval indices.
91 For example, point-max is 1 greater than the index of the last
92 character. This difference is handled in the caller, which uses
93 the validated points to determine a length, and operates on that.
94 Exceptions are Ftext_properties_at, Fnext_property_change, and
95 Fprevious_property_change which call this function with BEGIN == END.
96 Handle this case specially.
98 If FORCE is soft (0), it's OK to return NULL_INTERVAL. Otherwise,
99 create an interval tree for OBJECT if one doesn't exist, provided
100 the object actually contains text. In the current design, if there
101 is no text, there can be no text properties. */
107 validate_interval_range (object
, begin
, end
, force
)
108 Lisp_Object object
, *begin
, *end
;
114 CHECK_STRING_OR_BUFFER (object
, 0);
115 CHECK_NUMBER_COERCE_MARKER (*begin
, 0);
116 CHECK_NUMBER_COERCE_MARKER (*end
, 0);
118 /* If we are asked for a point, but from a subr which operates
119 on a range, then return nothing. */
120 if (EQ (*begin
, *end
) && begin
!= end
)
121 return NULL_INTERVAL
;
123 if (XINT (*begin
) > XINT (*end
))
131 if (BUFFERP (object
))
133 register struct buffer
*b
= XBUFFER (object
);
135 if (!(BUF_BEGV (b
) <= XINT (*begin
) && XINT (*begin
) <= XINT (*end
)
136 && XINT (*end
) <= BUF_ZV (b
)))
137 args_out_of_range (*begin
, *end
);
138 i
= BUF_INTERVALS (b
);
140 /* If there's no text, there are no properties. */
141 if (BUF_BEGV (b
) == BUF_ZV (b
))
142 return NULL_INTERVAL
;
144 searchpos
= XINT (*begin
);
148 register struct Lisp_String
*s
= XSTRING (object
);
150 if (! (0 <= XINT (*begin
) && XINT (*begin
) <= XINT (*end
)
151 && XINT (*end
) <= s
->size
))
152 args_out_of_range (*begin
, *end
);
153 /* User-level Positions in strings start with 0,
154 but the interval code always wants positions starting with 1. */
155 XSETFASTINT (*begin
, XFASTINT (*begin
) + 1);
157 XSETFASTINT (*end
, XFASTINT (*end
) + 1);
161 return NULL_INTERVAL
;
163 searchpos
= XINT (*begin
);
166 if (NULL_INTERVAL_P (i
))
167 return (force
? create_root_interval (object
) : i
);
169 return find_interval (i
, searchpos
);
172 /* Validate LIST as a property list. If LIST is not a list, then
173 make one consisting of (LIST nil). Otherwise, verify that LIST
174 is even numbered and thus suitable as a plist. */
177 validate_plist (list
)
186 register Lisp_Object tail
;
187 for (i
= 0, tail
= list
; !NILP (tail
); i
++)
193 error ("Odd length text property list");
197 return Fcons (list
, Fcons (Qnil
, Qnil
));
200 /* Return nonzero if interval I has all the properties,
201 with the same values, of list PLIST. */
204 interval_has_all_properties (plist
, i
)
208 register Lisp_Object tail1
, tail2
, sym1
, sym2
;
211 /* Go through each element of PLIST. */
212 for (tail1
= plist
; ! NILP (tail1
); tail1
= Fcdr (Fcdr (tail1
)))
217 /* Go through I's plist, looking for sym1 */
218 for (tail2
= i
->plist
; ! NILP (tail2
); tail2
= Fcdr (Fcdr (tail2
)))
219 if (EQ (sym1
, Fcar (tail2
)))
221 /* Found the same property on both lists. If the
222 values are unequal, return zero. */
223 if (! EQ (Fcar (Fcdr (tail1
)), Fcar (Fcdr (tail2
))))
226 /* Property has same value on both lists; go to next one. */
238 /* Return nonzero if the plist of interval I has any of the
239 properties of PLIST, regardless of their values. */
242 interval_has_some_properties (plist
, i
)
246 register Lisp_Object tail1
, tail2
, sym
;
248 /* Go through each element of PLIST. */
249 for (tail1
= plist
; ! NILP (tail1
); tail1
= Fcdr (Fcdr (tail1
)))
253 /* Go through i's plist, looking for tail1 */
254 for (tail2
= i
->plist
; ! NILP (tail2
); tail2
= Fcdr (Fcdr (tail2
)))
255 if (EQ (sym
, Fcar (tail2
)))
262 /* Changing the plists of individual intervals. */
264 /* Return the value of PROP in property-list PLIST, or Qunbound if it
267 property_value (plist
, prop
)
268 Lisp_Object plist
, prop
;
272 while (PLIST_ELT_P (plist
, value
))
273 if (EQ (XCONS (plist
)->car
, prop
))
274 return XCONS (value
)->car
;
276 plist
= XCONS (value
)->cdr
;
281 /* Set the properties of INTERVAL to PROPERTIES,
282 and record undo info for the previous values.
283 OBJECT is the string or buffer that INTERVAL belongs to. */
286 set_properties (properties
, interval
, object
)
287 Lisp_Object properties
, object
;
290 Lisp_Object sym
, value
;
292 if (BUFFERP (object
))
294 /* For each property in the old plist which is missing from PROPERTIES,
295 or has a different value in PROPERTIES, make an undo record. */
296 for (sym
= interval
->plist
;
297 PLIST_ELT_P (sym
, value
);
298 sym
= XCONS (value
)->cdr
)
299 if (! EQ (property_value (properties
, XCONS (sym
)->car
),
302 record_property_change (interval
->position
, LENGTH (interval
),
303 XCONS (sym
)->car
, XCONS (value
)->car
,
307 /* For each new property that has no value at all in the old plist,
308 make an undo record binding it to nil, so it will be removed. */
309 for (sym
= properties
;
310 PLIST_ELT_P (sym
, value
);
311 sym
= XCONS (value
)->cdr
)
312 if (EQ (property_value (interval
->plist
, XCONS (sym
)->car
), Qunbound
))
314 record_property_change (interval
->position
, LENGTH (interval
),
315 XCONS (sym
)->car
, Qnil
,
320 /* Store new properties. */
321 interval
->plist
= Fcopy_sequence (properties
);
324 /* Add the properties of PLIST to the interval I, or set
325 the value of I's property to the value of the property on PLIST
326 if they are different.
328 OBJECT should be the string or buffer the interval is in.
330 Return nonzero if this changes I (i.e., if any members of PLIST
331 are actually added to I's plist) */
334 add_properties (plist
, i
, object
)
339 Lisp_Object tail1
, tail2
, sym1
, val1
;
340 register int changed
= 0;
342 struct gcpro gcpro1
, gcpro2
, gcpro3
;
347 /* No need to protect OBJECT, because we can GC only in the case
348 where it is a buffer, and live buffers are always protected.
349 I and its plist are also protected, via OBJECT. */
350 GCPRO3 (tail1
, sym1
, val1
);
352 /* Go through each element of PLIST. */
353 for (tail1
= plist
; ! NILP (tail1
); tail1
= Fcdr (Fcdr (tail1
)))
356 val1
= Fcar (Fcdr (tail1
));
359 /* Go through I's plist, looking for sym1 */
360 for (tail2
= i
->plist
; ! NILP (tail2
); tail2
= Fcdr (Fcdr (tail2
)))
361 if (EQ (sym1
, Fcar (tail2
)))
363 /* No need to gcpro, because tail2 protects this
364 and it must be a cons cell (we get an error otherwise). */
365 register Lisp_Object this_cdr
;
367 this_cdr
= Fcdr (tail2
);
368 /* Found the property. Now check its value. */
371 /* The properties have the same value on both lists.
372 Continue to the next property. */
373 if (EQ (val1
, Fcar (this_cdr
)))
376 /* Record this change in the buffer, for undo purposes. */
377 if (BUFFERP (object
))
379 record_property_change (i
->position
, LENGTH (i
),
380 sym1
, Fcar (this_cdr
), object
);
383 /* I's property has a different value -- change it */
384 Fsetcar (this_cdr
, val1
);
391 /* Record this change in the buffer, for undo purposes. */
392 if (BUFFERP (object
))
394 record_property_change (i
->position
, LENGTH (i
),
397 i
->plist
= Fcons (sym1
, Fcons (val1
, i
->plist
));
407 /* For any members of PLIST which are properties of I, remove them
409 OBJECT is the string or buffer containing I. */
412 remove_properties (plist
, i
, object
)
417 register Lisp_Object tail1
, tail2
, sym
, current_plist
;
418 register int changed
= 0;
420 current_plist
= i
->plist
;
421 /* Go through each element of plist. */
422 for (tail1
= plist
; ! NILP (tail1
); tail1
= Fcdr (Fcdr (tail1
)))
426 /* First, remove the symbol if its at the head of the list */
427 while (! NILP (current_plist
) && EQ (sym
, Fcar (current_plist
)))
429 if (BUFFERP (object
))
431 record_property_change (i
->position
, LENGTH (i
),
432 sym
, Fcar (Fcdr (current_plist
)),
436 current_plist
= Fcdr (Fcdr (current_plist
));
440 /* Go through i's plist, looking for sym */
441 tail2
= current_plist
;
442 while (! NILP (tail2
))
444 register Lisp_Object
this;
445 this = Fcdr (Fcdr (tail2
));
446 if (EQ (sym
, Fcar (this)))
448 if (BUFFERP (object
))
450 record_property_change (i
->position
, LENGTH (i
),
451 sym
, Fcar (Fcdr (this)), object
);
454 Fsetcdr (Fcdr (tail2
), Fcdr (Fcdr (this)));
462 i
->plist
= current_plist
;
467 /* Remove all properties from interval I. Return non-zero
468 if this changes the interval. */
482 /* Returns the interval of the POSITION in OBJECT.
483 POSITION is BEG-based. */
486 interval_of (position
, object
)
494 XSETBUFFER (object
, current_buffer
);
496 CHECK_STRING_OR_BUFFER (object
, 0);
498 if (BUFFERP (object
))
500 register struct buffer
*b
= XBUFFER (object
);
504 i
= BUF_INTERVALS (b
);
508 register struct Lisp_String
*s
= XSTRING (object
);
510 /* We expect position to be 1-based. */
516 if (!(beg
<= position
&& position
<= end
))
517 args_out_of_range (position
, position
);
518 if (beg
== end
|| NULL_INTERVAL_P (i
))
519 return NULL_INTERVAL
;
521 return find_interval (i
, position
);
524 DEFUN ("text-properties-at", Ftext_properties_at
,
525 Stext_properties_at
, 1, 2, 0,
526 "Return the list of properties held by the character at POSITION\n\
527 in optional argument OBJECT, a string or buffer. If nil, OBJECT\n\
528 defaults to the current buffer.\n\
529 If POSITION is at the end of OBJECT, the value is nil.")
531 Lisp_Object position
, object
;
536 XSETBUFFER (object
, current_buffer
);
538 i
= validate_interval_range (object
, &position
, &position
, soft
);
539 if (NULL_INTERVAL_P (i
))
541 /* If POSITION is at the end of the interval,
542 it means it's the end of OBJECT.
543 There are no properties at the very end,
544 since no character follows. */
545 if (XINT (position
) == LENGTH (i
) + i
->position
)
551 DEFUN ("get-text-property", Fget_text_property
, Sget_text_property
, 2, 3, 0,
552 "Return the value of POSITION's property PROP, in OBJECT.\n\
553 OBJECT is optional and defaults to the current buffer.\n\
554 If POSITION is at the end of OBJECT, the value is nil.")
555 (position
, prop
, object
)
556 Lisp_Object position
, object
;
559 return textget (Ftext_properties_at (position
, object
), prop
);
562 DEFUN ("get-char-property", Fget_char_property
, Sget_char_property
, 2, 3, 0,
563 "Return the value of POSITION's property PROP, in OBJECT.\n\
564 OBJECT is optional and defaults to the current buffer.\n\
565 If POSITION is at the end of OBJECT, the value is nil.\n\
566 If OBJECT is a buffer, then overlay properties are considered as well as\n\
568 If OBJECT is a window, then that window's buffer is used, but window-specific\n\
569 overlays are considered only if they are associated with OBJECT.")
570 (position
, prop
, object
)
571 Lisp_Object position
, object
;
572 register Lisp_Object prop
;
574 struct window
*w
= 0;
576 CHECK_NUMBER_COERCE_MARKER (position
, 0);
579 XSETBUFFER (object
, current_buffer
);
581 if (WINDOWP (object
))
583 w
= XWINDOW (object
);
586 if (BUFFERP (object
))
588 int posn
= XINT (position
);
590 Lisp_Object
*overlay_vec
, tem
;
593 struct buffer
*obuf
= current_buffer
;
595 set_buffer_temp (XBUFFER (object
));
597 /* First try with room for 40 overlays. */
599 overlay_vec
= (Lisp_Object
*) alloca (len
* sizeof (Lisp_Object
));
601 noverlays
= overlays_at (posn
, 0, &overlay_vec
, &len
,
602 &next_overlay
, NULL
);
604 /* If there are more than 40,
605 make enough space for all, and try again. */
609 overlay_vec
= (Lisp_Object
*) alloca (len
* sizeof (Lisp_Object
));
610 noverlays
= overlays_at (posn
, 0, &overlay_vec
, &len
,
611 &next_overlay
, NULL
);
613 noverlays
= sort_overlays (overlay_vec
, noverlays
, w
);
615 set_buffer_temp (obuf
);
617 /* Now check the overlays in order of decreasing priority. */
618 while (--noverlays
>= 0)
620 tem
= Foverlay_get (overlay_vec
[noverlays
], prop
);
625 /* Not a buffer, or no appropriate overlay, so fall through to the
627 return (Fget_text_property (position
, prop
, object
));
630 DEFUN ("next-char-property-change", Fnext_char_property_change
,
631 Snext_char_property_change
, 1, 2, 0,
632 "Return the position of next text property or overlay change.\n\
633 This scans characters forward from POSITION in OBJECT till it finds\n\
634 a change in some text property, or the beginning or end of an overlay,\n\
635 and returns the position of that.\n\
636 If none is found, the function returns (point-max).\n\
638 If the optional third argument LIMIT is non-nil, don't search\n\
639 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
641 Lisp_Object position
, limit
;
645 temp
= Fnext_overlay_change (position
);
648 CHECK_NUMBER (limit
, 2);
649 if (XINT (limit
) < XINT (temp
))
652 return Fnext_property_change (position
, Qnil
, temp
);
655 DEFUN ("previous-char-property-change", Fprevious_char_property_change
,
656 Sprevious_char_property_change
, 1, 2, 0,
657 "Return the position of previous text property or overlay change.\n\
658 Scans characters backward from POSITION in OBJECT till it finds\n\
659 a change in some text property, or the beginning or end of an overlay,\n\
660 and returns the position of that.\n\
661 If none is found, the function returns (point-max).\n\
663 If the optional third argument LIMIT is non-nil, don't search\n\
664 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
666 Lisp_Object position
, limit
;
670 temp
= Fprevious_overlay_change (position
);
673 CHECK_NUMBER (limit
, 2);
674 if (XINT (limit
) > XINT (temp
))
677 return Fprevious_property_change (position
, Qnil
, temp
);
680 DEFUN ("next-property-change", Fnext_property_change
,
681 Snext_property_change
, 1, 3, 0,
682 "Return the position of next property change.\n\
683 Scans characters forward from POSITION in OBJECT till it finds\n\
684 a change in some text property, then returns the position of the change.\n\
685 The optional second argument OBJECT is the string or buffer to scan.\n\
686 Return nil if the property is constant all the way to the end of OBJECT.\n\
687 If the value is non-nil, it is a position greater than POSITION, never equal.\n\n\
688 If the optional third argument LIMIT is non-nil, don't search\n\
689 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
690 (position
, object
, limit
)
691 Lisp_Object position
, object
, limit
;
693 register INTERVAL i
, next
;
696 XSETBUFFER (object
, current_buffer
);
698 if (! NILP (limit
) && ! EQ (limit
, Qt
))
699 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
701 i
= validate_interval_range (object
, &position
, &position
, soft
);
703 /* If LIMIT is t, return start of next interval--don't
704 bother checking further intervals. */
707 if (NULL_INTERVAL_P (i
))
710 next
= next_interval (i
);
712 if (NULL_INTERVAL_P (next
))
713 XSETFASTINT (position
, (STRINGP (object
)
714 ? XSTRING (object
)->size
715 : BUF_ZV (XBUFFER (object
))));
717 XSETFASTINT (position
, next
->position
- (STRINGP (object
)));
721 if (NULL_INTERVAL_P (i
))
724 next
= next_interval (i
);
726 while (! NULL_INTERVAL_P (next
) && intervals_equal (i
, next
)
727 && (NILP (limit
) || next
->position
< XFASTINT (limit
)))
728 next
= next_interval (next
);
730 if (NULL_INTERVAL_P (next
))
732 if (! NILP (limit
) && !(next
->position
< XFASTINT (limit
)))
735 XSETFASTINT (position
, next
->position
- (STRINGP (object
)));
739 /* Return 1 if there's a change in some property between BEG and END. */
742 property_change_between_p (beg
, end
)
745 register INTERVAL i
, next
;
746 Lisp_Object object
, pos
;
748 XSETBUFFER (object
, current_buffer
);
749 XSETFASTINT (pos
, beg
);
751 i
= validate_interval_range (object
, &pos
, &pos
, soft
);
752 if (NULL_INTERVAL_P (i
))
755 next
= next_interval (i
);
756 while (! NULL_INTERVAL_P (next
) && intervals_equal (i
, next
))
758 next
= next_interval (next
);
759 if (NULL_INTERVAL_P (next
))
761 if (next
->position
>= end
)
765 if (NULL_INTERVAL_P (next
))
771 DEFUN ("next-single-property-change", Fnext_single_property_change
,
772 Snext_single_property_change
, 2, 4, 0,
773 "Return the position of next property change for a specific property.\n\
774 Scans characters forward from POSITION till it finds\n\
775 a change in the PROP property, then returns the position of the change.\n\
776 The optional third argument OBJECT is the string or buffer to scan.\n\
777 The property values are compared with `eq'.\n\
778 Return nil if the property is constant all the way to the end of OBJECT.\n\
779 If the value is non-nil, it is a position greater than POSITION, never equal.\n\n\
780 If the optional fourth argument LIMIT is non-nil, don't search\n\
781 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
782 (position
, prop
, object
, limit
)
783 Lisp_Object position
, prop
, object
, limit
;
785 register INTERVAL i
, next
;
786 register Lisp_Object here_val
;
789 XSETBUFFER (object
, current_buffer
);
792 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
794 i
= validate_interval_range (object
, &position
, &position
, soft
);
795 if (NULL_INTERVAL_P (i
))
798 here_val
= textget (i
->plist
, prop
);
799 next
= next_interval (i
);
800 while (! NULL_INTERVAL_P (next
)
801 && EQ (here_val
, textget (next
->plist
, prop
))
802 && (NILP (limit
) || next
->position
< XFASTINT (limit
)))
803 next
= next_interval (next
);
805 if (NULL_INTERVAL_P (next
))
807 if (! NILP (limit
) && !(next
->position
< XFASTINT (limit
)))
810 XSETFASTINT (position
, next
->position
- (STRINGP (object
)));
814 DEFUN ("previous-property-change", Fprevious_property_change
,
815 Sprevious_property_change
, 1, 3, 0,
816 "Return the position of previous property change.\n\
817 Scans characters backwards from POSITION in OBJECT till it finds\n\
818 a change in some text property, then returns the position of the change.\n\
819 The optional second argument OBJECT is the string or buffer to scan.\n\
820 Return nil if the property is constant all the way to the start of OBJECT.\n\
821 If the value is non-nil, it is a position less than POSITION, never equal.\n\n\
822 If the optional third argument LIMIT is non-nil, don't search\n\
823 back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
824 (position
, object
, limit
)
825 Lisp_Object position
, object
, limit
;
827 register INTERVAL i
, previous
;
830 XSETBUFFER (object
, current_buffer
);
833 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
835 i
= validate_interval_range (object
, &position
, &position
, soft
);
836 if (NULL_INTERVAL_P (i
))
839 /* Start with the interval containing the char before point. */
840 if (i
->position
== XFASTINT (position
))
841 i
= previous_interval (i
);
843 previous
= previous_interval (i
);
844 while (! NULL_INTERVAL_P (previous
) && intervals_equal (previous
, i
)
846 || previous
->position
+ LENGTH (previous
) > XFASTINT (limit
)))
847 previous
= previous_interval (previous
);
848 if (NULL_INTERVAL_P (previous
))
851 && !(previous
->position
+ LENGTH (previous
) > XFASTINT (limit
)))
854 XSETFASTINT (position
, (previous
->position
+ LENGTH (previous
)
855 - (STRINGP (object
))));
859 DEFUN ("previous-single-property-change", Fprevious_single_property_change
,
860 Sprevious_single_property_change
, 2, 4, 0,
861 "Return the position of previous property change for a specific property.\n\
862 Scans characters backward from POSITION till it finds\n\
863 a change in the PROP property, then returns the position of the change.\n\
864 The optional third argument OBJECT is the string or buffer to scan.\n\
865 The property values are compared with `eq'.\n\
866 Return nil if the property is constant all the way to the start of OBJECT.\n\
867 If the value is non-nil, it is a position less than POSITION, never equal.\n\n\
868 If the optional fourth argument LIMIT is non-nil, don't search\n\
869 back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
870 (position
, prop
, object
, limit
)
871 Lisp_Object position
, prop
, object
, limit
;
873 register INTERVAL i
, previous
;
874 register Lisp_Object here_val
;
877 XSETBUFFER (object
, current_buffer
);
880 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
882 i
= validate_interval_range (object
, &position
, &position
, soft
);
884 /* Start with the interval containing the char before point. */
885 if (! NULL_INTERVAL_P (i
) && i
->position
== XFASTINT (position
))
886 i
= previous_interval (i
);
888 if (NULL_INTERVAL_P (i
))
891 here_val
= textget (i
->plist
, prop
);
892 previous
= previous_interval (i
);
893 while (! NULL_INTERVAL_P (previous
)
894 && EQ (here_val
, textget (previous
->plist
, prop
))
896 || previous
->position
+ LENGTH (previous
) > XFASTINT (limit
)))
897 previous
= previous_interval (previous
);
898 if (NULL_INTERVAL_P (previous
))
901 && !(previous
->position
+ LENGTH (previous
) > XFASTINT (limit
)))
904 XSETFASTINT (position
, (previous
->position
+ LENGTH (previous
)
905 - (STRINGP (object
))));
909 /* Callers note, this can GC when OBJECT is a buffer (or nil). */
911 DEFUN ("add-text-properties", Fadd_text_properties
,
912 Sadd_text_properties
, 3, 4, 0,
913 "Add properties to the text from START to END.\n\
914 The third argument PROPERTIES is a property list\n\
915 specifying the property values to add.\n\
916 The optional fourth argument, OBJECT,\n\
917 is the string or buffer containing the text.\n\
918 Return t if any property value actually changed, nil otherwise.")
919 (start
, end
, properties
, object
)
920 Lisp_Object start
, end
, properties
, object
;
922 register INTERVAL i
, unchanged
;
923 register int s
, len
, modified
= 0;
926 properties
= validate_plist (properties
);
927 if (NILP (properties
))
931 XSETBUFFER (object
, current_buffer
);
933 i
= validate_interval_range (object
, &start
, &end
, hard
);
934 if (NULL_INTERVAL_P (i
))
938 len
= XINT (end
) - s
;
940 /* No need to protect OBJECT, because we GC only if it's a buffer,
941 and live buffers are always protected. */
944 /* If we're not starting on an interval boundary, we have to
945 split this interval. */
946 if (i
->position
!= s
)
948 /* If this interval already has the properties, we can
950 if (interval_has_all_properties (properties
, i
))
952 int got
= (LENGTH (i
) - (s
- i
->position
));
954 RETURN_UNGCPRO (Qnil
);
956 i
= next_interval (i
);
961 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
962 copy_properties (unchanged
, i
);
966 if (BUFFERP (object
))
967 modify_region (XBUFFER (object
), XINT (start
), XINT (end
));
969 /* We are at the beginning of interval I, with LEN chars to scan. */
975 if (LENGTH (i
) >= len
)
977 /* We can UNGCPRO safely here, because there will be just
978 one more chance to gc, in the next call to add_properties,
979 and after that we will not need PROPERTIES or OBJECT again. */
982 if (interval_has_all_properties (properties
, i
))
984 if (BUFFERP (object
))
985 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
986 XINT (end
) - XINT (start
));
988 return modified
? Qt
: Qnil
;
991 if (LENGTH (i
) == len
)
993 add_properties (properties
, i
, object
);
994 if (BUFFERP (object
))
995 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
996 XINT (end
) - XINT (start
));
1000 /* i doesn't have the properties, and goes past the change limit */
1002 i
= split_interval_left (unchanged
, len
);
1003 copy_properties (unchanged
, i
);
1004 add_properties (properties
, i
, object
);
1005 if (BUFFERP (object
))
1006 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1007 XINT (end
) - XINT (start
));
1012 modified
+= add_properties (properties
, i
, object
);
1013 i
= next_interval (i
);
1017 /* Callers note, this can GC when OBJECT is a buffer (or nil). */
1019 DEFUN ("put-text-property", Fput_text_property
,
1020 Sput_text_property
, 4, 5, 0,
1021 "Set one property of the text from START to END.\n\
1022 The third and fourth arguments PROPERTY and VALUE\n\
1023 specify the property to add.\n\
1024 The optional fifth argument, OBJECT,\n\
1025 is the string or buffer containing the text.")
1026 (start
, end
, property
, value
, object
)
1027 Lisp_Object start
, end
, property
, value
, object
;
1029 Fadd_text_properties (start
, end
,
1030 Fcons (property
, Fcons (value
, Qnil
)),
1035 DEFUN ("set-text-properties", Fset_text_properties
,
1036 Sset_text_properties
, 3, 4, 0,
1037 "Completely replace properties of text from START to END.\n\
1038 The third argument PROPERTIES is the new property list.\n\
1039 The optional fourth argument, OBJECT,\n\
1040 is the string or buffer containing the text.")
1041 (start
, end
, properties
, object
)
1042 Lisp_Object start
, end
, properties
, object
;
1044 register INTERVAL i
, unchanged
;
1045 register INTERVAL prev_changed
= NULL_INTERVAL
;
1046 register int s
, len
;
1047 Lisp_Object ostart
, oend
;
1048 int have_modified
= 0;
1053 properties
= validate_plist (properties
);
1056 XSETBUFFER (object
, current_buffer
);
1058 /* If we want no properties for a whole string,
1059 get rid of its intervals. */
1060 if (NILP (properties
) && STRINGP (object
)
1061 && XFASTINT (start
) == 0
1062 && XFASTINT (end
) == XSTRING (object
)->size
)
1064 if (! XSTRING (object
)->intervals
)
1067 XSTRING (object
)->intervals
= 0;
1071 i
= validate_interval_range (object
, &start
, &end
, soft
);
1073 if (NULL_INTERVAL_P (i
))
1075 /* If buffer has no properties, and we want none, return now. */
1076 if (NILP (properties
))
1079 /* Restore the original START and END values
1080 because validate_interval_range increments them for strings. */
1084 i
= validate_interval_range (object
, &start
, &end
, hard
);
1085 /* This can return if start == end. */
1086 if (NULL_INTERVAL_P (i
))
1091 len
= XINT (end
) - s
;
1093 if (BUFFERP (object
))
1094 modify_region (XBUFFER (object
), XINT (start
), XINT (end
));
1096 if (i
->position
!= s
)
1099 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
1101 if (LENGTH (i
) > len
)
1103 copy_properties (unchanged
, i
);
1104 i
= split_interval_left (i
, len
);
1105 set_properties (properties
, i
, object
);
1106 if (BUFFERP (object
))
1107 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1108 XINT (end
) - XINT (start
));
1113 set_properties (properties
, i
, object
);
1115 if (LENGTH (i
) == len
)
1117 if (BUFFERP (object
))
1118 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1119 XINT (end
) - XINT (start
));
1126 i
= next_interval (i
);
1129 /* We are starting at the beginning of an interval, I */
1135 if (LENGTH (i
) >= len
)
1137 if (LENGTH (i
) > len
)
1138 i
= split_interval_left (i
, len
);
1140 /* We have to call set_properties even if we are going to
1141 merge the intervals, so as to make the undo records
1142 and cause redisplay to happen. */
1143 set_properties (properties
, i
, object
);
1144 if (!NULL_INTERVAL_P (prev_changed
))
1145 merge_interval_left (i
);
1146 if (BUFFERP (object
))
1147 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1148 XINT (end
) - XINT (start
));
1154 /* We have to call set_properties even if we are going to
1155 merge the intervals, so as to make the undo records
1156 and cause redisplay to happen. */
1157 set_properties (properties
, i
, object
);
1158 if (NULL_INTERVAL_P (prev_changed
))
1161 prev_changed
= i
= merge_interval_left (i
);
1163 i
= next_interval (i
);
1166 if (BUFFERP (object
))
1167 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1168 XINT (end
) - XINT (start
));
1172 DEFUN ("remove-text-properties", Fremove_text_properties
,
1173 Sremove_text_properties
, 3, 4, 0,
1174 "Remove some properties from text from START to END.\n\
1175 The third argument PROPERTIES is a property list\n\
1176 whose property names specify the properties to remove.\n\
1177 \(The values stored in PROPERTIES are ignored.)\n\
1178 The optional fourth argument, OBJECT,\n\
1179 is the string or buffer containing the text.\n\
1180 Return t if any property was actually removed, nil otherwise.")
1181 (start
, end
, properties
, object
)
1182 Lisp_Object start
, end
, properties
, object
;
1184 register INTERVAL i
, unchanged
;
1185 register int s
, len
, modified
= 0;
1188 XSETBUFFER (object
, current_buffer
);
1190 i
= validate_interval_range (object
, &start
, &end
, soft
);
1191 if (NULL_INTERVAL_P (i
))
1195 len
= XINT (end
) - s
;
1197 if (i
->position
!= s
)
1199 /* No properties on this first interval -- return if
1200 it covers the entire region. */
1201 if (! interval_has_some_properties (properties
, i
))
1203 int got
= (LENGTH (i
) - (s
- i
->position
));
1207 i
= next_interval (i
);
1209 /* Split away the beginning of this interval; what we don't
1214 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
1215 copy_properties (unchanged
, i
);
1219 if (BUFFERP (object
))
1220 modify_region (XBUFFER (object
), XINT (start
), XINT (end
));
1222 /* We are at the beginning of an interval, with len to scan */
1228 if (LENGTH (i
) >= len
)
1230 if (! interval_has_some_properties (properties
, i
))
1231 return modified
? Qt
: Qnil
;
1233 if (LENGTH (i
) == len
)
1235 remove_properties (properties
, i
, object
);
1236 if (BUFFERP (object
))
1237 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1238 XINT (end
) - XINT (start
));
1242 /* i has the properties, and goes past the change limit */
1244 i
= split_interval_left (i
, len
);
1245 copy_properties (unchanged
, i
);
1246 remove_properties (properties
, i
, object
);
1247 if (BUFFERP (object
))
1248 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1249 XINT (end
) - XINT (start
));
1254 modified
+= remove_properties (properties
, i
, object
);
1255 i
= next_interval (i
);
1259 DEFUN ("text-property-any", Ftext_property_any
,
1260 Stext_property_any
, 4, 5, 0,
1261 "Check text from START to END for property PROPERTY equalling VALUE.\n\
1262 If so, return the position of the first character whose property PROPERTY\n\
1263 is `eq' to VALUE. Otherwise return nil.\n\
1264 The optional fifth argument, OBJECT, is the string or buffer\n\
1265 containing the text.")
1266 (start
, end
, property
, value
, object
)
1267 Lisp_Object start
, end
, property
, value
, object
;
1269 register INTERVAL i
;
1270 register int e
, pos
;
1273 XSETBUFFER (object
, current_buffer
);
1274 i
= validate_interval_range (object
, &start
, &end
, soft
);
1275 if (NULL_INTERVAL_P (i
))
1276 return (!NILP (value
) || EQ (start
, end
) ? Qnil
: start
);
1279 while (! NULL_INTERVAL_P (i
))
1281 if (i
->position
>= e
)
1283 if (EQ (textget (i
->plist
, property
), value
))
1286 if (pos
< XINT (start
))
1288 return make_number (pos
- (STRINGP (object
)));
1290 i
= next_interval (i
);
1295 DEFUN ("text-property-not-all", Ftext_property_not_all
,
1296 Stext_property_not_all
, 4, 5, 0,
1297 "Check text from START to END for property PROPERTY not equalling VALUE.\n\
1298 If so, return the position of the first character whose property PROPERTY\n\
1299 is not `eq' to VALUE. Otherwise, return nil.\n\
1300 The optional fifth argument, OBJECT, is the string or buffer\n\
1301 containing the text.")
1302 (start
, end
, property
, value
, object
)
1303 Lisp_Object start
, end
, property
, value
, object
;
1305 register INTERVAL i
;
1309 XSETBUFFER (object
, current_buffer
);
1310 i
= validate_interval_range (object
, &start
, &end
, soft
);
1311 if (NULL_INTERVAL_P (i
))
1312 return (NILP (value
) || EQ (start
, end
)) ? Qnil
: start
;
1316 while (! NULL_INTERVAL_P (i
))
1318 if (i
->position
>= e
)
1320 if (! EQ (textget (i
->plist
, property
), value
))
1322 if (i
->position
> s
)
1324 return make_number (s
- (STRINGP (object
)));
1326 i
= next_interval (i
);
1331 #if 0 /* You can use set-text-properties for this. */
1333 DEFUN ("erase-text-properties", Ferase_text_properties
,
1334 Serase_text_properties
, 2, 3, 0,
1335 "Remove all properties from the text from START to END.\n\
1336 The optional third argument, OBJECT,\n\
1337 is the string or buffer containing the text.")
1338 (start
, end
, object
)
1339 Lisp_Object start
, end
, object
;
1341 register INTERVAL i
;
1342 register INTERVAL prev_changed
= NULL_INTERVAL
;
1343 register int s
, len
, modified
;
1346 XSETBUFFER (object
, current_buffer
);
1348 i
= validate_interval_range (object
, &start
, &end
, soft
);
1349 if (NULL_INTERVAL_P (i
))
1353 len
= XINT (end
) - s
;
1355 if (i
->position
!= s
)
1358 register INTERVAL unchanged
= i
;
1360 /* If there are properties here, then this text will be modified. */
1361 if (! NILP (i
->plist
))
1363 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
1367 if (LENGTH (i
) > len
)
1369 i
= split_interval_right (i
, len
);
1370 copy_properties (unchanged
, i
);
1374 if (LENGTH (i
) == len
)
1379 /* If the text of I is without any properties, and contains
1380 LEN or more characters, then we may return without changing
1382 else if (LENGTH (i
) - (s
- i
->position
) <= len
)
1384 /* The amount of text to change extends past I, so just note
1385 how much we've gotten. */
1387 got
= LENGTH (i
) - (s
- i
->position
);
1391 i
= next_interval (i
);
1394 /* We are starting at the beginning of an interval, I. */
1397 if (LENGTH (i
) >= len
)
1399 /* If I has no properties, simply merge it if possible. */
1400 if (NILP (i
->plist
))
1402 if (! NULL_INTERVAL_P (prev_changed
))
1403 merge_interval_left (i
);
1405 return modified
? Qt
: Qnil
;
1408 if (LENGTH (i
) > len
)
1409 i
= split_interval_left (i
, len
);
1410 if (! NULL_INTERVAL_P (prev_changed
))
1411 merge_interval_left (i
);
1418 /* Here if we still need to erase past the end of I */
1420 if (NULL_INTERVAL_P (prev_changed
))
1422 modified
+= erase_properties (i
);
1427 modified
+= ! NILP (i
->plist
);
1428 /* Merging I will give it the properties of PREV_CHANGED. */
1429 prev_changed
= i
= merge_interval_left (i
);
1432 i
= next_interval (i
);
1435 return modified
? Qt
: Qnil
;
1439 /* I don't think this is the right interface to export; how often do you
1440 want to do something like this, other than when you're copying objects
1443 I think it would be better to have a pair of functions, one which
1444 returns the text properties of a region as a list of ranges and
1445 plists, and another which applies such a list to another object. */
1447 /* Add properties from SRC to SRC of SRC, starting at POS in DEST.
1448 SRC and DEST may each refer to strings or buffers.
1449 Optional sixth argument PROP causes only that property to be copied.
1450 Properties are copied to DEST as if by `add-text-properties'.
1451 Return t if any property value actually changed, nil otherwise. */
1453 /* Note this can GC when DEST is a buffer. */
1456 copy_text_properties (start
, end
, src
, pos
, dest
, prop
)
1457 Lisp_Object start
, end
, src
, pos
, dest
, prop
;
1463 int s
, e
, e2
, p
, len
, modified
= 0;
1464 struct gcpro gcpro1
, gcpro2
;
1466 i
= validate_interval_range (src
, &start
, &end
, soft
);
1467 if (NULL_INTERVAL_P (i
))
1470 CHECK_NUMBER_COERCE_MARKER (pos
, 0);
1472 Lisp_Object dest_start
, dest_end
;
1475 XSETFASTINT (dest_end
, XINT (dest_start
) + (XINT (end
) - XINT (start
)));
1476 /* Apply this to a copy of pos; it will try to increment its arguments,
1477 which we don't want. */
1478 validate_interval_range (dest
, &dest_start
, &dest_end
, soft
);
1489 e2
= i
->position
+ LENGTH (i
);
1496 while (! NILP (plist
))
1498 if (EQ (Fcar (plist
), prop
))
1500 plist
= Fcons (prop
, Fcons (Fcar (Fcdr (plist
)), Qnil
));
1503 plist
= Fcdr (Fcdr (plist
));
1507 /* Must defer modifications to the interval tree in case src
1508 and dest refer to the same string or buffer. */
1509 stuff
= Fcons (Fcons (make_number (p
),
1510 Fcons (make_number (p
+ len
),
1511 Fcons (plist
, Qnil
))),
1515 i
= next_interval (i
);
1516 if (NULL_INTERVAL_P (i
))
1523 GCPRO2 (stuff
, dest
);
1525 while (! NILP (stuff
))
1528 res
= Fadd_text_properties (Fcar (res
), Fcar (Fcdr (res
)),
1529 Fcar (Fcdr (Fcdr (res
))), dest
);
1532 stuff
= Fcdr (stuff
);
1537 return modified
? Qt
: Qnil
;
1540 /* Call the modification hook functions in LIST, each with START and END. */
1543 call_mod_hooks (list
, start
, end
)
1544 Lisp_Object list
, start
, end
;
1546 struct gcpro gcpro1
;
1548 while (!NILP (list
))
1550 call2 (Fcar (list
), start
, end
);
1556 /* Check for read-only intervals and signal an error if we find one.
1557 Then check for any modification hooks in the range START up to
1558 (but not including) END. Create a list of all these hooks in
1559 lexicographic order, eliminating consecutive extra copies of the
1560 same hook. Then call those hooks in order, with START and END - 1
1564 verify_interval_modification (buf
, start
, end
)
1568 register INTERVAL intervals
= BUF_INTERVALS (buf
);
1569 register INTERVAL i
, prev
;
1571 register Lisp_Object prev_mod_hooks
;
1572 Lisp_Object mod_hooks
;
1573 struct gcpro gcpro1
;
1576 prev_mod_hooks
= Qnil
;
1579 interval_insert_behind_hooks
= Qnil
;
1580 interval_insert_in_front_hooks
= Qnil
;
1582 if (NULL_INTERVAL_P (intervals
))
1592 /* For an insert operation, check the two chars around the position. */
1596 Lisp_Object before
, after
;
1598 /* Set I to the interval containing the char after START,
1599 and PREV to the interval containing the char before START.
1600 Either one may be null. They may be equal. */
1601 i
= find_interval (intervals
, start
);
1603 if (start
== BUF_BEGV (buf
))
1605 else if (i
->position
== start
)
1606 prev
= previous_interval (i
);
1607 else if (i
->position
< start
)
1609 if (start
== BUF_ZV (buf
))
1612 /* If Vinhibit_read_only is set and is not a list, we can
1613 skip the read_only checks. */
1614 if (NILP (Vinhibit_read_only
) || CONSP (Vinhibit_read_only
))
1616 /* If I and PREV differ we need to check for the read-only
1617 property together with its stickiness. If either I or
1618 PREV are 0, this check is all we need.
1619 We have to take special care, since read-only may be
1620 indirectly defined via the category property. */
1623 if (! NULL_INTERVAL_P (i
))
1625 after
= textget (i
->plist
, Qread_only
);
1627 /* If interval I is read-only and read-only is
1628 front-sticky, inhibit insertion.
1629 Check for read-only as well as category. */
1631 && NILP (Fmemq (after
, Vinhibit_read_only
)))
1635 tem
= textget (i
->plist
, Qfront_sticky
);
1636 if (TMEM (Qread_only
, tem
)
1637 || (NILP (Fplist_get (i
->plist
, Qread_only
))
1638 && TMEM (Qcategory
, tem
)))
1639 error ("Attempt to insert within read-only text");
1643 if (! NULL_INTERVAL_P (prev
))
1645 before
= textget (prev
->plist
, Qread_only
);
1647 /* If interval PREV is read-only and read-only isn't
1648 rear-nonsticky, inhibit insertion.
1649 Check for read-only as well as category. */
1651 && NILP (Fmemq (before
, Vinhibit_read_only
)))
1655 tem
= textget (prev
->plist
, Qrear_nonsticky
);
1656 if (! TMEM (Qread_only
, tem
)
1657 && (! NILP (Fplist_get (prev
->plist
,Qread_only
))
1658 || ! TMEM (Qcategory
, tem
)))
1659 error ("Attempt to insert within read-only text");
1663 else if (! NULL_INTERVAL_P (i
))
1665 after
= textget (i
->plist
, Qread_only
);
1667 /* If interval I is read-only and read-only is
1668 front-sticky, inhibit insertion.
1669 Check for read-only as well as category. */
1670 if (! NILP (after
) && NILP (Fmemq (after
, Vinhibit_read_only
)))
1674 tem
= textget (i
->plist
, Qfront_sticky
);
1675 if (TMEM (Qread_only
, tem
)
1676 || (NILP (Fplist_get (i
->plist
, Qread_only
))
1677 && TMEM (Qcategory
, tem
)))
1678 error ("Attempt to insert within read-only text");
1680 tem
= textget (prev
->plist
, Qrear_nonsticky
);
1681 if (! TMEM (Qread_only
, tem
)
1682 && (! NILP (Fplist_get (prev
->plist
, Qread_only
))
1683 || ! TMEM (Qcategory
, tem
)))
1684 error ("Attempt to insert within read-only text");
1689 /* Run both insert hooks (just once if they're the same). */
1690 if (!NULL_INTERVAL_P (prev
))
1691 interval_insert_behind_hooks
1692 = textget (prev
->plist
, Qinsert_behind_hooks
);
1693 if (!NULL_INTERVAL_P (i
))
1694 interval_insert_in_front_hooks
1695 = textget (i
->plist
, Qinsert_in_front_hooks
);
1699 /* Loop over intervals on or next to START...END,
1700 collecting their hooks. */
1702 i
= find_interval (intervals
, start
);
1705 if (! INTERVAL_WRITABLE_P (i
))
1706 error ("Attempt to modify read-only text");
1708 mod_hooks
= textget (i
->plist
, Qmodification_hooks
);
1709 if (! NILP (mod_hooks
) && ! EQ (mod_hooks
, prev_mod_hooks
))
1711 hooks
= Fcons (mod_hooks
, hooks
);
1712 prev_mod_hooks
= mod_hooks
;
1715 i
= next_interval (i
);
1717 /* Keep going thru the interval containing the char before END. */
1718 while (! NULL_INTERVAL_P (i
) && i
->position
< end
);
1721 hooks
= Fnreverse (hooks
);
1722 while (! EQ (hooks
, Qnil
))
1724 call_mod_hooks (Fcar (hooks
), make_number (start
),
1726 hooks
= Fcdr (hooks
);
1732 /* Run the interval hooks for an insertion.
1733 verify_interval_modification chose which hooks to run;
1734 this function is called after the insertion happens
1735 so it can indicate the range of inserted text. */
1738 report_interval_modification (start
, end
)
1739 Lisp_Object start
, end
;
1741 if (! NILP (interval_insert_behind_hooks
))
1742 call_mod_hooks (interval_insert_behind_hooks
,
1743 make_number (start
), make_number (end
));
1744 if (! NILP (interval_insert_in_front_hooks
)
1745 && ! EQ (interval_insert_in_front_hooks
,
1746 interval_insert_behind_hooks
))
1747 call_mod_hooks (interval_insert_in_front_hooks
,
1748 make_number (start
), make_number (end
));
1754 DEFVAR_LISP ("default-text-properties", &Vdefault_text_properties
,
1755 "Property-list used as default values.\n\
1756 The value of a property in this list is seen as the value for every\n\
1757 character that does not have its own value for that property.");
1758 Vdefault_text_properties
= Qnil
;
1760 DEFVAR_LISP ("inhibit-point-motion-hooks", &Vinhibit_point_motion_hooks
,
1761 "If non-nil, don't run `point-left' and `point-entered' text properties.\n\
1762 This also inhibits the use of the `intangible' text property.");
1763 Vinhibit_point_motion_hooks
= Qnil
;
1765 staticpro (&interval_insert_behind_hooks
);
1766 staticpro (&interval_insert_in_front_hooks
);
1767 interval_insert_behind_hooks
= Qnil
;
1768 interval_insert_in_front_hooks
= Qnil
;
1771 /* Common attributes one might give text */
1773 staticpro (&Qforeground
);
1774 Qforeground
= intern ("foreground");
1775 staticpro (&Qbackground
);
1776 Qbackground
= intern ("background");
1778 Qfont
= intern ("font");
1779 staticpro (&Qstipple
);
1780 Qstipple
= intern ("stipple");
1781 staticpro (&Qunderline
);
1782 Qunderline
= intern ("underline");
1783 staticpro (&Qread_only
);
1784 Qread_only
= intern ("read-only");
1785 staticpro (&Qinvisible
);
1786 Qinvisible
= intern ("invisible");
1787 staticpro (&Qintangible
);
1788 Qintangible
= intern ("intangible");
1789 staticpro (&Qcategory
);
1790 Qcategory
= intern ("category");
1791 staticpro (&Qlocal_map
);
1792 Qlocal_map
= intern ("local-map");
1793 staticpro (&Qfront_sticky
);
1794 Qfront_sticky
= intern ("front-sticky");
1795 staticpro (&Qrear_nonsticky
);
1796 Qrear_nonsticky
= intern ("rear-nonsticky");
1798 /* Properties that text might use to specify certain actions */
1800 staticpro (&Qmouse_left
);
1801 Qmouse_left
= intern ("mouse-left");
1802 staticpro (&Qmouse_entered
);
1803 Qmouse_entered
= intern ("mouse-entered");
1804 staticpro (&Qpoint_left
);
1805 Qpoint_left
= intern ("point-left");
1806 staticpro (&Qpoint_entered
);
1807 Qpoint_entered
= intern ("point-entered");
1809 defsubr (&Stext_properties_at
);
1810 defsubr (&Sget_text_property
);
1811 defsubr (&Sget_char_property
);
1812 defsubr (&Snext_char_property_change
);
1813 defsubr (&Sprevious_char_property_change
);
1814 defsubr (&Snext_property_change
);
1815 defsubr (&Snext_single_property_change
);
1816 defsubr (&Sprevious_property_change
);
1817 defsubr (&Sprevious_single_property_change
);
1818 defsubr (&Sadd_text_properties
);
1819 defsubr (&Sput_text_property
);
1820 defsubr (&Sset_text_properties
);
1821 defsubr (&Sremove_text_properties
);
1822 defsubr (&Stext_property_any
);
1823 defsubr (&Stext_property_not_all
);
1824 /* defsubr (&Serase_text_properties); */
1825 /* defsubr (&Scopy_text_properties); */
1830 lose
-- this shouldn
't be compiled if USE_TEXT_PROPERTIES isn't defined
1832 #endif /* USE_TEXT_PROPERTIES */