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