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