Mercurial > emacs
annotate src/textprop.c @ 3858:e07d474bdba9
(Fremove_text_properties, Fadd_text_properties):
Really do next_interval when skipping the first interval.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Mon, 21 Jun 1993 19:37:49 +0000 |
| parents | e748df7e6e74 |
| children | 7be89f84a882 |
| rev | line source |
|---|---|
| 1029 | 1 /* Interface code for dealing with text properties. |
|
2053
8bdcc55ebd8f
(Qmodification_hooks): Renamed from Qmodification.
Richard M. Stallman <rms@gnu.org>
parents:
1965
diff
changeset
|
2 Copyright (C) 1993 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 | |
| 20 #include "config.h" | |
| 21 #include "lisp.h" | |
| 22 #include "intervals.h" | |
| 23 #include "buffer.h" | |
| 24 | |
| 25 | |
| 26 /* NOTES: previous- and next- property change will have to skip | |
| 27 zero-length intervals if they are implemented. This could be done | |
| 28 inside next_interval and previous_interval. | |
| 29 | |
| 1211 | 30 set_properties needs to deal with the interval property cache. |
| 31 | |
| 1029 | 32 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
|
33 only once on the list. Although some code i.e., remove_properties, |
| 1029 | 34 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
|
35 necessary for the system to remain consistent. This requirement |
| 1029 | 36 is enforced by the subrs installing properties onto the intervals. */ |
| 37 | |
|
1302
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
38 /* 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
|
39 #ifdef USE_TEXT_PROPERTIES |
| 1029 | 40 |
| 41 /* Types of hooks. */ | |
| 42 Lisp_Object Qmouse_left; | |
| 43 Lisp_Object Qmouse_entered; | |
| 44 Lisp_Object Qpoint_left; | |
| 45 Lisp_Object Qpoint_entered; | |
|
2053
8bdcc55ebd8f
(Qmodification_hooks): Renamed from Qmodification.
Richard M. Stallman <rms@gnu.org>
parents:
1965
diff
changeset
|
46 Lisp_Object Qmodification_hooks; |
|
2058
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
47 Lisp_Object Qcategory; |
|
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
48 Lisp_Object Qlocal_map; |
| 1029 | 49 |
| 50 /* Visual properties text (including strings) may have. */ | |
| 51 Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple; | |
| 52 Lisp_Object Qinvisible, Qread_only; | |
| 53 | |
| 1055 | 54 /* Extract the interval at the position pointed to by BEGIN from |
| 55 OBJECT, a string or buffer. Additionally, check that the positions | |
| 56 pointed to by BEGIN and END are within the bounds of OBJECT, and | |
| 57 reverse them if *BEGIN is greater than *END. The objects pointed | |
| 58 to by BEGIN and END may be integers or markers; if the latter, they | |
| 59 are coerced to integers. | |
| 1029 | 60 |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
61 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
|
62 to make them origin-one. |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
63 |
| 1029 | 64 Note that buffer points don't correspond to interval indices. |
| 65 For example, point-max is 1 greater than the index of the last | |
| 66 character. This difference is handled in the caller, which uses | |
| 67 the validated points to determine a length, and operates on that. | |
| 68 Exceptions are Ftext_properties_at, Fnext_property_change, and | |
| 69 Fprevious_property_change which call this function with BEGIN == END. | |
| 70 Handle this case specially. | |
| 71 | |
| 72 If FORCE is soft (0), it's OK to return NULL_INTERVAL. Otherwise, | |
| 1055 | 73 create an interval tree for OBJECT if one doesn't exist, provided |
| 74 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
|
75 is no text, there can be no text properties. */ |
| 1029 | 76 |
| 77 #define soft 0 | |
| 78 #define hard 1 | |
| 79 | |
| 80 static INTERVAL | |
| 81 validate_interval_range (object, begin, end, force) | |
| 82 Lisp_Object object, *begin, *end; | |
| 83 int force; | |
| 84 { | |
| 85 register INTERVAL i; | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
86 int searchpos; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
87 |
| 1029 | 88 CHECK_STRING_OR_BUFFER (object, 0); |
| 89 CHECK_NUMBER_COERCE_MARKER (*begin, 0); | |
| 90 CHECK_NUMBER_COERCE_MARKER (*end, 0); | |
| 91 | |
| 92 /* If we are asked for a point, but from a subr which operates | |
| 93 on a range, then return nothing. */ | |
| 94 if (*begin == *end && begin != end) | |
| 95 return NULL_INTERVAL; | |
| 96 | |
| 97 if (XINT (*begin) > XINT (*end)) | |
| 98 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
99 Lisp_Object n; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
100 n = *begin; |
| 1029 | 101 *begin = *end; |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
102 *end = n; |
| 1029 | 103 } |
| 104 | |
| 105 if (XTYPE (object) == Lisp_Buffer) | |
| 106 { | |
| 107 register struct buffer *b = XBUFFER (object); | |
| 108 | |
| 109 if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end) | |
| 110 && XINT (*end) <= BUF_ZV (b))) | |
| 111 args_out_of_range (*begin, *end); | |
| 112 i = b->intervals; | |
| 113 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
114 /* 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
|
115 if (BUF_BEGV (b) == BUF_ZV (b)) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
116 return NULL_INTERVAL; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
117 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
118 searchpos = XINT (*begin); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
119 if (searchpos == BUF_Z (b)) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
120 searchpos--; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
121 #if 0 |
| 1029 | 122 /* Special case for point-max: return the interval for the |
| 123 last character. */ | |
| 124 if (*begin == *end && *begin == BUF_Z (b)) | |
| 125 *begin -= 1; | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
126 #endif |
| 1029 | 127 } |
| 128 else | |
| 129 { | |
| 130 register struct Lisp_String *s = XSTRING (object); | |
| 131 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
132 if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end) |
| 1029 | 133 && XINT (*end) <= s->size)) |
| 134 args_out_of_range (*begin, *end); | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
135 /* 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
|
136 but the interval code always wants positions starting with 1. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
137 XFASTINT (*begin) += 1; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
138 XFASTINT (*end) += 1; |
| 1029 | 139 i = s->intervals; |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
140 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
141 if (s->size == 0) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
142 return NULL_INTERVAL; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
143 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
144 searchpos = XINT (*begin); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
145 if (searchpos > s->size) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
146 searchpos--; |
| 1029 | 147 } |
| 148 | |
| 149 if (NULL_INTERVAL_P (i)) | |
| 150 return (force ? create_root_interval (object) : i); | |
| 151 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
152 return find_interval (i, searchpos); |
| 1029 | 153 } |
| 154 | |
| 155 /* Validate LIST as a property list. If LIST is not a list, then | |
| 156 make one consisting of (LIST nil). Otherwise, verify that LIST | |
| 157 is even numbered and thus suitable as a plist. */ | |
| 158 | |
| 159 static Lisp_Object | |
| 160 validate_plist (list) | |
| 161 { | |
| 162 if (NILP (list)) | |
| 163 return Qnil; | |
| 164 | |
| 165 if (CONSP (list)) | |
| 166 { | |
| 167 register int i; | |
| 168 register Lisp_Object tail; | |
| 169 for (i = 0, tail = list; !NILP (tail); i++) | |
| 170 tail = Fcdr (tail); | |
| 171 if (i & 1) | |
| 172 error ("Odd length text property list"); | |
| 173 return list; | |
| 174 } | |
| 175 | |
| 176 return Fcons (list, Fcons (Qnil, Qnil)); | |
| 177 } | |
| 178 | |
| 179 /* Return nonzero if interval I has all the properties, | |
| 180 with the same values, of list PLIST. */ | |
| 181 | |
| 182 static int | |
| 183 interval_has_all_properties (plist, i) | |
| 184 Lisp_Object plist; | |
| 185 INTERVAL i; | |
| 186 { | |
| 187 register Lisp_Object tail1, tail2, sym1, sym2; | |
| 188 register int found; | |
| 189 | |
| 190 /* Go through each element of PLIST. */ | |
| 191 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
| 192 { | |
| 193 sym1 = Fcar (tail1); | |
| 194 found = 0; | |
| 195 | |
| 196 /* Go through I's plist, looking for sym1 */ | |
| 197 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | |
| 198 if (EQ (sym1, Fcar (tail2))) | |
| 199 { | |
| 200 /* Found the same property on both lists. If the | |
| 201 values are unequal, return zero. */ | |
| 202 if (! EQ (Fequal (Fcar (Fcdr (tail1)), Fcar (Fcdr (tail2))), | |
| 203 Qt)) | |
| 204 return 0; | |
| 205 | |
| 206 /* Property has same value on both lists; go to next one. */ | |
| 207 found = 1; | |
| 208 break; | |
| 209 } | |
| 210 | |
| 211 if (! found) | |
| 212 return 0; | |
| 213 } | |
| 214 | |
| 215 return 1; | |
| 216 } | |
| 217 | |
| 218 /* Return nonzero if the plist of interval I has any of the | |
| 219 properties of PLIST, regardless of their values. */ | |
| 220 | |
| 221 static INLINE int | |
| 222 interval_has_some_properties (plist, i) | |
| 223 Lisp_Object plist; | |
| 224 INTERVAL i; | |
| 225 { | |
| 226 register Lisp_Object tail1, tail2, sym; | |
| 227 | |
| 228 /* Go through each element of PLIST. */ | |
| 229 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
| 230 { | |
| 231 sym = Fcar (tail1); | |
| 232 | |
| 233 /* Go through i's plist, looking for tail1 */ | |
| 234 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | |
| 235 if (EQ (sym, Fcar (tail2))) | |
| 236 return 1; | |
| 237 } | |
| 238 | |
| 239 return 0; | |
| 240 } | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
241 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
242 /* Set the properties of INTERVAL to PROPERTIES, |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
243 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
|
244 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
|
245 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
246 static void |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
247 set_properties (properties, interval, object) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
248 Lisp_Object properties, object; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
249 INTERVAL interval; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
250 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
251 Lisp_Object oldprops; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
252 oldprops = interval->plist; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
253 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
254 /* Record undo for old properties. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
255 while (XTYPE (oldprops) == Lisp_Cons) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
256 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
257 Lisp_Object sym; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
258 sym = Fcar (oldprops); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
259 record_property_change (interval->position, LENGTH (interval), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
260 sym, Fcar_safe (Fcdr (oldprops)), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
261 object); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
262 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
263 oldprops = Fcdr_safe (Fcdr (oldprops)); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
264 } |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
265 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
266 /* Store new properties. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
267 interval->plist = Fcopy_sequence (properties); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
268 } |
| 1029 | 269 |
| 270 /* Add the properties of PLIST to the interval I, or set | |
| 271 the value of I's property to the value of the property on PLIST | |
| 272 if they are different. | |
| 273 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
274 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
|
275 |
| 1029 | 276 Return nonzero if this changes I (i.e., if any members of PLIST |
| 277 are actually added to I's plist) */ | |
| 278 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
279 static int |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
280 add_properties (plist, i, object) |
| 1029 | 281 Lisp_Object plist; |
| 282 INTERVAL i; | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
283 Lisp_Object object; |
| 1029 | 284 { |
| 285 register Lisp_Object tail1, tail2, sym1, val1; | |
| 286 register int changed = 0; | |
| 287 register int found; | |
| 288 | |
| 289 /* Go through each element of PLIST. */ | |
| 290 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
| 291 { | |
| 292 sym1 = Fcar (tail1); | |
| 293 val1 = Fcar (Fcdr (tail1)); | |
| 294 found = 0; | |
| 295 | |
| 296 /* Go through I's plist, looking for sym1 */ | |
| 297 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | |
| 298 if (EQ (sym1, Fcar (tail2))) | |
| 299 { | |
| 300 register Lisp_Object this_cdr = Fcdr (tail2); | |
| 301 | |
| 302 /* Found the property. Now check its value. */ | |
| 303 found = 1; | |
| 304 | |
| 305 /* The properties have the same value on both lists. | |
| 306 Continue to the next property. */ | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
307 if (!NILP (Fequal (val1, Fcar (this_cdr)))) |
| 1029 | 308 break; |
| 309 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
310 /* Record this change in the buffer, for undo purposes. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
311 if (XTYPE (object) == Lisp_Buffer) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
312 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
313 record_property_change (i->position, LENGTH (i), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
314 sym1, Fcar (this_cdr), object); |
|
2783
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
315 modify_region (XBUFFER (object), |
|
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
316 make_number (i->position), |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
317 make_number (i->position + LENGTH (i))); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
318 } |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
319 |
| 1029 | 320 /* I's property has a different value -- change it */ |
| 321 Fsetcar (this_cdr, val1); | |
| 322 changed++; | |
| 323 break; | |
| 324 } | |
| 325 | |
| 326 if (! found) | |
| 327 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
328 /* Record this change in the buffer, for undo purposes. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
329 if (XTYPE (object) == Lisp_Buffer) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
330 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
331 record_property_change (i->position, LENGTH (i), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
332 sym1, Qnil, object); |
|
2783
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
333 modify_region (XBUFFER (object), |
|
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
334 make_number (i->position), |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
335 make_number (i->position + LENGTH (i))); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
336 } |
| 1029 | 337 i->plist = Fcons (sym1, Fcons (val1, i->plist)); |
| 338 changed++; | |
| 339 } | |
| 340 } | |
| 341 | |
| 342 return changed; | |
| 343 } | |
| 344 | |
| 345 /* 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
|
346 from I's plist. |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
347 OBJECT is the string or buffer containing I. */ |
| 1029 | 348 |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
349 static int |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
350 remove_properties (plist, i, object) |
| 1029 | 351 Lisp_Object plist; |
| 352 INTERVAL i; | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
353 Lisp_Object object; |
| 1029 | 354 { |
| 355 register Lisp_Object tail1, tail2, sym; | |
| 356 register Lisp_Object current_plist = i->plist; | |
| 357 register int changed = 0; | |
| 358 | |
| 359 /* Go through each element of plist. */ | |
| 360 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | |
| 361 { | |
| 362 sym = Fcar (tail1); | |
| 363 | |
| 364 /* First, remove the symbol if its at the head of the list */ | |
| 365 while (! NILP (current_plist) && EQ (sym, Fcar (current_plist))) | |
| 366 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
367 if (XTYPE (object) == Lisp_Buffer) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
368 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
369 record_property_change (i->position, LENGTH (i), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
370 sym, Fcar (Fcdr (current_plist)), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
371 object); |
|
2783
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
372 modify_region (XBUFFER (object), |
|
789c11177579
The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents:
2762
diff
changeset
|
373 make_number (i->position), |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
374 make_number (i->position + LENGTH (i))); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
375 } |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
376 |
| 1029 | 377 current_plist = Fcdr (Fcdr (current_plist)); |
| 378 changed++; | |
| 379 } | |
| 380 | |
| 381 /* Go through i's plist, looking for sym */ | |
| 382 tail2 = current_plist; | |
| 383 while (! NILP (tail2)) | |
| 384 { | |
| 385 register Lisp_Object this = Fcdr (Fcdr (tail2)); | |
| 386 if (EQ (sym, Fcar (this))) | |
| 387 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
388 if (XTYPE (object) == Lisp_Buffer) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
389 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
390 record_property_change (i->position, LENGTH (i), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
391 sym, Fcar (Fcdr (this)), object); |
|
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))); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
395 } |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
396 |
| 1029 | 397 Fsetcdr (Fcdr (tail2), Fcdr (Fcdr (this))); |
| 398 changed++; | |
| 399 } | |
| 400 tail2 = this; | |
| 401 } | |
| 402 } | |
| 403 | |
| 404 if (changed) | |
| 405 i->plist = current_plist; | |
| 406 return changed; | |
| 407 } | |
| 408 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
409 #if 0 |
| 1029 | 410 /* Remove all properties from interval I. Return non-zero |
| 411 if this changes the interval. */ | |
| 412 | |
| 413 static INLINE int | |
| 414 erase_properties (i) | |
| 415 INTERVAL i; | |
| 416 { | |
| 417 if (NILP (i->plist)) | |
| 418 return 0; | |
| 419 | |
| 420 i->plist = Qnil; | |
| 421 return 1; | |
| 422 } | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
423 #endif |
| 1029 | 424 |
| 425 DEFUN ("text-properties-at", Ftext_properties_at, | |
| 426 Stext_properties_at, 1, 2, 0, | |
| 427 "Return the list of properties held by the character at POSITION\n\ | |
| 428 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
|
429 defaults to the current buffer.\n\ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
430 If POSITION is at the end of OBJECT, the value is nil.") |
| 1029 | 431 (pos, object) |
| 432 Lisp_Object pos, object; | |
| 433 { | |
| 434 register INTERVAL i; | |
| 435 | |
| 436 if (NILP (object)) | |
| 437 XSET (object, Lisp_Buffer, current_buffer); | |
| 438 | |
| 439 i = validate_interval_range (object, &pos, &pos, soft); | |
| 440 if (NULL_INTERVAL_P (i)) | |
| 441 return Qnil; | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
442 /* 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
|
443 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
|
444 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
|
445 since no character follows. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
446 if (XINT (pos) == LENGTH (i) + i->position) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
447 return Qnil; |
| 1029 | 448 |
| 449 return i->plist; | |
| 450 } | |
| 451 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
452 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
|
453 "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
|
454 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
|
455 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
|
456 (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
|
457 Lisp_Object pos, object; |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
458 register Lisp_Object prop; |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
459 { |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
460 register INTERVAL i; |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
461 register Lisp_Object tail; |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
462 |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
463 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
464 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
465 i = validate_interval_range (object, &pos, &pos, soft); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
466 if (NULL_INTERVAL_P (i)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
467 return Qnil; |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
468 |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
469 /* 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
|
470 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
|
471 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
|
472 since no character follows. */ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
473 if (XINT (pos) == LENGTH (i) + i->position) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
474 return Qnil; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
475 |
|
2058
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
476 return textget (i->plist, prop); |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
477 } |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
478 |
| 1029 | 479 DEFUN ("next-property-change", Fnext_property_change, |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
480 Snext_property_change, 1, 2, 0, |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
481 "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
|
482 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
|
483 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
|
484 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
|
485 Return nil if the property is constant all the way to the end of OBJECT.\n\ |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
486 If the value is non-nil, it is a position greater than POS, never equal.") |
| 1029 | 487 (pos, object) |
| 488 Lisp_Object pos, object; | |
| 489 { | |
| 490 register INTERVAL i, next; | |
| 491 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
492 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
493 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
494 |
| 1029 | 495 i = validate_interval_range (object, &pos, &pos, soft); |
| 496 if (NULL_INTERVAL_P (i)) | |
| 497 return Qnil; | |
| 498 | |
| 499 next = next_interval (i); | |
| 500 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next)) | |
| 501 next = next_interval (next); | |
| 502 | |
| 503 if (NULL_INTERVAL_P (next)) | |
| 504 return Qnil; | |
| 505 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
506 return next->position - (XTYPE (object) == Lisp_String); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
507 ; |
| 1029 | 508 } |
| 509 | |
| 1211 | 510 DEFUN ("next-single-property-change", Fnext_single_property_change, |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
511 Snext_single_property_change, 1, 3, 0, |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
512 "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
|
513 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
|
514 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
|
515 The optional third 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
|
516 Return nil if the property is constant all the way to the end of OBJECT.\n\ |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
517 If the value is non-nil, it is a position greater than POS, never equal.") |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
518 (pos, prop, object) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
519 Lisp_Object pos, prop, object; |
| 1211 | 520 { |
| 521 register INTERVAL i, next; | |
| 522 register Lisp_Object here_val; | |
| 523 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
524 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
525 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
526 |
| 1211 | 527 i = validate_interval_range (object, &pos, &pos, soft); |
| 528 if (NULL_INTERVAL_P (i)) | |
| 529 return Qnil; | |
| 530 | |
|
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
531 here_val = textget (i->plist, prop); |
| 1211 | 532 next = next_interval (i); |
|
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
533 while (! NULL_INTERVAL_P (next) |
|
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
534 && EQ (here_val, textget (next->plist, prop))) |
| 1211 | 535 next = next_interval (next); |
| 536 | |
| 537 if (NULL_INTERVAL_P (next)) | |
| 538 return Qnil; | |
| 539 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
540 return next->position - (XTYPE (object) == Lisp_String); |
| 1211 | 541 } |
| 542 | |
| 1029 | 543 DEFUN ("previous-property-change", Fprevious_property_change, |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
544 Sprevious_property_change, 1, 2, 0, |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
545 "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
|
546 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
|
547 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
|
548 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
|
549 Return nil if the property is constant all the way to the start of OBJECT.\n\ |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
550 If the value is non-nil, it is a position less than POS, never equal.") |
| 1029 | 551 (pos, object) |
| 552 Lisp_Object pos, object; | |
| 553 { | |
| 554 register INTERVAL i, previous; | |
| 555 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
556 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
557 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
558 |
| 1029 | 559 i = validate_interval_range (object, &pos, &pos, soft); |
| 560 if (NULL_INTERVAL_P (i)) | |
| 561 return Qnil; | |
| 562 | |
| 563 previous = previous_interval (i); | |
| 564 while (! NULL_INTERVAL_P (previous) && intervals_equal (previous, i)) | |
| 565 previous = previous_interval (previous); | |
| 566 if (NULL_INTERVAL_P (previous)) | |
| 567 return Qnil; | |
| 568 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
569 return (previous->position + LENGTH (previous) - 1 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
570 - (XTYPE (object) == Lisp_String)); |
| 1029 | 571 } |
| 572 | |
| 1211 | 573 DEFUN ("previous-single-property-change", Fprevious_single_property_change, |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
574 Sprevious_single_property_change, 2, 3, 0, |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
575 "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
|
576 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
|
577 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
|
578 The optional third 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
|
579 Return nil if the property is constant all the way to the start of OBJECT.\n\ |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
580 If the value is non-nil, it is a position less than POS, never equal.") |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
581 (pos, prop, object) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
582 Lisp_Object pos, prop, object; |
| 1211 | 583 { |
| 584 register INTERVAL i, previous; | |
| 585 register Lisp_Object here_val; | |
| 586 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
587 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
588 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
589 |
| 1211 | 590 i = validate_interval_range (object, &pos, &pos, soft); |
| 591 if (NULL_INTERVAL_P (i)) | |
| 592 return Qnil; | |
| 593 | |
|
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
594 here_val = textget (i->plist, prop); |
| 1211 | 595 previous = previous_interval (i); |
| 596 while (! NULL_INTERVAL_P (previous) | |
|
2762
dd28ed1e1928
* textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents:
2124
diff
changeset
|
597 && EQ (here_val, textget (previous->plist, prop))) |
| 1211 | 598 previous = previous_interval (previous); |
| 599 if (NULL_INTERVAL_P (previous)) | |
| 600 return Qnil; | |
| 601 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
602 return (previous->position + LENGTH (previous) - 1 |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
603 - (XTYPE (object) == Lisp_String)); |
| 1211 | 604 } |
| 605 | |
| 1029 | 606 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
|
607 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
|
608 "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
|
609 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
|
610 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
|
611 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
|
612 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
|
613 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
|
614 (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
|
615 Lisp_Object start, end, properties, object; |
| 1029 | 616 { |
| 617 register INTERVAL i, unchanged; | |
|
2124
54179ef9ce35
* textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents:
2058
diff
changeset
|
618 register int s, len, modified = 0; |
| 1029 | 619 |
| 620 properties = validate_plist (properties); | |
| 621 if (NILP (properties)) | |
| 622 return Qnil; | |
| 623 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
624 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
625 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
626 |
| 1029 | 627 i = validate_interval_range (object, &start, &end, hard); |
| 628 if (NULL_INTERVAL_P (i)) | |
| 629 return Qnil; | |
| 630 | |
| 631 s = XINT (start); | |
| 632 len = XINT (end) - s; | |
| 633 | |
| 634 /* If we're not starting on an interval boundary, we have to | |
| 635 split this interval. */ | |
| 636 if (i->position != s) | |
| 637 { | |
| 638 /* If this interval already has the properties, we can | |
| 639 skip it. */ | |
| 640 if (interval_has_all_properties (properties, i)) | |
| 641 { | |
| 642 int got = (LENGTH (i) - (s - i->position)); | |
| 643 if (got >= len) | |
| 644 return Qnil; | |
| 645 len -= got; | |
|
3858
e07d474bdba9
(Fremove_text_properties, Fadd_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
3698
diff
changeset
|
646 i = next_interval (i); |
| 1029 | 647 } |
| 648 else | |
| 649 { | |
| 650 unchanged = i; | |
| 651 i = split_interval_right (unchanged, s - unchanged->position + 1); | |
| 652 copy_properties (unchanged, i); | |
| 653 } | |
| 654 } | |
| 655 | |
|
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
656 /* 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
|
657 for (;;) |
| 1029 | 658 { |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
659 if (i == 0) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
660 abort (); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
661 |
| 1029 | 662 if (LENGTH (i) >= len) |
| 663 { | |
| 664 if (interval_has_all_properties (properties, i)) | |
| 665 return modified ? Qt : Qnil; | |
| 666 | |
| 667 if (LENGTH (i) == len) | |
| 668 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
669 add_properties (properties, i, object); |
| 1029 | 670 return Qt; |
| 671 } | |
| 672 | |
| 673 /* i doesn't have the properties, and goes past the change limit */ | |
| 674 unchanged = i; | |
| 675 i = split_interval_left (unchanged, len + 1); | |
| 676 copy_properties (unchanged, i); | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
677 add_properties (properties, i, object); |
| 1029 | 678 return Qt; |
| 679 } | |
| 680 | |
| 681 len -= LENGTH (i); | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
682 modified += add_properties (properties, i, object); |
| 1029 | 683 i = next_interval (i); |
| 684 } | |
| 685 } | |
| 686 | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
687 DEFUN ("put-text-property", Fput_text_property, |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
688 Sput_text_property, 4, 5, 0, |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
689 "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
|
690 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
|
691 specify the property to add.\n\ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
692 The optional fifth argument, OBJECT,\n\ |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
693 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
|
694 (start, end, prop, value, object) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
695 Lisp_Object start, end, prop, value, object; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
696 { |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
697 Fadd_text_properties (start, end, |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
698 Fcons (prop, Fcons (value, Qnil)), |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
699 object); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
700 return Qnil; |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
701 } |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
702 |
| 1029 | 703 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
|
704 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
|
705 "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
|
706 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
|
707 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
|
708 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
|
709 (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
|
710 Lisp_Object start, end, props, object; |
| 1029 | 711 { |
| 712 register INTERVAL i, unchanged; | |
| 1211 | 713 register INTERVAL prev_changed = NULL_INTERVAL; |
| 1029 | 714 register int s, len; |
| 715 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
716 props = validate_plist (props); |
| 1029 | 717 |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
718 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
719 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
720 |
| 1029 | 721 i = validate_interval_range (object, &start, &end, hard); |
| 722 if (NULL_INTERVAL_P (i)) | |
| 723 return Qnil; | |
| 724 | |
| 725 s = XINT (start); | |
| 726 len = XINT (end) - s; | |
| 727 | |
| 728 if (i->position != s) | |
| 729 { | |
| 730 unchanged = i; | |
| 731 i = split_interval_right (unchanged, s - unchanged->position + 1); | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
732 |
| 1029 | 733 if (LENGTH (i) > len) |
| 734 { | |
| 1211 | 735 copy_properties (unchanged, i); |
|
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
736 i = split_interval_left (i, len + 1); |
|
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
737 set_properties (props, i, object); |
| 1029 | 738 return Qt; |
| 739 } | |
| 740 | |
|
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
741 set_properties (props, i, object); |
|
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
742 |
| 1211 | 743 if (LENGTH (i) == len) |
| 744 return Qt; | |
| 745 | |
| 746 prev_changed = i; | |
| 1029 | 747 len -= LENGTH (i); |
| 748 i = next_interval (i); | |
| 749 } | |
| 750 | |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
751 /* 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
|
752 while (len > 0) |
| 1029 | 753 { |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
754 if (i == 0) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
755 abort (); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
756 |
| 1029 | 757 if (LENGTH (i) >= len) |
| 758 { | |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
759 if (LENGTH (i) > len) |
|
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
760 i = split_interval_left (i, len + 1); |
| 1029 | 761 |
| 1211 | 762 if (NULL_INTERVAL_P (prev_changed)) |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
763 set_properties (props, i, object); |
| 1211 | 764 else |
| 765 merge_interval_left (i); | |
| 1029 | 766 return Qt; |
| 767 } | |
| 768 | |
| 769 len -= LENGTH (i); | |
| 1211 | 770 if (NULL_INTERVAL_P (prev_changed)) |
| 771 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
772 set_properties (props, i, object); |
| 1211 | 773 prev_changed = i; |
| 774 } | |
| 775 else | |
| 776 prev_changed = i = merge_interval_left (i); | |
| 777 | |
| 1029 | 778 i = next_interval (i); |
| 779 } | |
| 780 | |
| 781 return Qt; | |
| 782 } | |
| 783 | |
| 784 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
|
785 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
|
786 "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
|
787 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
|
788 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
|
789 \(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
|
790 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
|
791 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
|
792 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
|
793 (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
|
794 Lisp_Object start, end, props, object; |
| 1029 | 795 { |
| 796 register INTERVAL i, unchanged; | |
|
2124
54179ef9ce35
* textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents:
2058
diff
changeset
|
797 register int s, len, modified = 0; |
| 1029 | 798 |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
799 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
800 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
801 |
| 1029 | 802 i = validate_interval_range (object, &start, &end, soft); |
| 803 if (NULL_INTERVAL_P (i)) | |
| 804 return Qnil; | |
| 805 | |
| 806 s = XINT (start); | |
| 807 len = XINT (end) - s; | |
| 1211 | 808 |
| 1029 | 809 if (i->position != s) |
| 810 { | |
| 811 /* No properties on this first interval -- return if | |
| 812 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
|
813 if (! interval_has_some_properties (props, i)) |
| 1029 | 814 { |
| 815 int got = (LENGTH (i) - (s - i->position)); | |
| 816 if (got >= len) | |
| 817 return Qnil; | |
| 818 len -= got; | |
|
3858
e07d474bdba9
(Fremove_text_properties, Fadd_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
3698
diff
changeset
|
819 i = next_interval (i); |
| 1029 | 820 } |
|
3553
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
821 /* 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
|
822 want to modify. */ |
| 1029 | 823 else |
| 824 { | |
| 825 unchanged = i; | |
| 826 i = split_interval_right (unchanged, s - unchanged->position + 1); | |
| 827 copy_properties (unchanged, i); | |
| 828 } | |
| 829 } | |
| 830 | |
| 831 /* 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
|
832 for (;;) |
| 1029 | 833 { |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
834 if (i == 0) |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
835 abort (); |
|
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
836 |
| 1029 | 837 if (LENGTH (i) >= len) |
| 838 { | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
839 if (! interval_has_some_properties (props, i)) |
| 1029 | 840 return modified ? Qt : Qnil; |
| 841 | |
| 842 if (LENGTH (i) == len) | |
| 843 { | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
844 remove_properties (props, i, object); |
| 1029 | 845 return Qt; |
| 846 } | |
| 847 | |
| 848 /* 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
|
849 unchanged = i; |
|
5f9688c0b704
(Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents:
2783
diff
changeset
|
850 i = split_interval_left (i, len + 1); |
| 1029 | 851 copy_properties (unchanged, i); |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
852 remove_properties (props, i, object); |
| 1029 | 853 return Qt; |
| 854 } | |
| 855 | |
| 856 len -= LENGTH (i); | |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
857 modified += remove_properties (props, i, object); |
| 1029 | 858 i = next_interval (i); |
| 859 } | |
| 860 } | |
| 861 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
862 #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
|
863 |
| 1029 | 864 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
|
865 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
|
866 "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
|
867 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
|
868 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
|
869 (start, end, object) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
870 Lisp_Object start, end, object; |
| 1029 | 871 { |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
872 register INTERVAL i; |
| 1305 | 873 register INTERVAL prev_changed = NULL_INTERVAL; |
| 1029 | 874 register int s, len, modified; |
| 875 | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
876 if (NILP (object)) |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
877 XSET (object, Lisp_Buffer, current_buffer); |
|
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
878 |
| 1029 | 879 i = validate_interval_range (object, &start, &end, soft); |
| 880 if (NULL_INTERVAL_P (i)) | |
| 881 return Qnil; | |
| 882 | |
| 883 s = XINT (start); | |
| 884 len = XINT (end) - s; | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
885 |
| 1029 | 886 if (i->position != s) |
| 887 { | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
888 register int got; |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
889 register INTERVAL unchanged = i; |
| 1029 | 890 |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
891 /* 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
|
892 if (! NILP (i->plist)) |
| 1029 | 893 { |
| 894 i = split_interval_right (unchanged, s - unchanged->position + 1); | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
895 i->plist = Qnil; |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
896 modified++; |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
897 |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
898 if (LENGTH (i) > len) |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
899 { |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
900 i = split_interval_right (i, len + 1); |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
901 copy_properties (unchanged, i); |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
902 return Qt; |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
903 } |
| 1029 | 904 |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
905 if (LENGTH (i) == len) |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
906 return Qt; |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
907 |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
908 got = LENGTH (i); |
| 1029 | 909 } |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
910 /* 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
|
911 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
|
912 anything.*/ |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
913 else if (LENGTH (i) - (s - i->position) <= len) |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
914 return Qnil; |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
915 /* 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
|
916 how much we've gotten. */ |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
917 else |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
918 got = LENGTH (i) - (s - i->position); |
| 1029 | 919 |
| 920 len -= got; | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
921 prev_changed = i; |
| 1029 | 922 i = next_interval (i); |
| 923 } | |
| 924 | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
925 /* We are starting at the beginning of an interval, I. */ |
| 1029 | 926 while (len > 0) |
| 927 { | |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
928 if (LENGTH (i) >= len) |
| 1029 | 929 { |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
930 /* 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
|
931 if (NILP (i->plist)) |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
932 { |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
933 if (! NULL_INTERVAL_P (prev_changed)) |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
934 merge_interval_left (i); |
| 1029 | 935 |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
936 return modified ? Qt : Qnil; |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
937 } |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
938 |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
939 if (LENGTH (i) > len) |
|
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
940 i = split_interval_left (i, len + 1); |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
941 if (! NULL_INTERVAL_P (prev_changed)) |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
942 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
|
943 else |
|
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
944 i->plist = Qnil; |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
945 |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
946 return Qt; |
| 1029 | 947 } |
| 948 | |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
949 /* Here if we still need to erase past the end of I */ |
| 1029 | 950 len -= LENGTH (i); |
|
1272
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
951 if (NULL_INTERVAL_P (prev_changed)) |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
952 { |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
953 modified += erase_properties (i); |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
954 prev_changed = i; |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
955 } |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
956 else |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
957 { |
|
1283
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
958 modified += ! NILP (i->plist); |
|
6f4cbcc62eba
Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents:
1272
diff
changeset
|
959 /* 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
|
960 prev_changed = i = merge_interval_left (i); |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
961 } |
|
bfd04f61eb16
Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents:
1211
diff
changeset
|
962 |
| 1029 | 963 i = next_interval (i); |
| 964 } | |
| 965 | |
| 966 return modified ? Qt : Qnil; | |
| 967 } | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
968 #endif /* 0 */ |
| 1029 | 969 |
| 970 void | |
| 971 syms_of_textprop () | |
| 972 { | |
| 973 DEFVAR_INT ("interval-balance-threshold", &interval_balance_threshold, | |
|
1715
cd23f7ef1bd0
* floatfns.c (Flog): Fix unescaped newline in string.
Jim Blandy <jimb@redhat.com>
parents:
1305
diff
changeset
|
974 "Threshold for rebalancing interval trees, expressed as the\n\ |
| 1029 | 975 percentage by which the left interval tree should not differ from the right."); |
| 976 interval_balance_threshold = 8; | |
| 977 | |
| 978 /* Common attributes one might give text */ | |
| 979 | |
| 980 staticpro (&Qforeground); | |
| 981 Qforeground = intern ("foreground"); | |
| 982 staticpro (&Qbackground); | |
| 983 Qbackground = intern ("background"); | |
| 984 staticpro (&Qfont); | |
| 985 Qfont = intern ("font"); | |
| 986 staticpro (&Qstipple); | |
| 987 Qstipple = intern ("stipple"); | |
| 988 staticpro (&Qunderline); | |
| 989 Qunderline = intern ("underline"); | |
| 990 staticpro (&Qread_only); | |
| 991 Qread_only = intern ("read-only"); | |
| 992 staticpro (&Qinvisible); | |
| 993 Qinvisible = intern ("invisible"); | |
|
2058
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
994 staticpro (&Qcategory); |
|
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
995 Qcategory = intern ("category"); |
|
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
996 staticpro (&Qlocal_map); |
|
a43d0bb1b7d8
(Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents:
2053
diff
changeset
|
997 Qlocal_map = intern ("local-map"); |
| 1029 | 998 |
| 999 /* Properties that text might use to specify certain actions */ | |
| 1000 | |
| 1001 staticpro (&Qmouse_left); | |
| 1002 Qmouse_left = intern ("mouse-left"); | |
| 1003 staticpro (&Qmouse_entered); | |
| 1004 Qmouse_entered = intern ("mouse-entered"); | |
| 1005 staticpro (&Qpoint_left); | |
| 1006 Qpoint_left = intern ("point-left"); | |
| 1007 staticpro (&Qpoint_entered); | |
| 1008 Qpoint_entered = intern ("point-entered"); | |
|
2053
8bdcc55ebd8f
(Qmodification_hooks): Renamed from Qmodification.
Richard M. Stallman <rms@gnu.org>
parents:
1965
diff
changeset
|
1009 staticpro (&Qmodification_hooks); |
|
8bdcc55ebd8f
(Qmodification_hooks): Renamed from Qmodification.
Richard M. Stallman <rms@gnu.org>
parents:
1965
diff
changeset
|
1010 Qmodification_hooks = intern ("modification-hooks"); |
| 1029 | 1011 |
| 1012 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
|
1013 defsubr (&Sget_text_property); |
| 1029 | 1014 defsubr (&Snext_property_change); |
| 1211 | 1015 defsubr (&Snext_single_property_change); |
| 1029 | 1016 defsubr (&Sprevious_property_change); |
| 1211 | 1017 defsubr (&Sprevious_single_property_change); |
| 1029 | 1018 defsubr (&Sadd_text_properties); |
|
1965
2bdbd6ed2430
(Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents:
1930
diff
changeset
|
1019 defsubr (&Sput_text_property); |
| 1029 | 1020 defsubr (&Sset_text_properties); |
| 1021 defsubr (&Sremove_text_properties); | |
|
1857
9d65dfc7bdb7
(Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents:
1715
diff
changeset
|
1022 /* defsubr (&Serase_text_properties); */ |
| 1029 | 1023 } |
|
1302
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1024 |
|
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1025 #else |
|
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1026 |
|
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1027 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
|
1028 |
|
538cc0cd6d83
* textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents:
1283
diff
changeset
|
1029 #endif /* USE_TEXT_PROPERTIES */ |
