annotate src/textprop.c @ 1690:256b87a92511

*** empty log message ***
author David J. MacKenzie <djm@gnu.org>
date Tue, 15 Dec 1992 02:35:40 +0000
parents 5c19f71f0314
children cd23f7ef1bd0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1 /* Interface code for dealing with text properties.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
2 Copyright (C) 1992 Free Software Foundation, Inc.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
3
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
5
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
9 any later version.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
10
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
14 GNU General Public License for more details.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
15
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
19
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
20 #include "config.h"
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
21 #include "lisp.h"
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
22 #include "intervals.h"
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
23 #include "buffer.h"
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
24
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
25
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
26 /* NOTES: previous- and next- property change will have to skip
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
27 zero-length intervals if they are implemented. This could be done
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
28 inside next_interval and previous_interval.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
29
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
30 set_properties needs to deal with the interval property cache.
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
31
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
32 It is assumed that for any interval plist, a property appears
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
33 only once on the list. Although some code i.e., remove_properties (),
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
34 handles the more general case, the uniqueness of properties is
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
35 neccessary for the system to remain consistent. This requirement
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
36 is enforced by the subrs installing properties onto the intervals. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
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
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
40
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41 /* Types of hooks. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
42 Lisp_Object Qmouse_left;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
43 Lisp_Object Qmouse_entered;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 Lisp_Object Qpoint_left;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45 Lisp_Object Qpoint_entered;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 Lisp_Object Qmodification;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
48 /* Visual properties text (including strings) may have. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
49 Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
50 Lisp_Object Qinvisible, Qread_only;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
51
1055
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
52 /* Extract the interval at the position pointed to by BEGIN from
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
53 OBJECT, a string or buffer. Additionally, check that the positions
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
54 pointed to by BEGIN and END are within the bounds of OBJECT, and
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
55 reverse them if *BEGIN is greater than *END. The objects pointed
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
56 to by BEGIN and END may be integers or markers; if the latter, they
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
57 are coerced to integers.
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
59 Note that buffer points don't correspond to interval indices.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
60 For example, point-max is 1 greater than the index of the last
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
61 character. This difference is handled in the caller, which uses
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
62 the validated points to determine a length, and operates on that.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
63 Exceptions are Ftext_properties_at, Fnext_property_change, and
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
64 Fprevious_property_change which call this function with BEGIN == END.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
65 Handle this case specially.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
66
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
67 If FORCE is soft (0), it's OK to return NULL_INTERVAL. Otherwise,
1055
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
68 create an interval tree for OBJECT if one doesn't exist, provided
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
69 the object actually contains text. In the current design, if there
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
70 is no text, there can be no text properties. */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
71
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 #define soft 0
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73 #define hard 1
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
74
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75 static INTERVAL
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 validate_interval_range (object, begin, end, force)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
77 Lisp_Object object, *begin, *end;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
78 int force;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 register INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 CHECK_STRING_OR_BUFFER (object, 0);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
82 CHECK_NUMBER_COERCE_MARKER (*begin, 0);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
83 CHECK_NUMBER_COERCE_MARKER (*end, 0);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
84
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
85 /* If we are asked for a point, but from a subr which operates
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
86 on a range, then return nothing. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
87 if (*begin == *end && begin != end)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
88 return NULL_INTERVAL;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
89
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
90 if (XINT (*begin) > XINT (*end))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
91 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
92 register int n;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
93 n = XFASTINT (*begin); /* This is legit even if *begin is < 0 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94 *begin = *end;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 XFASTINT (*end) = n; /* because this is all we do with n. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98 if (XTYPE (object) == Lisp_Buffer)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 register struct buffer *b = XBUFFER (object);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
101
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
102 /* If there's no text, there are no properties. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 if (BUF_BEGV (b) == BUF_ZV (b))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104 return NULL_INTERVAL;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
106 if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
107 && XINT (*end) <= BUF_ZV (b)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
108 args_out_of_range (*begin, *end);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
109 i = b->intervals;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
110
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
111 /* Special case for point-max: return the interval for the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
112 last character. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
113 if (*begin == *end && *begin == BUF_Z (b))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
114 *begin -= 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
115 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
116 else
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
117 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
118 register struct Lisp_String *s = XSTRING (object);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
119
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
120 if (! (1 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
121 && XINT (*end) <= s->size))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
122 args_out_of_range (*begin, *end);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
123 i = s->intervals;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
124 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
125
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
126 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
127 return (force ? create_root_interval (object) : i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
128
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
129 return find_interval (i, XINT (*begin));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
130 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
131
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
132 /* Validate LIST as a property list. If LIST is not a list, then
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
133 make one consisting of (LIST nil). Otherwise, verify that LIST
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
134 is even numbered and thus suitable as a plist. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
135
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
136 static Lisp_Object
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
137 validate_plist (list)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
138 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
139 if (NILP (list))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
140 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
141
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
142 if (CONSP (list))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
143 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
144 register int i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
145 register Lisp_Object tail;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
146 for (i = 0, tail = list; !NILP (tail); i++)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
147 tail = Fcdr (tail);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
148 if (i & 1)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
149 error ("Odd length text property list");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
150 return list;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
151 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
152
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
153 return Fcons (list, Fcons (Qnil, Qnil));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
154 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
155
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
156 #define set_properties(list,i) (i->plist = Fcopy_sequence (list))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
157
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
158 /* Return nonzero if interval I has all the properties,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
159 with the same values, of list PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
160
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
161 static int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
162 interval_has_all_properties (plist, i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
163 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
164 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
165 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
166 register Lisp_Object tail1, tail2, sym1, sym2;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
167 register int found;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
168
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
169 /* Go through each element of PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
170 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
171 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
172 sym1 = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
173 found = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
174
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
175 /* Go through I's plist, looking for sym1 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
176 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
177 if (EQ (sym1, Fcar (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
178 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
179 /* Found the same property on both lists. If the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
180 values are unequal, return zero. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
181 if (! EQ (Fequal (Fcar (Fcdr (tail1)), Fcar (Fcdr (tail2))),
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
182 Qt))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
183 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
184
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
185 /* Property has same value on both lists; go to next one. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
186 found = 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
187 break;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
188 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
189
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
190 if (! found)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
191 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
192 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
193
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
194 return 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
195 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
196
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
197 /* Return nonzero if the plist of interval I has any of the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
198 properties of PLIST, regardless of their values. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
199
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
200 static INLINE int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
201 interval_has_some_properties (plist, i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
202 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
203 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
204 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
205 register Lisp_Object tail1, tail2, sym;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
206
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
207 /* Go through each element of PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
208 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
209 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
210 sym = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
211
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
212 /* Go through i's plist, looking for tail1 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
213 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
214 if (EQ (sym, Fcar (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
215 return 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
216 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
217
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
218 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
219 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
220
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
221 /* Add the properties of PLIST to the interval I, or set
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
222 the value of I's property to the value of the property on PLIST
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
223 if they are different.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
224
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
225 Return nonzero if this changes I (i.e., if any members of PLIST
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
226 are actually added to I's plist) */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
227
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
228 static INLINE int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
229 add_properties (plist, i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
230 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
231 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
232 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
233 register Lisp_Object tail1, tail2, sym1, val1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
234 register int changed = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
235 register int found;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
236
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
237 /* Go through each element of PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
238 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
239 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
240 sym1 = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
241 val1 = Fcar (Fcdr (tail1));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
242 found = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
243
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
244 /* Go through I's plist, looking for sym1 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
245 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
246 if (EQ (sym1, Fcar (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
247 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
248 register Lisp_Object this_cdr = Fcdr (tail2);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
249
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
250 /* Found the property. Now check its value. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
251 found = 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
252
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
253 /* The properties have the same value on both lists.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
254 Continue to the next property. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
255 if (Fequal (val1, Fcar (this_cdr)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
256 break;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
257
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
258 /* I's property has a different value -- change it */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
259 Fsetcar (this_cdr, val1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
260 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
261 break;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
262 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
263
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
264 if (! found)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
265 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
266 i->plist = Fcons (sym1, Fcons (val1, i->plist));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
267 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
268 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
269 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
270
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
271 return changed;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
272 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
273
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
274 /* For any members of PLIST which are properties of I, remove them
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
275 from I's plist. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
276
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
277 static INLINE int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
278 remove_properties (plist, i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
279 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
280 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
281 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
282 register Lisp_Object tail1, tail2, sym;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
283 register Lisp_Object current_plist = i->plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
284 register int changed = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
285
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
286 /* Go through each element of plist. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
287 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
288 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
289 sym = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
290
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
291 /* First, remove the symbol if its at the head of the list */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
292 while (! NILP (current_plist) && EQ (sym, Fcar (current_plist)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
293 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
294 current_plist = Fcdr (Fcdr (current_plist));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
295 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
296 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
297
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
298 /* Go through i's plist, looking for sym */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
299 tail2 = current_plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
300 while (! NILP (tail2))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
301 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
302 register Lisp_Object this = Fcdr (Fcdr (tail2));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
303 if (EQ (sym, Fcar (this)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
304 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
305 Fsetcdr (Fcdr (tail2), Fcdr (Fcdr (this)));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
306 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
307 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
308 tail2 = this;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
309 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
310 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
311
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
312 if (changed)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
313 i->plist = current_plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
314 return changed;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
315 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
316
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
317 /* Remove all properties from interval I. Return non-zero
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
318 if this changes the interval. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
319
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
320 static INLINE int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
321 erase_properties (i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
322 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
323 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
324 if (NILP (i->plist))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
325 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
326
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
327 i->plist = Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
328 return 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
329 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
330
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
331 DEFUN ("text-properties-at", Ftext_properties_at,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
332 Stext_properties_at, 1, 2, 0,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
333 "Return the list of properties held by the character at POSITION\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
334 in optional argument OBJECT, a string or buffer. If nil, OBJECT\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
335 defaults to the current buffer.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
336 (pos, object)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
337 Lisp_Object pos, object;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
338 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
339 register INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
340 register int p;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
341
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
342 if (NILP (object))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
343 XSET (object, Lisp_Buffer, current_buffer);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
344
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
345 i = validate_interval_range (object, &pos, &pos, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
346 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
347 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
348
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
349 return i->plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
350 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
351
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
352 DEFUN ("next-property-change", Fnext_property_change,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
353 Snext_property_change, 2, 2, 0,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
354 "Return the position after POSITION in OBJECT which has properties\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
355 different from those at POSITION. OBJECT may be a string or buffer.\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
356 Returns nil if unsuccessful.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
357 (pos, object)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
358 Lisp_Object pos, object;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
359 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
360 register INTERVAL i, next;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
361
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
362 i = validate_interval_range (object, &pos, &pos, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
363 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
364 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
365
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
366 next = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
367 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
368 next = next_interval (next);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
369
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
370 if (NULL_INTERVAL_P (next))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
371 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
372
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
373 return next->position;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
374 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
375
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
376 DEFUN ("next-single-property-change", Fnext_single_property_change,
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
377 Snext_single_property_change, 3, 3, 0,
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
378 "Return the position after POSITION in OBJECT which has a different\n\
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
379 value for PROPERTY than the text at POSITION. OBJECT may be a string or\n\
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
380 buffer. Returns nil if unsuccessful.")
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
381 (pos, object, prop)
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
382 {
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
383 register INTERVAL i, next;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
384 register Lisp_Object here_val;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
385
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
386 i = validate_interval_range (object, &pos, &pos, soft);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
387 if (NULL_INTERVAL_P (i))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
388 return Qnil;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
389
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
390 here_val = Fget (prop, i->plist);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
391 next = next_interval (i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
392 while (! NULL_INTERVAL_P (next) && EQ (here_val, Fget (prop, next->plist)))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
393 next = next_interval (next);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
394
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
395 if (NULL_INTERVAL_P (next))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
396 return Qnil;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
397
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
398 return next->position;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
399 }
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
400
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
401 DEFUN ("previous-property-change", Fprevious_property_change,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
402 Sprevious_property_change, 2, 2, 0,
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
403 "Return the position preceding POSITION in OBJECT which has properties\n\
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
404 different from those at POSITION. OBJECT may be a string or buffer.\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
405 Returns nil if unsuccessful.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
406 (pos, object)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
407 Lisp_Object pos, object;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
408 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
409 register INTERVAL i, previous;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
410
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
411 i = validate_interval_range (object, &pos, &pos, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
412 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
413 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
414
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
415 previous = previous_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
416 while (! NULL_INTERVAL_P (previous) && intervals_equal (previous, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
417 previous = previous_interval (previous);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
418 if (NULL_INTERVAL_P (previous))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
419 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
420
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
421 return previous->position + LENGTH (previous) - 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
422 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
423
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
424 DEFUN ("previous-single-property-change", Fprevious_single_property_change,
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
425 Sprevious_single_property_change, 3, 3, 0,
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
426 "Return the position preceding POSITION in OBJECT which has a\n\
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
427 different value for PROPERTY than the text at POSITION. OBJECT may be
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
428 a string or buffer. Returns nil if unsuccessful.")
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
429 (pos, object, prop)
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
430 {
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
431 register INTERVAL i, previous;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
432 register Lisp_Object here_val;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
433
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
434 i = validate_interval_range (object, &pos, &pos, soft);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
435 if (NULL_INTERVAL_P (i))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
436 return Qnil;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
437
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
438 here_val = Fget (prop, i->plist);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
439 previous = previous_interval (i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
440 while (! NULL_INTERVAL_P (previous)
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
441 && EQ (here_val, Fget (prop, previous->plist)))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
442 previous = previous_interval (previous);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
443 if (NULL_INTERVAL_P (previous))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
444 return Qnil;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
445
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
446 return previous->position + LENGTH (previous) - 1;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
447 }
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
448
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
449 DEFUN ("add-text-properties", Fadd_text_properties,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
450 Sadd_text_properties, 4, 4, 0,
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
451 "Add the PROPERTIES, a property list, to the text of OBJECT,\n\
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
452 a string or buffer, in the range START to END. Returns t if any change\n\
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
453 was made, nil otherwise.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
454 (object, start, end, properties)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
455 Lisp_Object object, start, end, properties;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
456 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
457 register INTERVAL i, unchanged;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
458 register int s, len, modified;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
459
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
460 properties = validate_plist (properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
461 if (NILP (properties))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
462 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
463
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
464 i = validate_interval_range (object, &start, &end, hard);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
465 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
466 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
467
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
468 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
469 len = XINT (end) - s;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
470
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
471 /* If we're not starting on an interval boundary, we have to
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
472 split this interval. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
473 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
474 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
475 /* If this interval already has the properties, we can
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
476 skip it. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
477 if (interval_has_all_properties (properties, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
478 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
479 int got = (LENGTH (i) - (s - i->position));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
480 if (got >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
481 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
482 len -= got;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
483 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
484 else
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
485 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
486 unchanged = i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
487 i = split_interval_right (unchanged, s - unchanged->position + 1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
488 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
489 if (LENGTH (i) > len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
490 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
491 i = split_interval_left (i, len + 1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
492 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
493 add_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
494 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
495 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
496
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
497 add_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
498 modified = 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
499 len -= LENGTH (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
500 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
501 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
502 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
503
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
504 /* We are at the beginning of an interval, with len to scan */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
505 while (1)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
506 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
507 if (LENGTH (i) >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
508 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
509 if (interval_has_all_properties (properties, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
510 return modified ? Qt : Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
511
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
512 if (LENGTH (i) == len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
513 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
514 add_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
515 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
516 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
517
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
518 /* i doesn't have the properties, and goes past the change limit */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
519 unchanged = i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
520 i = split_interval_left (unchanged, len + 1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
521 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
522 add_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
523 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
524 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
525
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
526 len -= LENGTH (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
527 modified += add_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
528 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
529 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
530 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
531
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
532 DEFUN ("set-text-properties", Fset_text_properties,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
533 Sset_text_properties, 4, 4, 0,
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
534 "Make the text of OBJECT, a string or buffer, have precisely\n\
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
535 PROPERTIES, a list of properties, in the range START to END.\n\
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
536 \n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
537 If called with a valid property list, return t (text was changed).\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
538 Otherwise return nil.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
539 (object, start, end, properties)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
540 Lisp_Object object, start, end, properties;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
541 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
542 register INTERVAL i, unchanged;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
543 register INTERVAL prev_changed = NULL_INTERVAL;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
544 register int s, len;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
545
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
546 properties = validate_plist (properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
547 if (NILP (properties))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
548 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
549
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
550 i = validate_interval_range (object, &start, &end, hard);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
551 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
552 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
553
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
554 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
555 len = XINT (end) - s;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
556
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
557 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
558 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
559 unchanged = i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
560 i = split_interval_right (unchanged, s - unchanged->position + 1);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
561 set_properties (properties, i);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
562
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
563 if (LENGTH (i) > len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
564 {
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
565 i = split_interval_right (i, len);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
566 copy_properties (unchanged, i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
567 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
568 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
569
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
570 if (LENGTH (i) == len)
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
571 return Qt;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
572
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
573 prev_changed = i;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
574 len -= LENGTH (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
575 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
576 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
577
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
578 /* 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
579 while (len > 0)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
580 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
581 if (LENGTH (i) >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
582 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
583 if (LENGTH (i) > len)
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
584 i = split_interval_left (i, len + 1);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
585
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
586 if (NULL_INTERVAL_P (prev_changed))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
587 set_properties (properties, i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
588 else
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
589 merge_interval_left (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
590 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
591 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
592
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
593 len -= LENGTH (i);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
594 if (NULL_INTERVAL_P (prev_changed))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
595 {
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
596 set_properties (properties, i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
597 prev_changed = i;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
598 }
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
599 else
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
600 prev_changed = i = merge_interval_left (i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
601
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
602 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
603 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
604
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
605 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
606 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
607
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
608 DEFUN ("remove-text-properties", Fremove_text_properties,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
609 Sremove_text_properties, 4, 4, 0,
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
610 "Remove the PROPERTIES, a property list, from the text of OBJECT,\n\
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
611 a string or buffer, in the range START to END. Returns t if any change\n\
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
612 was made, nil otherwise.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
613 (object, start, end, properties)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
614 Lisp_Object object, start, end, properties;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
615 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
616 register INTERVAL i, unchanged;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
617 register int s, len, modified;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
618
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
619 i = validate_interval_range (object, &start, &end, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
620 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
621 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
622
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
623 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
624 len = XINT (end) - s;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
625
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
626 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
627 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
628 /* No properties on this first interval -- return if
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
629 it covers the entire region. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
630 if (! interval_has_some_properties (properties, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
631 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
632 int got = (LENGTH (i) - (s - i->position));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
633 if (got >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
634 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
635 len -= got;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
636 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
637 /* Remove the properties from this interval. If it's short
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
638 enough, return, splitting it if it's too short. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
639 else
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
640 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
641 unchanged = i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
642 i = split_interval_right (unchanged, s - unchanged->position + 1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
643 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
644 if (LENGTH (i) > len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
645 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
646 i = split_interval_left (i, len + 1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
647 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
648 remove_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
649 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
650 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
651
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
652 remove_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
653 modified = 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
654 len -= LENGTH (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
655 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
656 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
657 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
658
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
659 /* We are at the beginning of an interval, with len to scan */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
660 while (1)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
661 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
662 if (LENGTH (i) >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
663 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
664 if (! interval_has_some_properties (properties, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
665 return modified ? Qt : Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
666
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
667 if (LENGTH (i) == len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
668 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
669 remove_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
670 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
671 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
672
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
673 /* i has the properties, and goes past the change limit */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
674 unchanged = split_interval_right (i, len + 1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
675 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
676 remove_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
677 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
678 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
679
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
680 len -= LENGTH (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
681 modified += remove_properties (properties, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
682 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
683 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
684 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
685
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
686 DEFUN ("erase-text-properties", Ferase_text_properties,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
687 Serase_text_properties, 3, 3, 0,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
688 "Remove all text properties from OBJECT (a string or buffer), in the\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
689 range START to END. Returns t if any change was made, nil otherwise.")
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
690 (object, start, end)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
691 Lisp_Object object, start, end;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
692 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
693 register INTERVAL i;
1305
5c19f71f0314 Fixed typeos.
Joseph Arceneaux <jla@gnu.org>
parents: 1302
diff changeset
694 register INTERVAL prev_changed = NULL_INTERVAL;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
695 register int s, len, modified;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
696
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
697 i = validate_interval_range (object, &start, &end, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
698 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
699 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
700
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
701 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
702 len = XINT (end) - s;
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
703
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
704 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
705 {
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
706 register int got;
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
707 register INTERVAL unchanged = i;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
708
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
709 /* 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
710 if (! NILP (i->plist))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
711 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
712 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
713 i->plist = Qnil;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
714 modified++;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
715
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
716 if (LENGTH (i) > len)
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
717 {
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
718 i = split_interval_right (i, len + 1);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
719 copy_properties (unchanged, i);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
720 return Qt;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
721 }
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
722
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
723 if (LENGTH (i) == len)
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
724 return Qt;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
725
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
726 got = LENGTH (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
727 }
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
728 /* 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
729 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
730 anything.*/
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
731 else if (LENGTH (i) - (s - i->position) <= len)
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
732 return Qnil;
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
733 /* 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
734 how much we've gotten. */
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
735 else
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
736 got = LENGTH (i) - (s - i->position);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
737
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
738 len -= got;
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
739 prev_changed = i;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
740 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
741 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
742
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
743 /* We are starting at the beginning of an interval, I. */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
744 while (len > 0)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
745 {
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
746 if (LENGTH (i) >= len)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
747 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
748 /* 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
749 if (NILP (i->plist))
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
750 {
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
751 if (! NULL_INTERVAL_P (prev_changed))
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
752 merge_interval_left (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
753
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
754 return modified ? Qt : Qnil;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
755 }
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
756
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
757 if (LENGTH (i) > len)
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
758 i = split_interval_left (i, len + 1);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
759 if (! NULL_INTERVAL_P (prev_changed))
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
760 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
761 else
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
762 i->plist = Qnil;
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
763
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
764 return Qt;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
765 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
766
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
767 /* Here if we still need to erase past the end of I */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
768 len -= LENGTH (i);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
769 if (NULL_INTERVAL_P (prev_changed))
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
770 {
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
771 modified += erase_properties (i);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
772 prev_changed = i;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
773 }
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
774 else
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
775 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
776 modified += ! NILP (i->plist);
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
777 /* 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
778 prev_changed = i = merge_interval_left (i);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
779 }
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
780
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
781 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
782 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
783
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
784 return modified ? Qt : Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
785 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
786
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
787 void
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
788 syms_of_textprop ()
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
789 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
790 DEFVAR_INT ("interval-balance-threshold", &interval_balance_threshold,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
791 "Threshold for rebalancing interval trees, expressed as the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
792 percentage by which the left interval tree should not differ from the right.");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
793 interval_balance_threshold = 8;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
794
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
795 /* Common attributes one might give text */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
796
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
797 staticpro (&Qforeground);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
798 Qforeground = intern ("foreground");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
799 staticpro (&Qbackground);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
800 Qbackground = intern ("background");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
801 staticpro (&Qfont);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
802 Qfont = intern ("font");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
803 staticpro (&Qstipple);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
804 Qstipple = intern ("stipple");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
805 staticpro (&Qunderline);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
806 Qunderline = intern ("underline");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
807 staticpro (&Qread_only);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
808 Qread_only = intern ("read-only");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
809 staticpro (&Qinvisible);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
810 Qinvisible = intern ("invisible");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
811
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
812 /* Properties that text might use to specify certain actions */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
813
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
814 staticpro (&Qmouse_left);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
815 Qmouse_left = intern ("mouse-left");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
816 staticpro (&Qmouse_entered);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
817 Qmouse_entered = intern ("mouse-entered");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
818 staticpro (&Qpoint_left);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
819 Qpoint_left = intern ("point-left");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
820 staticpro (&Qpoint_entered);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
821 Qpoint_entered = intern ("point-entered");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
822 staticpro (&Qmodification);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
823 Qmodification = intern ("modification");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
824
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
825 defsubr (&Stext_properties_at);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
826 defsubr (&Snext_property_change);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
827 defsubr (&Snext_single_property_change);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
828 defsubr (&Sprevious_property_change);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
829 defsubr (&Sprevious_single_property_change);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
830 defsubr (&Sadd_text_properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
831 defsubr (&Sset_text_properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
832 defsubr (&Sremove_text_properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
833 defsubr (&Serase_text_properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
834 }
1302
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
835
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
836 #else
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
837
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
838 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
839
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
840 #endif /* USE_TEXT_PROPERTIES */