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