annotate src/textprop.c @ 4296:294aa73cf31c

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