Mercurial > emacs
annotate src/textprop.c @ 10360:c68e5b8456e1
[XENIX|SOLARIS2] (VALBITS, GCTYPEBITS): Deleted; default is better.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 07 Jan 1995 00:19:51 +0000 |
parents | 4bf079c613c6 |
children | 701e7acfe885 |
rev | line source |
---|---|
1029 | 1 /* Interface code for dealing with text properties. |
7307 | 2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
1029 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
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 | |
3698 | 8 the Free Software Foundation; either version 2, or (at your option) |
1029 | 9 any later version. |
10 | |
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. | |
15 | |
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, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4649
diff
changeset
|
20 #include <config.h> |
1029 | 21 #include "lisp.h" |
22 #include "intervals.h" | |
23 #include "buffer.h" | |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
24 #include "window.h" |
8962
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
25 |
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
26 #ifndef NULL |
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
27 #define NULL (void *)0 |
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
28 #endif |
1029 | 29 |
30 | |
31 /* NOTES: previous- and next- property change will have to skip | |
32 zero-length intervals if they are implemented. This could be done | |
33 inside next_interval and previous_interval. | |
34 | |
1211 | 35 set_properties needs to deal with the interval property cache. |
36 | |
1029 | 37 It is assumed that for any interval plist, a property appears |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
38 only once on the list. Although some code i.e., remove_properties, |
1029 | 39 handles the more general case, the uniqueness of properties is |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3553
diff
changeset
|
40 necessary for the system to remain consistent. This requirement |
1029 | 41 is enforced by the subrs installing properties onto the intervals. */ |
42 | |
1302
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
43 /* The rest of the file is within this conditional */ |
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
44 #ifdef USE_TEXT_PROPERTIES |
1029 | 45 |
46 /* Types of hooks. */ | |
47 Lisp_Object Qmouse_left; | |
48 Lisp_Object Qmouse_entered; | |
49 Lisp_Object Qpoint_left; | |
50 Lisp_Object Qpoint_entered; | |
2058
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
51 Lisp_Object Qcategory; |
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
52 Lisp_Object Qlocal_map; |
1029 | 53 |
54 /* Visual properties text (including strings) may have. */ | |
55 Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple; | |
6755
a2bccbc870e6
(syms_of_textprop): Initialize Qintangible.
Karl Heuer <kwzh@gnu.org>
parents:
6681
diff
changeset
|
56 Lisp_Object Qinvisible, Qread_only, Qintangible; |
4381
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
57 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
58 /* Sticky properties */ |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
59 Lisp_Object Qfront_sticky, Qrear_nonsticky; |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
60 |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
61 /* If o1 is a cons whose cdr is a cons, return non-zero and set o2 to |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
62 the o1's cdr. Otherwise, return zero. This is handy for |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
63 traversing plists. */ |
9945
9b2ecbd894e4
(PLIST_ELT_P): Avoid assignments in arguments to a type-test macro.
Karl Heuer <kwzh@gnu.org>
parents:
9541
diff
changeset
|
64 #define PLIST_ELT_P(o1, o2) (CONSP (o1) && ((o2)=XCONS (o1)->cdr, CONSP (o2))) |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
65 |
4242
49007dbbec4c
(syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4214
diff
changeset
|
66 Lisp_Object Vinhibit_point_motion_hooks; |
49007dbbec4c
(syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4214
diff
changeset
|
67 |
1029 | 68 |
1055 | 69 /* Extract the interval at the position pointed to by BEGIN from |
70 OBJECT, a string or buffer. Additionally, check that the positions | |
71 pointed to by BEGIN and END are within the bounds of OBJECT, and | |
72 reverse them if *BEGIN is greater than *END. The objects pointed | |
73 to by BEGIN and END may be integers or markers; if the latter, they | |
74 are coerced to integers. | |
1029 | 75 |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
76 When OBJECT is a string, we increment *BEGIN and *END |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
77 to make them origin-one. |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
78 |
1029 | 79 Note that buffer points don't correspond to interval indices. |
80 For example, point-max is 1 greater than the index of the last | |
81 character. This difference is handled in the caller, which uses | |
82 the validated points to determine a length, and operates on that. | |
83 Exceptions are Ftext_properties_at, Fnext_property_change, and | |
84 Fprevious_property_change which call this function with BEGIN == END. | |
85 Handle this case specially. | |
86 | |
87 If FORCE is soft (0), it's OK to return NULL_INTERVAL. Otherwise, | |
1055 | 88 create an interval tree for OBJECT if one doesn't exist, provided |
89 the object actually contains text. In the current design, if there | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
90 is no text, there can be no text properties. */ |
1029 | 91 |
92 #define soft 0 | |
93 #define hard 1 | |
94 | |
95 static INTERVAL | |
96 validate_interval_range (object, begin, end, force) | |
97 Lisp_Object object, *begin, *end; | |
98 int force; | |
99 { | |
100 register INTERVAL i; | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
101 int searchpos; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
102 |
1029 | 103 CHECK_STRING_OR_BUFFER (object, 0); |
104 CHECK_NUMBER_COERCE_MARKER (*begin, 0); | |
105 CHECK_NUMBER_COERCE_MARKER (*end, 0); | |
106 | |
107 /* If we are asked for a point, but from a subr which operates | |
108 on a range, then return nothing. */ | |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
109 if (EQ (*begin, *end) && begin != end) |
1029 | 110 return NULL_INTERVAL; |
111 | |
112 if (XINT (*begin) > XINT (*end)) | |
113 { | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
114 Lisp_Object n; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
115 n = *begin; |
1029 | 116 *begin = *end; |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
117 *end = n; |
1029 | 118 } |
119 | |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
120 if (BUFFERP (object)) |
1029 | 121 { |
122 register struct buffer *b = XBUFFER (object); | |
123 | |
124 if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end) | |
125 && XINT (*end) <= BUF_ZV (b))) | |
126 args_out_of_range (*begin, *end); | |
10312
4bf079c613c6
(validate_interval_range): Use BUF_INTERVALS.
Richard M. Stallman <rms@gnu.org>
parents:
10159
diff
changeset
|
127 i = BUF_INTERVALS (b); |
1029 | 128 |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
129 /* If there's no text, there are no properties. */ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
130 if (BUF_BEGV (b) == BUF_ZV (b)) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
131 return NULL_INTERVAL; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
132 |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
133 searchpos = XINT (*begin); |
1029 | 134 } |
135 else | |
136 { | |
137 register struct Lisp_String *s = XSTRING (object); | |
138 | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
139 if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end) |
1029 | 140 && XINT (*end) <= s->size)) |
141 args_out_of_range (*begin, *end); | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
142 /* User-level Positions in strings start with 0, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
143 but the interval code always wants positions starting with 1. */ |
9331
bbf226780027
(validate_interval_range): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9321
diff
changeset
|
144 XSETFASTINT (*begin, XFASTINT (*begin) + 1); |
3996
b9bdcf862c67
* textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents:
3960
diff
changeset
|
145 if (begin != end) |
9331
bbf226780027
(validate_interval_range): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9321
diff
changeset
|
146 XSETFASTINT (*end, XFASTINT (*end) + 1); |
1029 | 147 i = s->intervals; |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
148 |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
149 if (s->size == 0) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
150 return NULL_INTERVAL; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
151 |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
152 searchpos = XINT (*begin); |
1029 | 153 } |
154 | |
155 if (NULL_INTERVAL_P (i)) | |
156 return (force ? create_root_interval (object) : i); | |
157 | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
158 return find_interval (i, searchpos); |
1029 | 159 } |
160 | |
161 /* Validate LIST as a property list. If LIST is not a list, then | |
162 make one consisting of (LIST nil). Otherwise, verify that LIST | |
163 is even numbered and thus suitable as a plist. */ | |
164 | |
165 static Lisp_Object | |
166 validate_plist (list) | |
4797
4dd43e41207a
(validate_plist): Add argument declaration for `list'.
Brian Fox <bfox@gnu.org>
parents:
4696
diff
changeset
|
167 Lisp_Object list; |
1029 | 168 { |
169 if (NILP (list)) | |
170 return Qnil; | |
171 | |
172 if (CONSP (list)) | |
173 { | |
174 register int i; | |
175 register Lisp_Object tail; | |
176 for (i = 0, tail = list; !NILP (tail); i++) | |
3996
b9bdcf862c67
* textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents:
3960
diff
changeset
|
177 { |
b9bdcf862c67
* textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents:
3960
diff
changeset
|
178 tail = Fcdr (tail); |
b9bdcf862c67
* textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents:
3960
diff
changeset
|
179 QUIT; |
b9bdcf862c67
* textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents:
3960
diff
changeset
|
180 } |
1029 | 181 if (i & 1) |
182 error ("Odd length text property list"); | |
183 return list; | |
184 } | |
185 | |
186 return Fcons (list, Fcons (Qnil, Qnil)); | |
187 } | |
188 | |
189 /* Return nonzero if interval I has all the properties, | |
190 with the same values, of list PLIST. */ | |
191 | |
192 static int | |
193 interval_has_all_properties (plist, i) | |
194 Lisp_Object plist; | |
195 INTERVAL i; | |
196 { | |
197 register Lisp_Object tail1, tail2, sym1, sym2; | |
198 register int found; | |
199 | |
200 /* Go through each element of PLIST. */ | |
201 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
202 { | |
203 sym1 = Fcar (tail1); | |
204 found = 0; | |
205 | |
206 /* Go through I's plist, looking for sym1 */ | |
207 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | |
208 if (EQ (sym1, Fcar (tail2))) | |
209 { | |
210 /* Found the same property on both lists. If the | |
211 values are unequal, return zero. */ | |
3998
c0560357c84e
Compare the values of text properties using EQ, not Fequal.
Jim Blandy <jimb@redhat.com>
parents:
3996
diff
changeset
|
212 if (! EQ (Fcar (Fcdr (tail1)), Fcar (Fcdr (tail2)))) |
1029 | 213 return 0; |
214 | |
215 /* Property has same value on both lists; go to next one. */ | |
216 found = 1; | |
217 break; | |
218 } | |
219 | |
220 if (! found) | |
221 return 0; | |
222 } | |
223 | |
224 return 1; | |
225 } | |
226 | |
227 /* Return nonzero if the plist of interval I has any of the | |
228 properties of PLIST, regardless of their values. */ | |
229 | |
230 static INLINE int | |
231 interval_has_some_properties (plist, i) | |
232 Lisp_Object plist; | |
233 INTERVAL i; | |
234 { | |
235 register Lisp_Object tail1, tail2, sym; | |
236 | |
237 /* Go through each element of PLIST. */ | |
238 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
239 { | |
240 sym = Fcar (tail1); | |
241 | |
242 /* Go through i's plist, looking for tail1 */ | |
243 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | |
244 if (EQ (sym, Fcar (tail2))) | |
245 return 1; | |
246 } | |
247 | |
248 return 0; | |
249 } | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
250 |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
251 /* Changing the plists of individual intervals. */ |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
252 |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
253 /* Return the value of PROP in property-list PLIST, or Qunbound if it |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
254 has none. */ |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
255 static Lisp_Object |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
256 property_value (plist, prop) |
8856
7e9547af43e8
(property_value): Declare args plist, prop.
Richard M. Stallman <rms@gnu.org>
parents:
8762
diff
changeset
|
257 Lisp_Object plist, prop; |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
258 { |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
259 Lisp_Object value; |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
260 |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
261 while (PLIST_ELT_P (plist, value)) |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
262 if (EQ (XCONS (plist)->car, prop)) |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
263 return XCONS (value)->car; |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
264 else |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
265 plist = XCONS (value)->cdr; |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
266 |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
267 return Qunbound; |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
268 } |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
269 |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
270 /* Set the properties of INTERVAL to PROPERTIES, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
271 and record undo info for the previous values. |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
272 OBJECT is the string or buffer that INTERVAL belongs to. */ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
273 |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
274 static void |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
275 set_properties (properties, interval, object) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
276 Lisp_Object properties, object; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
277 INTERVAL interval; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
278 { |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
279 Lisp_Object sym, value; |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
280 |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
281 if (BUFFERP (object)) |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
282 { |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
283 /* For each property in the old plist which is missing from PROPERTIES, |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
284 or has a different value in PROPERTIES, make an undo record. */ |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
285 for (sym = interval->plist; |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
286 PLIST_ELT_P (sym, value); |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
287 sym = XCONS (value)->cdr) |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
288 if (! EQ (property_value (properties, XCONS (sym)->car), |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
289 XCONS (value)->car)) |
4076
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
290 { |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
291 modify_region (XBUFFER (object), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
292 make_number (interval->position), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
293 make_number (interval->position + LENGTH (interval))); |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
294 record_property_change (interval->position, LENGTH (interval), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
295 XCONS (sym)->car, XCONS (value)->car, |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
296 object); |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
297 } |
3960
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
298 |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
299 /* For each new property that has no value at all in the old plist, |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
300 make an undo record binding it to nil, so it will be removed. */ |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
301 for (sym = properties; |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
302 PLIST_ELT_P (sym, value); |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
303 sym = XCONS (value)->cdr) |
7be89f84a882
* textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents:
3858
diff
changeset
|
304 if (EQ (property_value (interval->plist, XCONS (sym)->car), Qunbound)) |
4076
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
305 { |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
306 modify_region (XBUFFER (object), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
307 make_number (interval->position), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
308 make_number (interval->position + LENGTH (interval))); |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
309 record_property_change (interval->position, LENGTH (interval), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
310 XCONS (sym)->car, Qnil, |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
311 object); |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
312 } |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
313 } |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
314 |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
315 /* Store new properties. */ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
316 interval->plist = Fcopy_sequence (properties); |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
317 } |
1029 | 318 |
319 /* Add the properties of PLIST to the interval I, or set | |
320 the value of I's property to the value of the property on PLIST | |
321 if they are different. | |
322 | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
323 OBJECT should be the string or buffer the interval is in. |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
324 |
1029 | 325 Return nonzero if this changes I (i.e., if any members of PLIST |
326 are actually added to I's plist) */ | |
327 | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
328 static int |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
329 add_properties (plist, i, object) |
1029 | 330 Lisp_Object plist; |
331 INTERVAL i; | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
332 Lisp_Object object; |
1029 | 333 { |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
334 Lisp_Object tail1, tail2, sym1, val1; |
1029 | 335 register int changed = 0; |
336 register int found; | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
337 struct gcpro gcpro1, gcpro2, gcpro3; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
338 |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
339 tail1 = plist; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
340 sym1 = Qnil; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
341 val1 = Qnil; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
342 /* No need to protect OBJECT, because we can GC only in the case |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
343 where it is a buffer, and live buffers are always protected. |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
344 I and its plist are also protected, via OBJECT. */ |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
345 GCPRO3 (tail1, sym1, val1); |
1029 | 346 |
347 /* Go through each element of PLIST. */ | |
348 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
349 { | |
350 sym1 = Fcar (tail1); | |
351 val1 = Fcar (Fcdr (tail1)); | |
352 found = 0; | |
353 | |
354 /* Go through I's plist, looking for sym1 */ | |
355 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | |
356 if (EQ (sym1, Fcar (tail2))) | |
357 { | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
358 /* No need to gcpro, because tail2 protects this |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
359 and it must be a cons cell (we get an error otherwise). */ |
6516
8278049ee7a7
(add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6064
diff
changeset
|
360 register Lisp_Object this_cdr; |
1029 | 361 |
6516
8278049ee7a7
(add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6064
diff
changeset
|
362 this_cdr = Fcdr (tail2); |
1029 | 363 /* Found the property. Now check its value. */ |
364 found = 1; | |
365 | |
366 /* The properties have the same value on both lists. | |
367 Continue to the next property. */ | |
3998
c0560357c84e
Compare the values of text properties using EQ, not Fequal.
Jim Blandy <jimb@redhat.com>
parents:
3996
diff
changeset
|
368 if (EQ (val1, Fcar (this_cdr))) |
1029 | 369 break; |
370 | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
371 /* Record this change in the buffer, for undo purposes. */ |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
372 if (BUFFERP (object)) |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
373 { |
2783
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
374 modify_region (XBUFFER (object), |
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
375 make_number (i->position), |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
376 make_number (i->position + LENGTH (i))); |
4076
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
377 record_property_change (i->position, LENGTH (i), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
378 sym1, Fcar (this_cdr), object); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
379 } |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
380 |
1029 | 381 /* I's property has a different value -- change it */ |
382 Fsetcar (this_cdr, val1); | |
383 changed++; | |
384 break; | |
385 } | |
386 | |
387 if (! found) | |
388 { | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
389 /* Record this change in the buffer, for undo purposes. */ |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
390 if (BUFFERP (object)) |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
391 { |
2783
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
392 modify_region (XBUFFER (object), |
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
393 make_number (i->position), |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
394 make_number (i->position + LENGTH (i))); |
4076
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
395 record_property_change (i->position, LENGTH (i), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
396 sym1, Qnil, object); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
397 } |
1029 | 398 i->plist = Fcons (sym1, Fcons (val1, i->plist)); |
399 changed++; | |
400 } | |
401 } | |
402 | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
403 UNGCPRO; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
404 |
1029 | 405 return changed; |
406 } | |
407 | |
408 /* For any members of PLIST which are properties of I, remove them | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
409 from I's plist. |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
410 OBJECT is the string or buffer containing I. */ |
1029 | 411 |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
412 static int |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
413 remove_properties (plist, i, object) |
1029 | 414 Lisp_Object plist; |
415 INTERVAL i; | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
416 Lisp_Object object; |
1029 | 417 { |
6516
8278049ee7a7
(add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6064
diff
changeset
|
418 register Lisp_Object tail1, tail2, sym, current_plist; |
1029 | 419 register int changed = 0; |
420 | |
6516
8278049ee7a7
(add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6064
diff
changeset
|
421 current_plist = i->plist; |
1029 | 422 /* Go through each element of plist. */ |
423 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
424 { | |
425 sym = Fcar (tail1); | |
426 | |
427 /* First, remove the symbol if its at the head of the list */ | |
428 while (! NILP (current_plist) && EQ (sym, Fcar (current_plist))) | |
429 { | |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
430 if (BUFFERP (object)) |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
431 { |
4076
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
432 modify_region (XBUFFER (object), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
433 make_number (i->position), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
434 make_number (i->position + LENGTH (i))); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
435 record_property_change (i->position, LENGTH (i), |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
436 sym, Fcar (Fcdr (current_plist)), |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
437 object); |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
438 } |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
439 |
1029 | 440 current_plist = Fcdr (Fcdr (current_plist)); |
441 changed++; | |
442 } | |
443 | |
444 /* Go through i's plist, looking for sym */ | |
445 tail2 = current_plist; | |
446 while (! NILP (tail2)) | |
447 { | |
6516
8278049ee7a7
(add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6064
diff
changeset
|
448 register Lisp_Object this; |
8278049ee7a7
(add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents:
6064
diff
changeset
|
449 this = Fcdr (Fcdr (tail2)); |
1029 | 450 if (EQ (sym, Fcar (this))) |
451 { | |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
452 if (BUFFERP (object)) |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
453 { |
2783
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
454 modify_region (XBUFFER (object), |
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
455 make_number (i->position), |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
456 make_number (i->position + LENGTH (i))); |
4076
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
457 record_property_change (i->position, LENGTH (i), |
9fd5ecacfbbb
(Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents:
4007
diff
changeset
|
458 sym, Fcar (Fcdr (this)), object); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
459 } |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
460 |
1029 | 461 Fsetcdr (Fcdr (tail2), Fcdr (Fcdr (this))); |
462 changed++; | |
463 } | |
464 tail2 = this; | |
465 } | |
466 } | |
467 | |
468 if (changed) | |
469 i->plist = current_plist; | |
470 return changed; | |
471 } | |
472 | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
473 #if 0 |
1029 | 474 /* Remove all properties from interval I. Return non-zero |
475 if this changes the interval. */ | |
476 | |
477 static INLINE int | |
478 erase_properties (i) | |
479 INTERVAL i; | |
480 { | |
481 if (NILP (i->plist)) | |
482 return 0; | |
483 | |
484 i->plist = Qnil; | |
485 return 1; | |
486 } | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
487 #endif |
1029 | 488 |
489 DEFUN ("text-properties-at", Ftext_properties_at, | |
490 Stext_properties_at, 1, 2, 0, | |
491 "Return the list of properties held by the character at POSITION\n\ | |
492 in optional argument OBJECT, a string or buffer. If nil, OBJECT\n\ | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
493 defaults to the current buffer.\n\ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
494 If POSITION is at the end of OBJECT, the value is nil.") |
1029 | 495 (pos, object) |
496 Lisp_Object pos, object; | |
497 { | |
498 register INTERVAL i; | |
499 | |
500 if (NILP (object)) | |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
501 XSETBUFFER (object, current_buffer); |
1029 | 502 |
503 i = validate_interval_range (object, &pos, &pos, soft); | |
504 if (NULL_INTERVAL_P (i)) | |
505 return Qnil; | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
506 /* If POS is at the end of the interval, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
507 it means it's the end of OBJECT. |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
508 There are no properties at the very end, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
509 since no character follows. */ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
510 if (XINT (pos) == LENGTH (i) + i->position) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
511 return Qnil; |
1029 | 512 |
513 return i->plist; | |
514 } | |
515 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
516 DEFUN ("get-text-property", Fget_text_property, Sget_text_property, 2, 3, 0, |
1930
1cdbdbe2f70a
* textprop.c (Fget_text_property): Fix typo in function's declaration.
Jim Blandy <jimb@redhat.com>
parents:
1857
diff
changeset
|
517 "Return the value of position POS's property PROP, in OBJECT.\n\ |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
518 OBJECT is optional and defaults to the current buffer.\n\ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
519 If POSITION is at the end of OBJECT, the value is nil.") |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
520 (pos, prop, object) |
1930
1cdbdbe2f70a
* textprop.c (Fget_text_property): Fix typo in function's declaration.
Jim Blandy <jimb@redhat.com>
parents:
1857
diff
changeset
|
521 Lisp_Object pos, object; |
8271
e8556db1b7f3
(Fget_text_property): Simplify using Ftext_properties_at.
Richard M. Stallman <rms@gnu.org>
parents:
7773
diff
changeset
|
522 Lisp_Object prop; |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
523 { |
8271
e8556db1b7f3
(Fget_text_property): Simplify using Ftext_properties_at.
Richard M. Stallman <rms@gnu.org>
parents:
7773
diff
changeset
|
524 return textget (Ftext_properties_at (pos, object), prop); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
525 } |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
526 |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
527 DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0, |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
528 "Return the value of position POS's property PROP, in OBJECT.\n\ |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
529 OBJECT is optional and defaults to the current buffer.\n\ |
6681 | 530 If POS is at the end of OBJECT, the value is nil.\n\ |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
531 If OBJECT is a buffer, then overlay properties are considered as well as\n\ |
6064
bdfff039f6e3
(Fget_char_property): Fix docstring.
Karl Heuer <kwzh@gnu.org>
parents:
6063
diff
changeset
|
532 text properties.\n\ |
bdfff039f6e3
(Fget_char_property): Fix docstring.
Karl Heuer <kwzh@gnu.org>
parents:
6063
diff
changeset
|
533 If OBJECT is a window, then that window's buffer is used, but window-specific\n\ |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
534 overlays are considered only if they are associated with OBJECT.") |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
535 (pos, prop, object) |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
536 Lisp_Object pos, object; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
537 register Lisp_Object prop; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
538 { |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
539 struct window *w = 0; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
540 |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
541 CHECK_NUMBER_COERCE_MARKER (pos, 0); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
542 |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
543 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
544 XSETBUFFER (object, current_buffer); |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
545 |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
546 if (WINDOWP (object)) |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
547 { |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
548 w = XWINDOW (object); |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
549 object = w->buffer; |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
550 } |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
551 if (BUFFERP (object)) |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
552 { |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
553 int posn = XINT (pos); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
554 int noverlays; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
555 Lisp_Object *overlay_vec, tem; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
556 int next_overlay; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
557 int len; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
558 |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
559 /* First try with room for 40 overlays. */ |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
560 len = 40; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
561 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
562 |
8962
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
563 noverlays = overlays_at (posn, 0, &overlay_vec, &len, |
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
564 &next_overlay, NULL); |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
565 |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
566 /* If there are more than 40, |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
567 make enough space for all, and try again. */ |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
568 if (noverlays > len) |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
569 { |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
570 len = noverlays; |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
571 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
8962
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
572 noverlays = overlays_at (posn, 0, &overlay_vec, &len, |
722763fed8ce
(Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8907
diff
changeset
|
573 &next_overlay, NULL); |
6063
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
574 } |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
575 noverlays = sort_overlays (overlay_vec, noverlays, w); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
576 |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
577 /* Now check the overlays in order of decreasing priority. */ |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
578 while (--noverlays >= 0) |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
579 { |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
580 tem = Foverlay_get (overlay_vec[noverlays], prop); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
581 if (!NILP (tem)) |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
582 return (tem); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
583 } |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
584 } |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
585 /* Not a buffer, or no appropriate overlay, so fall through to the |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
586 simpler case. */ |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
587 return (Fget_text_property (pos, prop, object)); |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
588 } |
233fffcfb6c8
(Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents:
5646
diff
changeset
|
589 |
1029 | 590 DEFUN ("next-property-change", Fnext_property_change, |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
591 Snext_property_change, 1, 3, 0, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
592 "Return the position of next property change.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
593 Scans characters forward from POS in OBJECT till it finds\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
594 a change in some text property, then returns the position of the change.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
595 The optional second argument OBJECT is the string or buffer to scan.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
596 Return nil if the property is constant all the way to the end of OBJECT.\n\ |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
597 If the value is non-nil, it is a position greater than POS, never equal.\n\n\ |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
598 If the optional third argument LIMIT is non-nil, don't search\n\ |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
599 past position LIMIT; return LIMIT if nothing is found before LIMIT.") |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
600 (pos, object, limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
601 Lisp_Object pos, object, limit; |
1029 | 602 { |
603 register INTERVAL i, next; | |
604 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
605 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
606 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
607 |
7092
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
608 if (!NILP (limit)) |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
609 CHECK_NUMBER_COERCE_MARKER (limit, 0); |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
610 |
1029 | 611 i = validate_interval_range (object, &pos, &pos, soft); |
612 if (NULL_INTERVAL_P (i)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
613 return limit; |
1029 | 614 |
615 next = next_interval (i); | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
616 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
617 && (NILP (limit) || next->position < XFASTINT (limit))) |
1029 | 618 next = next_interval (next); |
619 | |
620 if (NULL_INTERVAL_P (next)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
621 return limit; |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
622 if (! NILP (limit) && !(next->position < XFASTINT (limit))) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
623 return limit; |
1029 | 624 |
9321
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
625 XSETFASTINT (pos, next->position - (STRINGP (object))); |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
626 return pos; |
4381
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
627 } |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
628 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
629 /* Return 1 if there's a change in some property between BEG and END. */ |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
630 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
631 int |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
632 property_change_between_p (beg, end) |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
633 int beg, end; |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
634 { |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
635 register INTERVAL i, next; |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
636 Lisp_Object object, pos; |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
637 |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
638 XSETBUFFER (object, current_buffer); |
9321
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
639 XSETFASTINT (pos, beg); |
4381
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
640 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
641 i = validate_interval_range (object, &pos, &pos, soft); |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
642 if (NULL_INTERVAL_P (i)) |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
643 return 0; |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
644 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
645 next = next_interval (i); |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
646 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next)) |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
647 { |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
648 next = next_interval (next); |
4614
2c5557903994
(property_change_between_p): Test NULL_INTERVAL_P
Richard M. Stallman <rms@gnu.org>
parents:
4381
diff
changeset
|
649 if (NULL_INTERVAL_P (next)) |
2c5557903994
(property_change_between_p): Test NULL_INTERVAL_P
Richard M. Stallman <rms@gnu.org>
parents:
4381
diff
changeset
|
650 return 0; |
4381
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
651 if (next->position >= end) |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
652 return 0; |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
653 } |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
654 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
655 if (NULL_INTERVAL_P (next)) |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
656 return 0; |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
657 |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
658 return 1; |
1029 | 659 } |
660 | |
1211 | 661 DEFUN ("next-single-property-change", Fnext_single_property_change, |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
662 Snext_single_property_change, 2, 4, 0, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
663 "Return the position of next property change for a specific property.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
664 Scans characters forward from POS till it finds\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
665 a change in the PROP property, then returns the position of the change.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
666 The optional third argument OBJECT is the string or buffer to scan.\n\ |
5020
94de08fd8a7c
(Fnext_single_property_change): Fix missing \n\.
Richard M. Stallman <rms@gnu.org>
parents:
4986
diff
changeset
|
667 The property values are compared with `eq'.\n\ |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
668 Return nil if the property is constant all the way to the end of OBJECT.\n\ |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
669 If the value is non-nil, it is a position greater than POS, never equal.\n\n\ |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
670 If the optional fourth argument LIMIT is non-nil, don't search\n\ |
5645 | 671 past position LIMIT; return LIMIT if nothing is found before LIMIT.") |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
672 (pos, prop, object, limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
673 Lisp_Object pos, prop, object, limit; |
1211 | 674 { |
675 register INTERVAL i, next; | |
676 register Lisp_Object here_val; | |
677 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
678 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
679 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
680 |
7092
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
681 if (!NILP (limit)) |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
682 CHECK_NUMBER_COERCE_MARKER (limit, 0); |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
683 |
1211 | 684 i = validate_interval_range (object, &pos, &pos, soft); |
685 if (NULL_INTERVAL_P (i)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
686 return limit; |
1211 | 687 |
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
688 here_val = textget (i->plist, prop); |
1211 | 689 next = next_interval (i); |
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
690 while (! NULL_INTERVAL_P (next) |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
691 && EQ (here_val, textget (next->plist, prop)) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
692 && (NILP (limit) || next->position < XFASTINT (limit))) |
1211 | 693 next = next_interval (next); |
694 | |
695 if (NULL_INTERVAL_P (next)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
696 return limit; |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
697 if (! NILP (limit) && !(next->position < XFASTINT (limit))) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
698 return limit; |
1211 | 699 |
9321
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
700 XSETFASTINT (pos, next->position - (STRINGP (object))); |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
701 return pos; |
1211 | 702 } |
703 | |
1029 | 704 DEFUN ("previous-property-change", Fprevious_property_change, |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
705 Sprevious_property_change, 1, 3, 0, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
706 "Return the position of previous property change.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
707 Scans characters backwards from POS in OBJECT till it finds\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
708 a change in some text property, then returns the position of the change.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
709 The optional second argument OBJECT is the string or buffer to scan.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
710 Return nil if the property is constant all the way to the start of OBJECT.\n\ |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
711 If the value is non-nil, it is a position less than POS, never equal.\n\n\ |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
712 If the optional third argument LIMIT is non-nil, don't search\n\ |
5645 | 713 back past position LIMIT; return LIMIT if nothing is found until LIMIT.") |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
714 (pos, object, limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
715 Lisp_Object pos, object, limit; |
1029 | 716 { |
717 register INTERVAL i, previous; | |
718 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
719 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
720 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
721 |
7092
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
722 if (!NILP (limit)) |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
723 CHECK_NUMBER_COERCE_MARKER (limit, 0); |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
724 |
1029 | 725 i = validate_interval_range (object, &pos, &pos, soft); |
726 if (NULL_INTERVAL_P (i)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
727 return limit; |
1029 | 728 |
5644
2abe67658895
(Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents:
5114
diff
changeset
|
729 /* Start with the interval containing the char before point. */ |
2abe67658895
(Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents:
5114
diff
changeset
|
730 if (i->position == XFASTINT (pos)) |
2abe67658895
(Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents:
5114
diff
changeset
|
731 i = previous_interval (i); |
2abe67658895
(Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents:
5114
diff
changeset
|
732 |
1029 | 733 previous = previous_interval (i); |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
734 while (! NULL_INTERVAL_P (previous) && intervals_equal (previous, i) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
735 && (NILP (limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
736 || previous->position + LENGTH (previous) > XFASTINT (limit))) |
1029 | 737 previous = previous_interval (previous); |
738 if (NULL_INTERVAL_P (previous)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
739 return limit; |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
740 if (!NILP (limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
741 && !(previous->position + LENGTH (previous) > XFASTINT (limit))) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
742 return limit; |
1029 | 743 |
9321
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
744 XSETFASTINT (pos, (previous->position + LENGTH (previous) |
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
745 - (STRINGP (object)))); |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
746 return pos; |
1029 | 747 } |
748 | |
1211 | 749 DEFUN ("previous-single-property-change", Fprevious_single_property_change, |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
750 Sprevious_single_property_change, 2, 4, 0, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
751 "Return the position of previous property change for a specific property.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
752 Scans characters backward from POS till it finds\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
753 a change in the PROP property, then returns the position of the change.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
754 The optional third argument OBJECT is the string or buffer to scan.\n\ |
4986
31b1545319dc
(Fprevious_single_property_change): Fix missing \n\.
Richard M. Stallman <rms@gnu.org>
parents:
4797
diff
changeset
|
755 The property values are compared with `eq'.\n\ |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
756 Return nil if the property is constant all the way to the start of OBJECT.\n\ |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
757 If the value is non-nil, it is a position less than POS, never equal.\n\n\ |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
758 If the optional fourth argument LIMIT is non-nil, don't search\n\ |
5645 | 759 back past position LIMIT; return LIMIT if nothing is found until LIMIT.") |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
760 (pos, prop, object, limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
761 Lisp_Object pos, prop, object, limit; |
1211 | 762 { |
763 register INTERVAL i, previous; | |
764 register Lisp_Object here_val; | |
765 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
766 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
767 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
768 |
7092
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
769 if (!NILP (limit)) |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
770 CHECK_NUMBER_COERCE_MARKER (limit, 0); |
b6b93953cc83
(F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents:
6755
diff
changeset
|
771 |
1211 | 772 i = validate_interval_range (object, &pos, &pos, soft); |
7773
2226c7efb3da
(Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents:
7582
diff
changeset
|
773 |
2226c7efb3da
(Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents:
7582
diff
changeset
|
774 /* Start with the interval containing the char before point. */ |
2226c7efb3da
(Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents:
7582
diff
changeset
|
775 if (! NULL_INTERVAL_P (i) && i->position == XFASTINT (pos)) |
2226c7efb3da
(Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents:
7582
diff
changeset
|
776 i = previous_interval (i); |
2226c7efb3da
(Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents:
7582
diff
changeset
|
777 |
1211 | 778 if (NULL_INTERVAL_P (i)) |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
779 return limit; |
1211 | 780 |
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
781 here_val = textget (i->plist, prop); |
1211 | 782 previous = previous_interval (i); |
783 while (! NULL_INTERVAL_P (previous) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
784 && EQ (here_val, textget (previous->plist, prop)) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
785 && (NILP (limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
786 || previous->position + LENGTH (previous) > XFASTINT (limit))) |
1211 | 787 previous = previous_interval (previous); |
788 if (NULL_INTERVAL_P (previous)) | |
5086
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
789 return limit; |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
790 if (!NILP (limit) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
791 && !(previous->position + LENGTH (previous) > XFASTINT (limit))) |
6e9634463e93
(Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents:
5020
diff
changeset
|
792 return limit; |
1211 | 793 |
9321
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
794 XSETFASTINT (pos, (previous->position + LENGTH (previous) |
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
795 - (STRINGP (object)))); |
8907
f7de8b4cb1b8
(validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents:
8856
diff
changeset
|
796 return pos; |
1211 | 797 } |
798 | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
799 /* Callers note, this can GC when OBJECT is a buffer (or nil). */ |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
800 |
1029 | 801 DEFUN ("add-text-properties", Fadd_text_properties, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
802 Sadd_text_properties, 3, 4, 0, |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
803 "Add properties to the text from START to END.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
804 The third argument PROPS is a property list\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
805 specifying the property values to add.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
806 The optional fourth argument, OBJECT,\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
807 is the string or buffer containing the text.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
808 Return t if any property value actually changed, nil otherwise.") |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
809 (start, end, properties, object) |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
810 Lisp_Object start, end, properties, object; |
1029 | 811 { |
812 register INTERVAL i, unchanged; | |
2124
54179ef9ce35
* textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents:
2058
diff
changeset
|
813 register int s, len, modified = 0; |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
814 struct gcpro gcpro1; |
1029 | 815 |
816 properties = validate_plist (properties); | |
817 if (NILP (properties)) | |
818 return Qnil; | |
819 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
820 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
821 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
822 |
1029 | 823 i = validate_interval_range (object, &start, &end, hard); |
824 if (NULL_INTERVAL_P (i)) | |
825 return Qnil; | |
826 | |
827 s = XINT (start); | |
828 len = XINT (end) - s; | |
829 | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
830 /* No need to protect OBJECT, because we GC only if it's a buffer, |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
831 and live buffers are always protected. */ |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
832 GCPRO1 (properties); |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
833 |
1029 | 834 /* If we're not starting on an interval boundary, we have to |
835 split this interval. */ | |
836 if (i->position != s) | |
837 { | |
838 /* If this interval already has the properties, we can | |
839 skip it. */ | |
840 if (interval_has_all_properties (properties, i)) | |
841 { | |
842 int got = (LENGTH (i) - (s - i->position)); | |
843 if (got >= len) | |
844 return Qnil; | |
845 len -= got; | |
3858
e07d474bdba9
(Fremove_text_properties, Fadd_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
3698
diff
changeset
|
846 i = next_interval (i); |
1029 | 847 } |
848 else | |
849 { | |
850 unchanged = i; | |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
851 i = split_interval_right (unchanged, s - unchanged->position); |
1029 | 852 copy_properties (unchanged, i); |
853 } | |
854 } | |
855 | |
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
856 /* We are at the beginning of interval I, with LEN chars to scan. */ |
2124
54179ef9ce35
* textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents:
2058
diff
changeset
|
857 for (;;) |
1029 | 858 { |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
859 if (i == 0) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
860 abort (); |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
861 |
1029 | 862 if (LENGTH (i) >= len) |
863 { | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
864 /* We can UNGCPRO safely here, because there will be just |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
865 one more chance to gc, in the next call to add_properties, |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
866 and after that we will not need PROPERTIES or OBJECT again. */ |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
867 UNGCPRO; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
868 |
1029 | 869 if (interval_has_all_properties (properties, i)) |
870 return modified ? Qt : Qnil; | |
871 | |
872 if (LENGTH (i) == len) | |
873 { | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
874 add_properties (properties, i, object); |
1029 | 875 return Qt; |
876 } | |
877 | |
878 /* i doesn't have the properties, and goes past the change limit */ | |
879 unchanged = i; | |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
880 i = split_interval_left (unchanged, len); |
1029 | 881 copy_properties (unchanged, i); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
882 add_properties (properties, i, object); |
1029 | 883 return Qt; |
884 } | |
885 | |
886 len -= LENGTH (i); | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
887 modified += add_properties (properties, i, object); |
1029 | 888 i = next_interval (i); |
889 } | |
890 } | |
891 | |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
892 /* Callers note, this can GC when OBJECT is a buffer (or nil). */ |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
893 |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
894 DEFUN ("put-text-property", Fput_text_property, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
895 Sput_text_property, 4, 5, 0, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
896 "Set one property of the text from START to END.\n\ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
897 The third and fourth arguments PROP and VALUE\n\ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
898 specify the property to add.\n\ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
899 The optional fifth argument, OBJECT,\n\ |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
900 is the string or buffer containing the text.") |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
901 (start, end, prop, value, object) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
902 Lisp_Object start, end, prop, value, object; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
903 { |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
904 Fadd_text_properties (start, end, |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
905 Fcons (prop, Fcons (value, Qnil)), |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
906 object); |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
907 return Qnil; |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
908 } |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
909 |
1029 | 910 DEFUN ("set-text-properties", Fset_text_properties, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
911 Sset_text_properties, 3, 4, 0, |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
912 "Completely replace properties of text from START to END.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
913 The third argument PROPS is the new property list.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
914 The optional fourth argument, OBJECT,\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
915 is the string or buffer containing the text.") |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
916 (start, end, props, object) |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
917 Lisp_Object start, end, props, object; |
1029 | 918 { |
919 register INTERVAL i, unchanged; | |
1211 | 920 register INTERVAL prev_changed = NULL_INTERVAL; |
1029 | 921 register int s, len; |
9071
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
922 Lisp_Object ostart, oend; |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
923 |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
924 ostart = start; |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
925 oend = end; |
1029 | 926 |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
927 props = validate_plist (props); |
1029 | 928 |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
929 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
930 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
931 |
9541
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
932 /* If we want no properties for a whole string, |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
933 get rid of its intervals. */ |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
934 if (NILP (props) && STRINGP (object) |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
935 && XFASTINT (start) == 0 |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
936 && XFASTINT (end) == XSTRING (object)->size) |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
937 { |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
938 XSTRING (object)->intervals = 0; |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
939 return Qt; |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
940 } |
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
941 |
8686 | 942 i = validate_interval_range (object, &start, &end, soft); |
9541
449e024f13be
(Fset_text_properties): Special case for getting
Richard M. Stallman <rms@gnu.org>
parents:
9331
diff
changeset
|
943 |
1029 | 944 if (NULL_INTERVAL_P (i)) |
8686 | 945 { |
946 /* If buffer has no props, and we want none, return now. */ | |
947 if (NILP (props)) | |
948 return Qnil; | |
949 | |
9071
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
950 /* Restore the original START and END values |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
951 because validate_interval_range increments them for strings. */ |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
952 start = ostart; |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
953 end = oend; |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
954 |
8686 | 955 i = validate_interval_range (object, &start, &end, hard); |
956 /* This can return if start == end. */ | |
957 if (NULL_INTERVAL_P (i)) | |
958 return Qnil; | |
959 } | |
1029 | 960 |
961 s = XINT (start); | |
962 len = XINT (end) - s; | |
963 | |
964 if (i->position != s) | |
965 { | |
966 unchanged = i; | |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
967 i = split_interval_right (unchanged, s - unchanged->position); |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
968 |
1029 | 969 if (LENGTH (i) > len) |
970 { | |
1211 | 971 copy_properties (unchanged, i); |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
972 i = split_interval_left (i, len); |
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
973 set_properties (props, i, object); |
1029 | 974 return Qt; |
975 } | |
976 | |
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
977 set_properties (props, i, object); |
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
978 |
1211 | 979 if (LENGTH (i) == len) |
980 return Qt; | |
981 | |
982 prev_changed = i; | |
1029 | 983 len -= LENGTH (i); |
984 i = next_interval (i); | |
985 } | |
986 | |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
987 /* We are starting at the beginning of an interval, I */ |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
988 while (len > 0) |
1029 | 989 { |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
990 if (i == 0) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
991 abort (); |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
992 |
1029 | 993 if (LENGTH (i) >= len) |
994 { | |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
995 if (LENGTH (i) > len) |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
996 i = split_interval_left (i, len); |
1029 | 997 |
1211 | 998 if (NULL_INTERVAL_P (prev_changed)) |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
999 set_properties (props, i, object); |
1211 | 1000 else |
1001 merge_interval_left (i); | |
1029 | 1002 return Qt; |
1003 } | |
1004 | |
1005 len -= LENGTH (i); | |
1211 | 1006 if (NULL_INTERVAL_P (prev_changed)) |
1007 { | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1008 set_properties (props, i, object); |
1211 | 1009 prev_changed = i; |
1010 } | |
1011 else | |
1012 prev_changed = i = merge_interval_left (i); | |
1013 | |
1029 | 1014 i = next_interval (i); |
1015 } | |
1016 | |
1017 return Qt; | |
1018 } | |
1019 | |
1020 DEFUN ("remove-text-properties", Fremove_text_properties, | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1021 Sremove_text_properties, 3, 4, 0, |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1022 "Remove some properties from text from START to END.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1023 The third argument PROPS is a property list\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1024 whose property names specify the properties to remove.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1025 \(The values stored in PROPS are ignored.)\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1026 The optional fourth argument, OBJECT,\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1027 is the string or buffer containing the text.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1028 Return t if any property was actually removed, nil otherwise.") |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1029 (start, end, props, object) |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1030 Lisp_Object start, end, props, object; |
1029 | 1031 { |
1032 register INTERVAL i, unchanged; | |
2124
54179ef9ce35
* textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents:
2058
diff
changeset
|
1033 register int s, len, modified = 0; |
1029 | 1034 |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1035 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
1036 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1037 |
1029 | 1038 i = validate_interval_range (object, &start, &end, soft); |
1039 if (NULL_INTERVAL_P (i)) | |
1040 return Qnil; | |
1041 | |
1042 s = XINT (start); | |
1043 len = XINT (end) - s; | |
1211 | 1044 |
1029 | 1045 if (i->position != s) |
1046 { | |
1047 /* No properties on this first interval -- return if | |
1048 it covers the entire region. */ | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1049 if (! interval_has_some_properties (props, i)) |
1029 | 1050 { |
1051 int got = (LENGTH (i) - (s - i->position)); | |
1052 if (got >= len) | |
1053 return Qnil; | |
1054 len -= got; | |
3858
e07d474bdba9
(Fremove_text_properties, Fadd_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
3698
diff
changeset
|
1055 i = next_interval (i); |
1029 | 1056 } |
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
1057 /* Split away the beginning of this interval; what we don't |
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
1058 want to modify. */ |
1029 | 1059 else |
1060 { | |
1061 unchanged = i; | |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1062 i = split_interval_right (unchanged, s - unchanged->position); |
1029 | 1063 copy_properties (unchanged, i); |
1064 } | |
1065 } | |
1066 | |
1067 /* We are at the beginning of an interval, with len to scan */ | |
2124
54179ef9ce35
* textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents:
2058
diff
changeset
|
1068 for (;;) |
1029 | 1069 { |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1070 if (i == 0) |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1071 abort (); |
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1072 |
1029 | 1073 if (LENGTH (i) >= len) |
1074 { | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1075 if (! interval_has_some_properties (props, i)) |
1029 | 1076 return modified ? Qt : Qnil; |
1077 | |
1078 if (LENGTH (i) == len) | |
1079 { | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1080 remove_properties (props, i, object); |
1029 | 1081 return Qt; |
1082 } | |
1083 | |
1084 /* i has the properties, and goes past the change limit */ | |
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
1085 unchanged = i; |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1086 i = split_interval_left (i, len); |
1029 | 1087 copy_properties (unchanged, i); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1088 remove_properties (props, i, object); |
1029 | 1089 return Qt; |
1090 } | |
1091 | |
1092 len -= LENGTH (i); | |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1093 modified += remove_properties (props, i, object); |
1029 | 1094 i = next_interval (i); |
1095 } | |
1096 } | |
1097 | |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1098 DEFUN ("text-property-any", Ftext_property_any, |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1099 Stext_property_any, 4, 5, 0, |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1100 "Check text from START to END to see if PROP is ever `eq' to VALUE.\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1101 If so, return the position of the first character whose PROP is `eq'\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1102 to VALUE. Otherwise return nil.\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1103 The optional fifth argument, OBJECT, is the string or buffer\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1104 containing the text.") |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1105 (start, end, prop, value, object) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1106 Lisp_Object start, end, prop, value, object; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1107 { |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1108 register INTERVAL i; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1109 register int e, pos; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1110 |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1111 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
1112 XSETBUFFER (object, current_buffer); |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1113 i = validate_interval_range (object, &start, &end, soft); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1114 e = XINT (end); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1115 |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1116 while (! NULL_INTERVAL_P (i)) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1117 { |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1118 if (i->position >= e) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1119 break; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1120 if (EQ (textget (i->plist, prop), value)) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1121 { |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1122 pos = i->position; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1123 if (pos < XINT (start)) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1124 pos = XINT (start); |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
1125 return make_number (pos - (STRINGP (object))); |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1126 } |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1127 i = next_interval (i); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1128 } |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1129 return Qnil; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1130 } |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1131 |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1132 DEFUN ("text-property-not-all", Ftext_property_not_all, |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1133 Stext_property_not_all, 4, 5, 0, |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1134 "Check text from START to END to see if PROP is ever not `eq' to VALUE.\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1135 If so, return the position of the first character whose PROP is not\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1136 `eq' to VALUE. Otherwise, return nil.\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1137 The optional fifth argument, OBJECT, is the string or buffer\n\ |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1138 containing the text.") |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1139 (start, end, prop, value, object) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1140 Lisp_Object start, end, prop, value, object; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1141 { |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1142 register INTERVAL i; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1143 register int s, e; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1144 |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1145 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
1146 XSETBUFFER (object, current_buffer); |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1147 i = validate_interval_range (object, &start, &end, soft); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1148 if (NULL_INTERVAL_P (i)) |
5114
b37f62d72049
(Ftext_property_not_all): For trivial yes, return start, not Qt.
Richard M. Stallman <rms@gnu.org>
parents:
5086
diff
changeset
|
1149 return (NILP (value) || EQ (start, end)) ? Qnil : start; |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1150 s = XINT (start); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1151 e = XINT (end); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1152 |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1153 while (! NULL_INTERVAL_P (i)) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1154 { |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1155 if (i->position >= e) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1156 break; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1157 if (! EQ (textget (i->plist, prop), value)) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1158 { |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1159 if (i->position > s) |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1160 s = i->position; |
9109
6e44ddc40153
(validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents:
9071
diff
changeset
|
1161 return make_number (s - (STRINGP (object))); |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1162 } |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1163 i = next_interval (i); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1164 } |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1165 return Qnil; |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1166 } |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1167 |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1168 #if 0 /* You can use set-text-properties for this. */ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1169 |
1029 | 1170 DEFUN ("erase-text-properties", Ferase_text_properties, |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1171 Serase_text_properties, 2, 3, 0, |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1172 "Remove all properties from the text from START to END.\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1173 The optional third argument, OBJECT,\n\ |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1174 is the string or buffer containing the text.") |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1175 (start, end, object) |
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1176 Lisp_Object start, end, object; |
1029 | 1177 { |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1178 register INTERVAL i; |
1305 | 1179 register INTERVAL prev_changed = NULL_INTERVAL; |
1029 | 1180 register int s, len, modified; |
1181 | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1182 if (NILP (object)) |
9280
4b238c43e59f
(Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents:
9109
diff
changeset
|
1183 XSETBUFFER (object, current_buffer); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1184 |
1029 | 1185 i = validate_interval_range (object, &start, &end, soft); |
1186 if (NULL_INTERVAL_P (i)) | |
1187 return Qnil; | |
1188 | |
1189 s = XINT (start); | |
1190 len = XINT (end) - s; | |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1191 |
1029 | 1192 if (i->position != s) |
1193 { | |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1194 register int got; |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1195 register INTERVAL unchanged = i; |
1029 | 1196 |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1197 /* If there are properties here, then this text will be modified. */ |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1198 if (! NILP (i->plist)) |
1029 | 1199 { |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1200 i = split_interval_right (unchanged, s - unchanged->position); |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1201 i->plist = Qnil; |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1202 modified++; |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1203 |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1204 if (LENGTH (i) > len) |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1205 { |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1206 i = split_interval_right (i, len); |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1207 copy_properties (unchanged, i); |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1208 return Qt; |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1209 } |
1029 | 1210 |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1211 if (LENGTH (i) == len) |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1212 return Qt; |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1213 |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1214 got = LENGTH (i); |
1029 | 1215 } |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1216 /* If the text of I is without any properties, and contains |
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1217 LEN or more characters, then we may return without changing |
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1218 anything.*/ |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1219 else if (LENGTH (i) - (s - i->position) <= len) |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1220 return Qnil; |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1221 /* The amount of text to change extends past I, so just note |
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1222 how much we've gotten. */ |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1223 else |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1224 got = LENGTH (i) - (s - i->position); |
1029 | 1225 |
1226 len -= got; | |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1227 prev_changed = i; |
1029 | 1228 i = next_interval (i); |
1229 } | |
1230 | |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1231 /* We are starting at the beginning of an interval, I. */ |
1029 | 1232 while (len > 0) |
1233 { | |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1234 if (LENGTH (i) >= len) |
1029 | 1235 { |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1236 /* If I has no properties, simply merge it if possible. */ |
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1237 if (NILP (i->plist)) |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1238 { |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1239 if (! NULL_INTERVAL_P (prev_changed)) |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1240 merge_interval_left (i); |
1029 | 1241 |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1242 return modified ? Qt : Qnil; |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1243 } |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1244 |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1245 if (LENGTH (i) > len) |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1246 i = split_interval_left (i, len); |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1247 if (! NULL_INTERVAL_P (prev_changed)) |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1248 merge_interval_left (i); |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1249 else |
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1250 i->plist = Qnil; |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1251 |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1252 return Qt; |
1029 | 1253 } |
1254 | |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1255 /* Here if we still need to erase past the end of I */ |
1029 | 1256 len -= LENGTH (i); |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1257 if (NULL_INTERVAL_P (prev_changed)) |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1258 { |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1259 modified += erase_properties (i); |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1260 prev_changed = i; |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1261 } |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1262 else |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1263 { |
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1264 modified += ! NILP (i->plist); |
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
1265 /* Merging I will give it the properties of PREV_CHANGED. */ |
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1266 prev_changed = i = merge_interval_left (i); |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1267 } |
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
1268 |
1029 | 1269 i = next_interval (i); |
1270 } | |
1271 | |
1272 return modified ? Qt : Qnil; | |
1273 } | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1274 #endif /* 0 */ |
1029 | 1275 |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1276 /* I don't think this is the right interface to export; how often do you |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1277 want to do something like this, other than when you're copying objects |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1278 around? |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1279 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1280 I think it would be better to have a pair of functions, one which |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1281 returns the text properties of a region as a list of ranges and |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1282 plists, and another which applies such a list to another object. */ |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1283 |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1284 /* Add properties from SRC to SRC of SRC, starting at POS in DEST. |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1285 SRC and DEST may each refer to strings or buffers. |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1286 Optional sixth argument PROP causes only that property to be copied. |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1287 Properties are copied to DEST as if by `add-text-properties'. |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1288 Return t if any property value actually changed, nil otherwise. */ |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1289 |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1290 /* Note this can GC when DEST is a buffer. */ |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1291 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1292 Lisp_Object |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1293 copy_text_properties (start, end, src, pos, dest, prop) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1294 Lisp_Object start, end, src, pos, dest, prop; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1295 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1296 INTERVAL i; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1297 Lisp_Object res; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1298 Lisp_Object stuff; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1299 Lisp_Object plist; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1300 int s, e, e2, p, len, modified = 0; |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1301 struct gcpro gcpro1, gcpro2; |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1302 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1303 i = validate_interval_range (src, &start, &end, soft); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1304 if (NULL_INTERVAL_P (i)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1305 return Qnil; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1306 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1307 CHECK_NUMBER_COERCE_MARKER (pos, 0); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1308 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1309 Lisp_Object dest_start, dest_end; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1310 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1311 dest_start = pos; |
9321
e6759002383c
(Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents:
9280
diff
changeset
|
1312 XSETFASTINT (dest_end, XINT (dest_start) + (XINT (end) - XINT (start))); |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1313 /* Apply this to a copy of pos; it will try to increment its arguments, |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1314 which we don't want. */ |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1315 validate_interval_range (dest, &dest_start, &dest_end, soft); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1316 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1317 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1318 s = XINT (start); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1319 e = XINT (end); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1320 p = XINT (pos); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1321 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1322 stuff = Qnil; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1323 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1324 while (s < e) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1325 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1326 e2 = i->position + LENGTH (i); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1327 if (e2 > e) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1328 e2 = e; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1329 len = e2 - s; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1330 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1331 plist = i->plist; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1332 if (! NILP (prop)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1333 while (! NILP (plist)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1334 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1335 if (EQ (Fcar (plist), prop)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1336 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1337 plist = Fcons (prop, Fcons (Fcar (Fcdr (plist)), Qnil)); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1338 break; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1339 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1340 plist = Fcdr (Fcdr (plist)); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1341 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1342 if (! NILP (plist)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1343 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1344 /* Must defer modifications to the interval tree in case src |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1345 and dest refer to the same string or buffer. */ |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1346 stuff = Fcons (Fcons (make_number (p), |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1347 Fcons (make_number (p + len), |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1348 Fcons (plist, Qnil))), |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1349 stuff); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1350 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1351 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1352 i = next_interval (i); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1353 if (NULL_INTERVAL_P (i)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1354 break; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1355 |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1356 p += len; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1357 s = i->position; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1358 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1359 |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1360 GCPRO2 (stuff, dest); |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1361 |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1362 while (! NILP (stuff)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1363 { |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1364 res = Fcar (stuff); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1365 res = Fadd_text_properties (Fcar (res), Fcar (Fcdr (res)), |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1366 Fcar (Fcdr (Fcdr (res))), dest); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1367 if (! NILP (res)) |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1368 modified++; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1369 stuff = Fcdr (stuff); |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1370 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1371 |
10159
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1372 UNGCPRO; |
1299d37b51bb
(add_properties): Add gcpro's.
Richard M. Stallman <rms@gnu.org>
parents:
9945
diff
changeset
|
1373 |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1374 return modified ? Qt : Qnil; |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1375 } |
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1376 |
1029 | 1377 void |
1378 syms_of_textprop () | |
1379 { | |
4242
49007dbbec4c
(syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4214
diff
changeset
|
1380 DEFVAR_LISP ("inhibit-point-motion-hooks", &Vinhibit_point_motion_hooks, |
9071
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
1381 "If non-nil, don't run `point-left' and `point-entered' text properties.\n\ |
2d4d0f6e7be0
(syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8962
diff
changeset
|
1382 This also inhibits the use of the `intangible' text property."); |
4242
49007dbbec4c
(syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4214
diff
changeset
|
1383 Vinhibit_point_motion_hooks = Qnil; |
49007dbbec4c
(syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents:
4214
diff
changeset
|
1384 |
1029 | 1385 /* Common attributes one might give text */ |
1386 | |
1387 staticpro (&Qforeground); | |
1388 Qforeground = intern ("foreground"); | |
1389 staticpro (&Qbackground); | |
1390 Qbackground = intern ("background"); | |
1391 staticpro (&Qfont); | |
1392 Qfont = intern ("font"); | |
1393 staticpro (&Qstipple); | |
1394 Qstipple = intern ("stipple"); | |
1395 staticpro (&Qunderline); | |
1396 Qunderline = intern ("underline"); | |
1397 staticpro (&Qread_only); | |
1398 Qread_only = intern ("read-only"); | |
1399 staticpro (&Qinvisible); | |
1400 Qinvisible = intern ("invisible"); | |
6755
a2bccbc870e6
(syms_of_textprop): Initialize Qintangible.
Karl Heuer <kwzh@gnu.org>
parents:
6681
diff
changeset
|
1401 staticpro (&Qintangible); |
a2bccbc870e6
(syms_of_textprop): Initialize Qintangible.
Karl Heuer <kwzh@gnu.org>
parents:
6681
diff
changeset
|
1402 Qintangible = intern ("intangible"); |
2058
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
1403 staticpro (&Qcategory); |
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
1404 Qcategory = intern ("category"); |
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
1405 staticpro (&Qlocal_map); |
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
1406 Qlocal_map = intern ("local-map"); |
4381
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
1407 staticpro (&Qfront_sticky); |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
1408 Qfront_sticky = intern ("front-sticky"); |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
1409 staticpro (&Qrear_nonsticky); |
b0556af4d680
(Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents:
4242
diff
changeset
|
1410 Qrear_nonsticky = intern ("rear-nonsticky"); |
1029 | 1411 |
1412 /* Properties that text might use to specify certain actions */ | |
1413 | |
1414 staticpro (&Qmouse_left); | |
1415 Qmouse_left = intern ("mouse-left"); | |
1416 staticpro (&Qmouse_entered); | |
1417 Qmouse_entered = intern ("mouse-entered"); | |
1418 staticpro (&Qpoint_left); | |
1419 Qpoint_left = intern ("point-left"); | |
1420 staticpro (&Qpoint_entered); | |
1421 Qpoint_entered = intern ("point-entered"); | |
1422 | |
1423 defsubr (&Stext_properties_at); | |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1424 defsubr (&Sget_text_property); |
7582
454c279b6d18
(syms_of_textprop): Set up Lisp fn get-char-property.
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
1425 defsubr (&Sget_char_property); |
1029 | 1426 defsubr (&Snext_property_change); |
1211 | 1427 defsubr (&Snext_single_property_change); |
1029 | 1428 defsubr (&Sprevious_property_change); |
1211 | 1429 defsubr (&Sprevious_single_property_change); |
1029 | 1430 defsubr (&Sadd_text_properties); |
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1431 defsubr (&Sput_text_property); |
1029 | 1432 defsubr (&Sset_text_properties); |
1433 defsubr (&Sremove_text_properties); | |
4144
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1434 defsubr (&Stext_property_any); |
8f5545cf9774
* intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents:
4076
diff
changeset
|
1435 defsubr (&Stext_property_not_all); |
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1436 /* defsubr (&Serase_text_properties); */ |
4007
55da23f04d01
* textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents:
3998
diff
changeset
|
1437 /* defsubr (&Scopy_text_properties); */ |
1029 | 1438 } |
1302
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1439 |
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1440 #else |
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1441 |
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1442 lose -- this shouldn't be compiled if USE_TEXT_PROPERTIES isn't defined |
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1443 |
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1444 #endif /* USE_TEXT_PROPERTIES */ |