annotate src/textprop.c @ 2111:d38d32084c15

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