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
);
495 else if (EQ (object
, Qt
))
496 return NULL_INTERVAL
;
498 CHECK_STRING_OR_BUFFER (object
, 0);
500 if (BUFFERP (object
))
502 register struct buffer
*b
= XBUFFER (object
);
506 i
= BUF_INTERVALS (b
);
510 register struct Lisp_String
*s
= XSTRING (object
);
512 /* We expect position to be 1-based. */
518 if (!(beg
<= position
&& position
<= end
))
519 args_out_of_range (make_number (position
), make_number (position
));
520 if (beg
== end
|| NULL_INTERVAL_P (i
))
521 return NULL_INTERVAL
;
523 return find_interval (i
, position
);
526 DEFUN ("text-properties-at", Ftext_properties_at
,
527 Stext_properties_at
, 1, 2, 0,
528 "Return the list of properties of the character at POSITION in OBJECT.\n\
529 OBJECT is the string or buffer to look for the properties in;\n\
530 nil means the current buffer.\n\
531 If POSITION is at the end of OBJECT, the value is nil.")
533 Lisp_Object position
, object
;
538 XSETBUFFER (object
, current_buffer
);
540 i
= validate_interval_range (object
, &position
, &position
, soft
);
541 if (NULL_INTERVAL_P (i
))
543 /* If POSITION is at the end of the interval,
544 it means it's the end of OBJECT.
545 There are no properties at the very end,
546 since no character follows. */
547 if (XINT (position
) == LENGTH (i
) + i
->position
)
553 DEFUN ("get-text-property", Fget_text_property
, Sget_text_property
, 2, 3, 0,
554 "Return the value of POSITION's property PROP, in OBJECT.\n\
555 OBJECT is optional and defaults to the current buffer.\n\
556 If POSITION is at the end of OBJECT, the value is nil.")
557 (position
, prop
, object
)
558 Lisp_Object position
, object
;
561 return textget (Ftext_properties_at (position
, object
), prop
);
564 DEFUN ("get-char-property", Fget_char_property
, Sget_char_property
, 2, 3, 0,
565 "Return the value of POSITION's property PROP, in OBJECT.\n\
566 OBJECT is optional and defaults to the current buffer.\n\
567 If POSITION is at the end of OBJECT, the value is nil.\n\
568 If OBJECT is a buffer, then overlay properties are considered as well as\n\
570 If OBJECT is a window, then that window's buffer is used, but window-specific\n\
571 overlays are considered only if they are associated with OBJECT.")
572 (position
, prop
, object
)
573 Lisp_Object position
, object
;
574 register Lisp_Object prop
;
576 struct window
*w
= 0;
578 CHECK_NUMBER_COERCE_MARKER (position
, 0);
581 XSETBUFFER (object
, current_buffer
);
583 if (WINDOWP (object
))
585 w
= XWINDOW (object
);
588 if (BUFFERP (object
))
590 int posn
= XINT (position
);
592 Lisp_Object
*overlay_vec
, tem
;
595 struct buffer
*obuf
= current_buffer
;
597 set_buffer_temp (XBUFFER (object
));
599 /* First try with room for 40 overlays. */
601 overlay_vec
= (Lisp_Object
*) alloca (len
* sizeof (Lisp_Object
));
603 noverlays
= overlays_at (posn
, 0, &overlay_vec
, &len
,
604 &next_overlay
, NULL
);
606 /* If there are more than 40,
607 make enough space for all, and try again. */
611 overlay_vec
= (Lisp_Object
*) alloca (len
* sizeof (Lisp_Object
));
612 noverlays
= overlays_at (posn
, 0, &overlay_vec
, &len
,
613 &next_overlay
, NULL
);
615 noverlays
= sort_overlays (overlay_vec
, noverlays
, w
);
617 set_buffer_temp (obuf
);
619 /* Now check the overlays in order of decreasing priority. */
620 while (--noverlays
>= 0)
622 tem
= Foverlay_get (overlay_vec
[noverlays
], prop
);
627 /* Not a buffer, or no appropriate overlay, so fall through to the
629 return (Fget_text_property (position
, prop
, object
));
632 DEFUN ("next-char-property-change", Fnext_char_property_change
,
633 Snext_char_property_change
, 1, 2, 0,
634 "Return the position of next text property or overlay change.\n\
635 This scans characters forward from POSITION in OBJECT till it finds\n\
636 a change in some text property, or the beginning or end of an overlay,\n\
637 and returns the position of that.\n\
638 If none is found, the function returns (point-max).\n\
640 If the optional third argument LIMIT is non-nil, don't search\n\
641 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
643 Lisp_Object position
, limit
;
647 temp
= Fnext_overlay_change (position
);
650 CHECK_NUMBER (limit
, 2);
651 if (XINT (limit
) < XINT (temp
))
654 return Fnext_property_change (position
, Qnil
, temp
);
657 DEFUN ("previous-char-property-change", Fprevious_char_property_change
,
658 Sprevious_char_property_change
, 1, 2, 0,
659 "Return the position of previous text property or overlay change.\n\
660 Scans characters backward from POSITION in OBJECT till it finds\n\
661 a change in some text property, or the beginning or end of an overlay,\n\
662 and returns the position of that.\n\
663 If none is found, the function returns (point-max).\n\
665 If the optional third argument LIMIT is non-nil, don't search\n\
666 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
668 Lisp_Object position
, limit
;
672 temp
= Fprevious_overlay_change (position
);
675 CHECK_NUMBER (limit
, 2);
676 if (XINT (limit
) > XINT (temp
))
679 return Fprevious_property_change (position
, Qnil
, temp
);
682 DEFUN ("next-property-change", Fnext_property_change
,
683 Snext_property_change
, 1, 3, 0,
684 "Return the position of next property change.\n\
685 Scans characters forward from POSITION in OBJECT till it finds\n\
686 a change in some text property, then returns the position of the change.\n\
687 The optional second argument OBJECT is the string or buffer to scan.\n\
688 Return nil if the property is constant all the way to the end of OBJECT.\n\
689 If the value is non-nil, it is a position greater than POSITION, never equal.\n\n\
690 If the optional third argument LIMIT is non-nil, don't search\n\
691 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
692 (position
, object
, limit
)
693 Lisp_Object position
, object
, limit
;
695 register INTERVAL i
, next
;
698 XSETBUFFER (object
, current_buffer
);
700 if (! NILP (limit
) && ! EQ (limit
, Qt
))
701 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
703 i
= validate_interval_range (object
, &position
, &position
, soft
);
705 /* If LIMIT is t, return start of next interval--don't
706 bother checking further intervals. */
709 if (NULL_INTERVAL_P (i
))
712 next
= next_interval (i
);
714 if (NULL_INTERVAL_P (next
))
715 XSETFASTINT (position
, (STRINGP (object
)
716 ? XSTRING (object
)->size
717 : BUF_ZV (XBUFFER (object
))));
719 XSETFASTINT (position
, next
->position
- (STRINGP (object
)));
723 if (NULL_INTERVAL_P (i
))
726 next
= next_interval (i
);
728 while (! NULL_INTERVAL_P (next
) && intervals_equal (i
, next
)
730 || next
->position
- (STRINGP (object
)) < XFASTINT (limit
)))
731 next
= next_interval (next
);
733 if (NULL_INTERVAL_P (next
))
736 && !(next
->position
- (STRINGP (object
)) < XFASTINT (limit
)))
739 XSETFASTINT (position
, next
->position
- (STRINGP (object
)));
743 /* Return 1 if there's a change in some property between BEG and END. */
746 property_change_between_p (beg
, end
)
749 register INTERVAL i
, next
;
750 Lisp_Object object
, pos
;
752 XSETBUFFER (object
, current_buffer
);
753 XSETFASTINT (pos
, beg
);
755 i
= validate_interval_range (object
, &pos
, &pos
, soft
);
756 if (NULL_INTERVAL_P (i
))
759 next
= next_interval (i
);
760 while (! NULL_INTERVAL_P (next
) && intervals_equal (i
, next
))
762 next
= next_interval (next
);
763 if (NULL_INTERVAL_P (next
))
765 if (next
->position
- (STRINGP (object
)) >= end
)
769 if (NULL_INTERVAL_P (next
))
775 DEFUN ("next-single-property-change", Fnext_single_property_change
,
776 Snext_single_property_change
, 2, 4, 0,
777 "Return the position of next property change for a specific property.\n\
778 Scans characters forward from POSITION till it finds\n\
779 a change in the PROP property, then returns the position of the change.\n\
780 The optional third argument OBJECT is the string or buffer to scan.\n\
781 The property values are compared with `eq'.\n\
782 Return nil if the property is constant all the way to the end of OBJECT.\n\
783 If the value is non-nil, it is a position greater than POSITION, never equal.\n\n\
784 If the optional fourth argument LIMIT is non-nil, don't search\n\
785 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
786 (position
, prop
, object
, limit
)
787 Lisp_Object position
, prop
, object
, limit
;
789 register INTERVAL i
, next
;
790 register Lisp_Object here_val
;
793 XSETBUFFER (object
, current_buffer
);
796 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
798 i
= validate_interval_range (object
, &position
, &position
, soft
);
799 if (NULL_INTERVAL_P (i
))
802 here_val
= textget (i
->plist
, prop
);
803 next
= next_interval (i
);
804 while (! NULL_INTERVAL_P (next
)
805 && EQ (here_val
, textget (next
->plist
, prop
))
806 && (NILP (limit
) || next
->position
- (STRINGP (object
)) < XFASTINT (limit
)))
807 next
= next_interval (next
);
809 if (NULL_INTERVAL_P (next
))
812 && !(next
->position
- (STRINGP (object
)) < XFASTINT (limit
)))
815 XSETFASTINT (position
, next
->position
- (STRINGP (object
)));
819 DEFUN ("previous-property-change", Fprevious_property_change
,
820 Sprevious_property_change
, 1, 3, 0,
821 "Return the position of previous property change.\n\
822 Scans characters backwards from POSITION in OBJECT till it finds\n\
823 a change in some text property, then returns the position of the change.\n\
824 The optional second argument OBJECT is the string or buffer to scan.\n\
825 Return nil if the property is constant all the way to the start of OBJECT.\n\
826 If the value is non-nil, it is a position less than POSITION, never equal.\n\n\
827 If the optional third argument LIMIT is non-nil, don't search\n\
828 back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
829 (position
, object
, limit
)
830 Lisp_Object position
, object
, limit
;
832 register INTERVAL i
, previous
;
835 XSETBUFFER (object
, current_buffer
);
838 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
840 i
= validate_interval_range (object
, &position
, &position
, soft
);
841 if (NULL_INTERVAL_P (i
))
844 /* Start with the interval containing the char before point. */
845 if (i
->position
== XFASTINT (position
))
846 i
= previous_interval (i
);
848 previous
= previous_interval (i
);
849 while (! NULL_INTERVAL_P (previous
) && intervals_equal (previous
, i
)
851 || (previous
->position
+ LENGTH (previous
) - (STRINGP (object
))
852 > XFASTINT (limit
))))
853 previous
= previous_interval (previous
);
854 if (NULL_INTERVAL_P (previous
))
857 && !(previous
->position
+ LENGTH (previous
) - (STRINGP (object
))
861 XSETFASTINT (position
, (previous
->position
+ LENGTH (previous
)
862 - (STRINGP (object
))));
866 DEFUN ("previous-single-property-change", Fprevious_single_property_change
,
867 Sprevious_single_property_change
, 2, 4, 0,
868 "Return the position of previous property change for a specific property.\n\
869 Scans characters backward from POSITION till it finds\n\
870 a change in the PROP property, then returns the position of the change.\n\
871 The optional third argument OBJECT is the string or buffer to scan.\n\
872 The property values are compared with `eq'.\n\
873 Return nil if the property is constant all the way to the start of OBJECT.\n\
874 If the value is non-nil, it is a position less than POSITION, never equal.\n\n\
875 If the optional fourth argument LIMIT is non-nil, don't search\n\
876 back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
877 (position
, prop
, object
, limit
)
878 Lisp_Object position
, prop
, object
, limit
;
880 register INTERVAL i
, previous
;
881 register Lisp_Object here_val
;
884 XSETBUFFER (object
, current_buffer
);
887 CHECK_NUMBER_COERCE_MARKER (limit
, 0);
889 i
= validate_interval_range (object
, &position
, &position
, soft
);
891 /* Start with the interval containing the char before point. */
892 if (! NULL_INTERVAL_P (i
) && i
->position
== XFASTINT (position
))
893 i
= previous_interval (i
);
895 if (NULL_INTERVAL_P (i
))
898 here_val
= textget (i
->plist
, prop
);
899 previous
= previous_interval (i
);
900 while (! NULL_INTERVAL_P (previous
)
901 && EQ (here_val
, textget (previous
->plist
, prop
))
903 || (previous
->position
+ LENGTH (previous
) - (STRINGP (object
))
904 > XFASTINT (limit
))))
905 previous
= previous_interval (previous
);
906 if (NULL_INTERVAL_P (previous
))
909 && !(previous
->position
+ LENGTH (previous
) - (STRINGP (object
))
913 XSETFASTINT (position
, (previous
->position
+ LENGTH (previous
)
914 - (STRINGP (object
))));
918 /* Callers note, this can GC when OBJECT is a buffer (or nil). */
920 DEFUN ("add-text-properties", Fadd_text_properties
,
921 Sadd_text_properties
, 3, 4, 0,
922 "Add properties to the text from START to END.\n\
923 The third argument PROPERTIES is a property list\n\
924 specifying the property values to add.\n\
925 The optional fourth argument, OBJECT,\n\
926 is the string or buffer containing the text.\n\
927 Return t if any property value actually changed, nil otherwise.")
928 (start
, end
, properties
, object
)
929 Lisp_Object start
, end
, properties
, object
;
931 register INTERVAL i
, unchanged
;
932 register int s
, len
, modified
= 0;
935 properties
= validate_plist (properties
);
936 if (NILP (properties
))
940 XSETBUFFER (object
, current_buffer
);
942 i
= validate_interval_range (object
, &start
, &end
, hard
);
943 if (NULL_INTERVAL_P (i
))
947 len
= XINT (end
) - s
;
949 /* No need to protect OBJECT, because we GC only if it's a buffer,
950 and live buffers are always protected. */
953 /* If we're not starting on an interval boundary, we have to
954 split this interval. */
955 if (i
->position
!= s
)
957 /* If this interval already has the properties, we can
959 if (interval_has_all_properties (properties
, i
))
961 int got
= (LENGTH (i
) - (s
- i
->position
));
963 RETURN_UNGCPRO (Qnil
);
965 i
= next_interval (i
);
970 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
971 copy_properties (unchanged
, i
);
975 if (BUFFERP (object
))
976 modify_region (XBUFFER (object
), XINT (start
), XINT (end
));
978 /* We are at the beginning of interval I, with LEN chars to scan. */
984 if (LENGTH (i
) >= len
)
986 /* We can UNGCPRO safely here, because there will be just
987 one more chance to gc, in the next call to add_properties,
988 and after that we will not need PROPERTIES or OBJECT again. */
991 if (interval_has_all_properties (properties
, i
))
993 if (BUFFERP (object
))
994 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
995 XINT (end
) - XINT (start
));
997 return modified
? Qt
: Qnil
;
1000 if (LENGTH (i
) == len
)
1002 add_properties (properties
, i
, object
);
1003 if (BUFFERP (object
))
1004 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1005 XINT (end
) - XINT (start
));
1009 /* i doesn't have the properties, and goes past the change limit */
1011 i
= split_interval_left (unchanged
, len
);
1012 copy_properties (unchanged
, i
);
1013 add_properties (properties
, i
, object
);
1014 if (BUFFERP (object
))
1015 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1016 XINT (end
) - XINT (start
));
1021 modified
+= add_properties (properties
, i
, object
);
1022 i
= next_interval (i
);
1026 /* Callers note, this can GC when OBJECT is a buffer (or nil). */
1028 DEFUN ("put-text-property", Fput_text_property
,
1029 Sput_text_property
, 4, 5, 0,
1030 "Set one property of the text from START to END.\n\
1031 The third and fourth arguments PROPERTY and VALUE\n\
1032 specify the property to add.\n\
1033 The optional fifth argument, OBJECT,\n\
1034 is the string or buffer containing the text.")
1035 (start
, end
, property
, value
, object
)
1036 Lisp_Object start
, end
, property
, value
, object
;
1038 Fadd_text_properties (start
, end
,
1039 Fcons (property
, Fcons (value
, Qnil
)),
1044 DEFUN ("set-text-properties", Fset_text_properties
,
1045 Sset_text_properties
, 3, 4, 0,
1046 "Completely replace properties of text from START to END.\n\
1047 The third argument PROPERTIES is the new property list.\n\
1048 The optional fourth argument, OBJECT,\n\
1049 is the string or buffer containing the text.")
1050 (start
, end
, properties
, object
)
1051 Lisp_Object start
, end
, properties
, object
;
1053 register INTERVAL i
, unchanged
;
1054 register INTERVAL prev_changed
= NULL_INTERVAL
;
1055 register int s
, len
;
1056 Lisp_Object ostart
, oend
;
1057 int have_modified
= 0;
1062 properties
= validate_plist (properties
);
1065 XSETBUFFER (object
, current_buffer
);
1067 /* If we want no properties for a whole string,
1068 get rid of its intervals. */
1069 if (NILP (properties
) && STRINGP (object
)
1070 && XFASTINT (start
) == 0
1071 && XFASTINT (end
) == XSTRING (object
)->size
)
1073 if (! XSTRING (object
)->intervals
)
1076 XSTRING (object
)->intervals
= 0;
1080 i
= validate_interval_range (object
, &start
, &end
, soft
);
1082 if (NULL_INTERVAL_P (i
))
1084 /* If buffer has no properties, and we want none, return now. */
1085 if (NILP (properties
))
1088 /* Restore the original START and END values
1089 because validate_interval_range increments them for strings. */
1093 i
= validate_interval_range (object
, &start
, &end
, hard
);
1094 /* This can return if start == end. */
1095 if (NULL_INTERVAL_P (i
))
1100 len
= XINT (end
) - s
;
1102 if (BUFFERP (object
))
1103 modify_region (XBUFFER (object
), XINT (start
), XINT (end
));
1105 if (i
->position
!= s
)
1108 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
1110 if (LENGTH (i
) > len
)
1112 copy_properties (unchanged
, i
);
1113 i
= split_interval_left (i
, len
);
1114 set_properties (properties
, i
, object
);
1115 if (BUFFERP (object
))
1116 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1117 XINT (end
) - XINT (start
));
1122 set_properties (properties
, i
, object
);
1124 if (LENGTH (i
) == len
)
1126 if (BUFFERP (object
))
1127 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1128 XINT (end
) - XINT (start
));
1135 i
= next_interval (i
);
1138 /* We are starting at the beginning of an interval, I */
1144 if (LENGTH (i
) >= len
)
1146 if (LENGTH (i
) > len
)
1147 i
= split_interval_left (i
, len
);
1149 /* We have to call set_properties even if we are going to
1150 merge the intervals, so as to make the undo records
1151 and cause redisplay to happen. */
1152 set_properties (properties
, i
, object
);
1153 if (!NULL_INTERVAL_P (prev_changed
))
1154 merge_interval_left (i
);
1155 if (BUFFERP (object
))
1156 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1157 XINT (end
) - XINT (start
));
1163 /* We have to call set_properties even if we are going to
1164 merge the intervals, so as to make the undo records
1165 and cause redisplay to happen. */
1166 set_properties (properties
, i
, object
);
1167 if (NULL_INTERVAL_P (prev_changed
))
1170 prev_changed
= i
= merge_interval_left (i
);
1172 i
= next_interval (i
);
1175 if (BUFFERP (object
))
1176 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1177 XINT (end
) - XINT (start
));
1181 DEFUN ("remove-text-properties", Fremove_text_properties
,
1182 Sremove_text_properties
, 3, 4, 0,
1183 "Remove some properties from text from START to END.\n\
1184 The third argument PROPERTIES is a property list\n\
1185 whose property names specify the properties to remove.\n\
1186 \(The values stored in PROPERTIES are ignored.)\n\
1187 The optional fourth argument, OBJECT,\n\
1188 is the string or buffer containing the text.\n\
1189 Return t if any property was actually removed, nil otherwise.")
1190 (start
, end
, properties
, object
)
1191 Lisp_Object start
, end
, properties
, object
;
1193 register INTERVAL i
, unchanged
;
1194 register int s
, len
, modified
= 0;
1197 XSETBUFFER (object
, current_buffer
);
1199 i
= validate_interval_range (object
, &start
, &end
, soft
);
1200 if (NULL_INTERVAL_P (i
))
1204 len
= XINT (end
) - s
;
1206 if (i
->position
!= s
)
1208 /* No properties on this first interval -- return if
1209 it covers the entire region. */
1210 if (! interval_has_some_properties (properties
, i
))
1212 int got
= (LENGTH (i
) - (s
- i
->position
));
1216 i
= next_interval (i
);
1218 /* Split away the beginning of this interval; what we don't
1223 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
1224 copy_properties (unchanged
, i
);
1228 if (BUFFERP (object
))
1229 modify_region (XBUFFER (object
), XINT (start
), XINT (end
));
1231 /* We are at the beginning of an interval, with len to scan */
1237 if (LENGTH (i
) >= len
)
1239 if (! interval_has_some_properties (properties
, i
))
1240 return modified
? Qt
: Qnil
;
1242 if (LENGTH (i
) == len
)
1244 remove_properties (properties
, i
, object
);
1245 if (BUFFERP (object
))
1246 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1247 XINT (end
) - XINT (start
));
1251 /* i has the properties, and goes past the change limit */
1253 i
= split_interval_left (i
, len
);
1254 copy_properties (unchanged
, i
);
1255 remove_properties (properties
, i
, object
);
1256 if (BUFFERP (object
))
1257 signal_after_change (XINT (start
), XINT (end
) - XINT (start
),
1258 XINT (end
) - XINT (start
));
1263 modified
+= remove_properties (properties
, i
, object
);
1264 i
= next_interval (i
);
1268 DEFUN ("text-property-any", Ftext_property_any
,
1269 Stext_property_any
, 4, 5, 0,
1270 "Check text from START to END for property PROPERTY equalling VALUE.\n\
1271 If so, return the position of the first character whose property PROPERTY\n\
1272 is `eq' to VALUE. Otherwise return nil.\n\
1273 The optional fifth argument, OBJECT, is the string or buffer\n\
1274 containing the text.")
1275 (start
, end
, property
, value
, object
)
1276 Lisp_Object start
, end
, property
, value
, object
;
1278 register INTERVAL i
;
1279 register int e
, pos
;
1282 XSETBUFFER (object
, current_buffer
);
1283 i
= validate_interval_range (object
, &start
, &end
, soft
);
1284 if (NULL_INTERVAL_P (i
))
1285 return (!NILP (value
) || EQ (start
, end
) ? Qnil
: start
);
1288 while (! NULL_INTERVAL_P (i
))
1290 if (i
->position
>= e
)
1292 if (EQ (textget (i
->plist
, property
), value
))
1295 if (pos
< XINT (start
))
1297 return make_number (pos
- (STRINGP (object
)));
1299 i
= next_interval (i
);
1304 DEFUN ("text-property-not-all", Ftext_property_not_all
,
1305 Stext_property_not_all
, 4, 5, 0,
1306 "Check text from START to END for property PROPERTY not equalling VALUE.\n\
1307 If so, return the position of the first character whose property PROPERTY\n\
1308 is not `eq' to VALUE. Otherwise, return nil.\n\
1309 The optional fifth argument, OBJECT, is the string or buffer\n\
1310 containing the text.")
1311 (start
, end
, property
, value
, object
)
1312 Lisp_Object start
, end
, property
, value
, object
;
1314 register INTERVAL i
;
1318 XSETBUFFER (object
, current_buffer
);
1319 i
= validate_interval_range (object
, &start
, &end
, soft
);
1320 if (NULL_INTERVAL_P (i
))
1321 return (NILP (value
) || EQ (start
, end
)) ? Qnil
: start
;
1325 while (! NULL_INTERVAL_P (i
))
1327 if (i
->position
>= e
)
1329 if (! EQ (textget (i
->plist
, property
), value
))
1331 if (i
->position
> s
)
1333 return make_number (s
- (STRINGP (object
)));
1335 i
= next_interval (i
);
1340 #if 0 /* You can use set-text-properties for this. */
1342 DEFUN ("erase-text-properties", Ferase_text_properties
,
1343 Serase_text_properties
, 2, 3, 0,
1344 "Remove all properties from the text from START to END.\n\
1345 The optional third argument, OBJECT,\n\
1346 is the string or buffer containing the text.")
1347 (start
, end
, object
)
1348 Lisp_Object start
, end
, object
;
1350 register INTERVAL i
;
1351 register INTERVAL prev_changed
= NULL_INTERVAL
;
1352 register int s
, len
, modified
;
1355 XSETBUFFER (object
, current_buffer
);
1357 i
= validate_interval_range (object
, &start
, &end
, soft
);
1358 if (NULL_INTERVAL_P (i
))
1362 len
= XINT (end
) - s
;
1364 if (i
->position
!= s
)
1367 register INTERVAL unchanged
= i
;
1369 /* If there are properties here, then this text will be modified. */
1370 if (! NILP (i
->plist
))
1372 i
= split_interval_right (unchanged
, s
- unchanged
->position
);
1376 if (LENGTH (i
) > len
)
1378 i
= split_interval_right (i
, len
);
1379 copy_properties (unchanged
, i
);
1383 if (LENGTH (i
) == len
)
1388 /* If the text of I is without any properties, and contains
1389 LEN or more characters, then we may return without changing
1391 else if (LENGTH (i
) - (s
- i
->position
) <= len
)
1393 /* The amount of text to change extends past I, so just note
1394 how much we've gotten. */
1396 got
= LENGTH (i
) - (s
- i
->position
);
1400 i
= next_interval (i
);
1403 /* We are starting at the beginning of an interval, I. */
1406 if (LENGTH (i
) >= len
)
1408 /* If I has no properties, simply merge it if possible. */
1409 if (NILP (i
->plist
))
1411 if (! NULL_INTERVAL_P (prev_changed
))
1412 merge_interval_left (i
);
1414 return modified
? Qt
: Qnil
;
1417 if (LENGTH (i
) > len
)
1418 i
= split_interval_left (i
, len
);
1419 if (! NULL_INTERVAL_P (prev_changed
))
1420 merge_interval_left (i
);
1427 /* Here if we still need to erase past the end of I */
1429 if (NULL_INTERVAL_P (prev_changed
))
1431 modified
+= erase_properties (i
);
1436 modified
+= ! NILP (i
->plist
);
1437 /* Merging I will give it the properties of PREV_CHANGED. */
1438 prev_changed
= i
= merge_interval_left (i
);
1441 i
= next_interval (i
);
1444 return modified
? Qt
: Qnil
;
1448 /* I don't think this is the right interface to export; how often do you
1449 want to do something like this, other than when you're copying objects
1452 I think it would be better to have a pair of functions, one which
1453 returns the text properties of a region as a list of ranges and
1454 plists, and another which applies such a list to another object. */
1456 /* Add properties from SRC to SRC of SRC, starting at POS in DEST.
1457 SRC and DEST may each refer to strings or buffers.
1458 Optional sixth argument PROP causes only that property to be copied.
1459 Properties are copied to DEST as if by `add-text-properties'.
1460 Return t if any property value actually changed, nil otherwise. */
1462 /* Note this can GC when DEST is a buffer. */
1465 copy_text_properties (start
, end
, src
, pos
, dest
, prop
)
1466 Lisp_Object start
, end
, src
, pos
, dest
, prop
;
1472 int s
, e
, e2
, p
, len
, modified
= 0;
1473 struct gcpro gcpro1
, gcpro2
;
1475 i
= validate_interval_range (src
, &start
, &end
, soft
);
1476 if (NULL_INTERVAL_P (i
))
1479 CHECK_NUMBER_COERCE_MARKER (pos
, 0);
1481 Lisp_Object dest_start
, dest_end
;
1484 XSETFASTINT (dest_end
, XINT (dest_start
) + (XINT (end
) - XINT (start
)));
1485 /* Apply this to a copy of pos; it will try to increment its arguments,
1486 which we don't want. */
1487 validate_interval_range (dest
, &dest_start
, &dest_end
, soft
);
1498 e2
= i
->position
+ LENGTH (i
);
1505 while (! NILP (plist
))
1507 if (EQ (Fcar (plist
), prop
))
1509 plist
= Fcons (prop
, Fcons (Fcar (Fcdr (plist
)), Qnil
));
1512 plist
= Fcdr (Fcdr (plist
));
1516 /* Must defer modifications to the interval tree in case src
1517 and dest refer to the same string or buffer. */
1518 stuff
= Fcons (Fcons (make_number (p
),
1519 Fcons (make_number (p
+ len
),
1520 Fcons (plist
, Qnil
))),
1524 i
= next_interval (i
);
1525 if (NULL_INTERVAL_P (i
))
1532 GCPRO2 (stuff
, dest
);
1534 while (! NILP (stuff
))
1537 res
= Fadd_text_properties (Fcar (res
), Fcar (Fcdr (res
)),
1538 Fcar (Fcdr (Fcdr (res
))), dest
);
1541 stuff
= Fcdr (stuff
);
1546 return modified
? Qt
: Qnil
;
1549 /* Call the modification hook functions in LIST, each with START and END. */
1552 call_mod_hooks (list
, start
, end
)
1553 Lisp_Object list
, start
, end
;
1555 struct gcpro gcpro1
;
1557 while (!NILP (list
))
1559 call2 (Fcar (list
), start
, end
);
1565 /* Check for read-only intervals between character positions START ... END,
1566 in BUF, and signal an error if we find one.
1568 Then check for any modification hooks in the range.
1569 Create a list of all these hooks in lexicographic order,
1570 eliminating consecutive extra copies of the same hook. Then call
1571 those hooks in order, with START and END - 1 as arguments. */
1574 verify_interval_modification (buf
, start
, end
)
1578 register INTERVAL intervals
= BUF_INTERVALS (buf
);
1579 register INTERVAL i
, prev
;
1581 register Lisp_Object prev_mod_hooks
;
1582 Lisp_Object mod_hooks
;
1583 struct gcpro gcpro1
;
1586 prev_mod_hooks
= Qnil
;
1589 interval_insert_behind_hooks
= Qnil
;
1590 interval_insert_in_front_hooks
= Qnil
;
1592 if (NULL_INTERVAL_P (intervals
))
1602 /* For an insert operation, check the two chars around the position. */
1606 Lisp_Object before
, after
;
1608 /* Set I to the interval containing the char after START,
1609 and PREV to the interval containing the char before START.
1610 Either one may be null. They may be equal. */
1611 i
= find_interval (intervals
, start
);
1613 if (start
== BUF_BEGV (buf
))
1615 else if (i
->position
== start
)
1616 prev
= previous_interval (i
);
1617 else if (i
->position
< start
)
1619 if (start
== BUF_ZV (buf
))
1622 /* If Vinhibit_read_only is set and is not a list, we can
1623 skip the read_only checks. */
1624 if (NILP (Vinhibit_read_only
) || CONSP (Vinhibit_read_only
))
1626 /* If I and PREV differ we need to check for the read-only
1627 property together with its stickiness. If either I or
1628 PREV are 0, this check is all we need.
1629 We have to take special care, since read-only may be
1630 indirectly defined via the category property. */
1633 if (! NULL_INTERVAL_P (i
))
1635 after
= textget (i
->plist
, Qread_only
);
1637 /* If interval I is read-only and read-only is
1638 front-sticky, inhibit insertion.
1639 Check for read-only as well as category. */
1641 && NILP (Fmemq (after
, Vinhibit_read_only
)))
1645 tem
= textget (i
->plist
, Qfront_sticky
);
1646 if (TMEM (Qread_only
, tem
)
1647 || (NILP (Fplist_get (i
->plist
, Qread_only
))
1648 && TMEM (Qcategory
, tem
)))
1649 error ("Attempt to insert within read-only text");
1653 if (! NULL_INTERVAL_P (prev
))
1655 before
= textget (prev
->plist
, Qread_only
);
1657 /* If interval PREV is read-only and read-only isn't
1658 rear-nonsticky, inhibit insertion.
1659 Check for read-only as well as category. */
1661 && NILP (Fmemq (before
, Vinhibit_read_only
)))
1665 tem
= textget (prev
->plist
, Qrear_nonsticky
);
1666 if (! TMEM (Qread_only
, tem
)
1667 && (! NILP (Fplist_get (prev
->plist
,Qread_only
))
1668 || ! TMEM (Qcategory
, tem
)))
1669 error ("Attempt to insert within read-only text");
1673 else if (! NULL_INTERVAL_P (i
))
1675 after
= textget (i
->plist
, Qread_only
);
1677 /* If interval I is read-only and read-only is
1678 front-sticky, inhibit insertion.
1679 Check for read-only as well as category. */
1680 if (! NILP (after
) && NILP (Fmemq (after
, Vinhibit_read_only
)))
1684 tem
= textget (i
->plist
, Qfront_sticky
);
1685 if (TMEM (Qread_only
, tem
)
1686 || (NILP (Fplist_get (i
->plist
, Qread_only
))
1687 && TMEM (Qcategory
, tem
)))
1688 error ("Attempt to insert within read-only text");
1690 tem
= textget (prev
->plist
, Qrear_nonsticky
);
1691 if (! TMEM (Qread_only
, tem
)
1692 && (! NILP (Fplist_get (prev
->plist
, Qread_only
))
1693 || ! TMEM (Qcategory
, tem
)))
1694 error ("Attempt to insert within read-only text");
1699 /* Run both insert hooks (just once if they're the same). */
1700 if (!NULL_INTERVAL_P (prev
))
1701 interval_insert_behind_hooks
1702 = textget (prev
->plist
, Qinsert_behind_hooks
);
1703 if (!NULL_INTERVAL_P (i
))
1704 interval_insert_in_front_hooks
1705 = textget (i
->plist
, Qinsert_in_front_hooks
);
1709 /* Loop over intervals on or next to START...END,
1710 collecting their hooks. */
1712 i
= find_interval (intervals
, start
);
1715 if (! INTERVAL_WRITABLE_P (i
))
1716 error ("Attempt to modify read-only text");
1718 mod_hooks
= textget (i
->plist
, Qmodification_hooks
);
1719 if (! NILP (mod_hooks
) && ! EQ (mod_hooks
, prev_mod_hooks
))
1721 hooks
= Fcons (mod_hooks
, hooks
);
1722 prev_mod_hooks
= mod_hooks
;
1725 i
= next_interval (i
);
1727 /* Keep going thru the interval containing the char before END. */
1728 while (! NULL_INTERVAL_P (i
) && i
->position
< end
);
1731 hooks
= Fnreverse (hooks
);
1732 while (! EQ (hooks
, Qnil
))
1734 call_mod_hooks (Fcar (hooks
), make_number (start
),
1736 hooks
= Fcdr (hooks
);
1742 /* Run the interval hooks for an insertion on character range START ... END.
1743 verify_interval_modification chose which hooks to run;
1744 this function is called after the insertion happens
1745 so it can indicate the range of inserted text. */
1748 report_interval_modification (start
, end
)
1749 Lisp_Object start
, end
;
1751 if (! NILP (interval_insert_behind_hooks
))
1752 call_mod_hooks (interval_insert_behind_hooks
, start
, end
);
1753 if (! NILP (interval_insert_in_front_hooks
)
1754 && ! EQ (interval_insert_in_front_hooks
,
1755 interval_insert_behind_hooks
))
1756 call_mod_hooks (interval_insert_in_front_hooks
, start
, end
);
1762 DEFVAR_LISP ("default-text-properties", &Vdefault_text_properties
,
1763 "Property-list used as default values.\n\
1764 The value of a property in this list is seen as the value for every\n\
1765 character that does not have its own value for that property.");
1766 Vdefault_text_properties
= Qnil
;
1768 DEFVAR_LISP ("inhibit-point-motion-hooks", &Vinhibit_point_motion_hooks
,
1769 "If non-nil, don't run `point-left' and `point-entered' text properties.\n\
1770 This also inhibits the use of the `intangible' text property.");
1771 Vinhibit_point_motion_hooks
= Qnil
;
1773 staticpro (&interval_insert_behind_hooks
);
1774 staticpro (&interval_insert_in_front_hooks
);
1775 interval_insert_behind_hooks
= Qnil
;
1776 interval_insert_in_front_hooks
= Qnil
;
1779 /* Common attributes one might give text */
1781 staticpro (&Qforeground
);
1782 Qforeground
= intern ("foreground");
1783 staticpro (&Qbackground
);
1784 Qbackground
= intern ("background");
1786 Qfont
= intern ("font");
1787 staticpro (&Qstipple
);
1788 Qstipple
= intern ("stipple");
1789 staticpro (&Qunderline
);
1790 Qunderline
= intern ("underline");
1791 staticpro (&Qread_only
);
1792 Qread_only
= intern ("read-only");
1793 staticpro (&Qinvisible
);
1794 Qinvisible
= intern ("invisible");
1795 staticpro (&Qintangible
);
1796 Qintangible
= intern ("intangible");
1797 staticpro (&Qcategory
);
1798 Qcategory
= intern ("category");
1799 staticpro (&Qlocal_map
);
1800 Qlocal_map
= intern ("local-map");
1801 staticpro (&Qfront_sticky
);
1802 Qfront_sticky
= intern ("front-sticky");
1803 staticpro (&Qrear_nonsticky
);
1804 Qrear_nonsticky
= intern ("rear-nonsticky");
1806 /* Properties that text might use to specify certain actions */
1808 staticpro (&Qmouse_left
);
1809 Qmouse_left
= intern ("mouse-left");
1810 staticpro (&Qmouse_entered
);
1811 Qmouse_entered
= intern ("mouse-entered");
1812 staticpro (&Qpoint_left
);
1813 Qpoint_left
= intern ("point-left");
1814 staticpro (&Qpoint_entered
);
1815 Qpoint_entered
= intern ("point-entered");
1817 defsubr (&Stext_properties_at
);
1818 defsubr (&Sget_text_property
);
1819 defsubr (&Sget_char_property
);
1820 defsubr (&Snext_char_property_change
);
1821 defsubr (&Sprevious_char_property_change
);
1822 defsubr (&Snext_property_change
);
1823 defsubr (&Snext_single_property_change
);
1824 defsubr (&Sprevious_property_change
);
1825 defsubr (&Sprevious_single_property_change
);
1826 defsubr (&Sadd_text_properties
);
1827 defsubr (&Sput_text_property
);
1828 defsubr (&Sset_text_properties
);
1829 defsubr (&Sremove_text_properties
);
1830 defsubr (&Stext_property_any
);
1831 defsubr (&Stext_property_not_all
);
1832 /* defsubr (&Serase_text_properties); */
1833 /* defsubr (&Scopy_text_properties); */
1838 lose
-- this shouldn
't be compiled if USE_TEXT_PROPERTIES isn't defined
1840 #endif /* USE_TEXT_PROPERTIES */