annotate src/textprop.c @ 9321:e6759002383c

(Fnext_property_change, property_change_between_p, Fnext_single_property_change, Fprevious_property_change, Fprevious_single_property_change, copy_text_properties): Don't use XFASTINT as an lvalue.
author Karl Heuer <kwzh@gnu.org>
date Tue, 04 Oct 1994 16:14:59 +0000
parents 4b238c43e59f
children bbf226780027
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.
7307
cd81dba38a49 Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 7092
diff changeset
2 Copyright (C) 1993, 1994 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
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4649
diff changeset
20 #include <config.h>
1029
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"
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
24 #include "window.h"
8962
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
25
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
26 #ifndef NULL
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
27 #define NULL (void *)0
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
28 #endif
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
29
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
30
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
31 /* NOTES: previous- and next- property change will have to skip
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
32 zero-length intervals if they are implemented. This could be done
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
33 inside next_interval and previous_interval.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
34
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
35 set_properties needs to deal with the interval property cache.
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
36
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 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
38 only once on the list. Although some code i.e., remove_properties,
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 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
40 necessary for the system to remain consistent. This requirement
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41 is enforced by the subrs installing properties onto the intervals. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
42
1302
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
43 /* 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
44 #ifdef USE_TEXT_PROPERTIES
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 /* Types of hooks. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47 Lisp_Object Qmouse_left;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
48 Lisp_Object Qmouse_entered;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
49 Lisp_Object Qpoint_left;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
50 Lisp_Object Qpoint_entered;
2058
a43d0bb1b7d8 (Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents: 2053
diff changeset
51 Lisp_Object Qcategory;
a43d0bb1b7d8 (Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents: 2053
diff changeset
52 Lisp_Object Qlocal_map;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
53
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
54 /* Visual properties text (including strings) may have. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
55 Lisp_Object Qforeground, Qbackground, Qfont, Qunderline, Qstipple;
6755
a2bccbc870e6 (syms_of_textprop): Initialize Qintangible.
Karl Heuer <kwzh@gnu.org>
parents: 6681
diff changeset
56 Lisp_Object Qinvisible, Qread_only, Qintangible;
4381
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
57
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
58 /* Sticky properties */
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
59 Lisp_Object Qfront_sticky, Qrear_nonsticky;
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
60
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
61 /* 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
62 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
63 traversing plists. */
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
64 #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
65
4242
49007dbbec4c (syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents: 4214
diff changeset
66 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
67
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
68
1055
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
69 /* Extract the interval at the position pointed to by BEGIN from
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
70 OBJECT, a string or buffer. Additionally, check that the positions
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
71 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
72 reverse them if *BEGIN is greater than *END. The objects pointed
7eb43ab890e0 entered into RCS
Joseph Arceneaux <jla@gnu.org>
parents: 1029
diff changeset
73 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
74 are coerced to integers.
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
76 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
77 to make them origin-one.
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
78
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 Note that buffer points don't correspond to interval indices.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 For example, point-max is 1 greater than the index of the last
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 character. This difference is handled in the caller, which uses
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
82 the validated points to determine a length, and operates on that.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
83 Exceptions are Ftext_properties_at, Fnext_property_change, and
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
84 Fprevious_property_change which call this function with BEGIN == END.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
85 Handle this case specially.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
86
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
87 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
88 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
89 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
90 is no text, there can be no text properties. */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
91
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
92 #define soft 0
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
93 #define hard 1
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95 static INTERVAL
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 validate_interval_range (object, begin, end, force)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 Lisp_Object object, *begin, *end;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98 int force;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 register INTERVAL i;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
101 int searchpos;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
102
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 CHECK_STRING_OR_BUFFER (object, 0);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104 CHECK_NUMBER_COERCE_MARKER (*begin, 0);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105 CHECK_NUMBER_COERCE_MARKER (*end, 0);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
106
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
107 /* If we are asked for a point, but from a subr which operates
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
108 on a range, then return nothing. */
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
109 if (EQ (*begin, *end) && begin != end)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
110 return NULL_INTERVAL;
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 (XINT (*begin) > XINT (*end))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
113 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
114 Lisp_Object n;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
115 n = *begin;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
116 *begin = *end;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
117 *end = n;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
118 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
119
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
120 if (BUFFERP (object))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
121 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
122 register struct buffer *b = XBUFFER (object);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
123
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
124 if (!(BUF_BEGV (b) <= XINT (*begin) && XINT (*begin) <= XINT (*end)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
125 && XINT (*end) <= BUF_ZV (b)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
126 args_out_of_range (*begin, *end);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
127 i = b->intervals;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
128
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
129 /* 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
130 if (BUF_BEGV (b) == BUF_ZV (b))
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
131 return NULL_INTERVAL;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
132
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
133 searchpos = XINT (*begin);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
134 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
135 else
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
136 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
137 register struct Lisp_String *s = XSTRING (object);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
138
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
139 if (! (0 <= XINT (*begin) && XINT (*begin) <= XINT (*end)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
140 && XINT (*end) <= s->size))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
141 args_out_of_range (*begin, *end);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
142 /* 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
143 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
144 XFASTINT (*begin) += 1;
3996
b9bdcf862c67 * textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents: 3960
diff changeset
145 if (begin != end)
b9bdcf862c67 * textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents: 3960
diff changeset
146 XFASTINT (*end) += 1;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
147 i = s->intervals;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
148
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
149 if (s->size == 0)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
150 return NULL_INTERVAL;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
151
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
152 searchpos = XINT (*begin);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
153 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
154
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
155 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
156 return (force ? create_root_interval (object) : i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
157
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
158 return find_interval (i, searchpos);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
159 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
160
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
161 /* Validate LIST as a property list. If LIST is not a list, then
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
162 make one consisting of (LIST nil). Otherwise, verify that LIST
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
163 is even numbered and thus suitable as a plist. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
164
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
165 static Lisp_Object
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
166 validate_plist (list)
4797
4dd43e41207a (validate_plist): Add argument declaration for `list'.
Brian Fox <bfox@gnu.org>
parents: 4696
diff changeset
167 Lisp_Object list;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
168 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
169 if (NILP (list))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
170 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
171
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
172 if (CONSP (list))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
173 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
174 register int i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
175 register Lisp_Object tail;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
176 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
177 {
b9bdcf862c67 * textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents: 3960
diff changeset
178 tail = Fcdr (tail);
b9bdcf862c67 * textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents: 3960
diff changeset
179 QUIT;
b9bdcf862c67 * textprop.c (validate_interval_range): Don't increment both
Jim Blandy <jimb@redhat.com>
parents: 3960
diff changeset
180 }
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
181 if (i & 1)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
182 error ("Odd length text property list");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
183 return list;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
184 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
185
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
186 return Fcons (list, Fcons (Qnil, Qnil));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
187 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
188
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
189 /* Return nonzero if interval I has all the properties,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
190 with the same values, of list PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
191
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
192 static int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
193 interval_has_all_properties (plist, i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
194 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
195 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
196 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
197 register Lisp_Object tail1, tail2, sym1, sym2;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
198 register int found;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
199
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
200 /* Go through each element of PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
201 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
202 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
203 sym1 = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
204 found = 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 /* Go through I's plist, looking for sym1 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
207 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
208 if (EQ (sym1, Fcar (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
209 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
210 /* Found the same property on both lists. If the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
211 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
212 if (! EQ (Fcar (Fcdr (tail1)), Fcar (Fcdr (tail2))))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
213 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
214
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
215 /* Property has same value on both lists; go to next one. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
216 found = 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
217 break;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
218 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
219
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
220 if (! found)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
221 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
222 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
223
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
224 return 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
225 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
226
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
227 /* Return nonzero if the plist of interval I has any of the
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
228 properties of PLIST, regardless of their values. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
229
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
230 static INLINE int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
231 interval_has_some_properties (plist, i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
232 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
233 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
234 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
235 register Lisp_Object tail1, tail2, sym;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
236
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
237 /* Go through each element of PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
238 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
239 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
240 sym = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
241
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
242 /* Go through i's plist, looking for tail1 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
243 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
244 if (EQ (sym, Fcar (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
245 return 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
246 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
247
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
248 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
249 }
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
250
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
251 /* 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
252
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
253 /* 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
254 has none. */
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
255 static Lisp_Object
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
256 property_value (plist, prop)
8856
7e9547af43e8 (property_value): Declare args plist, prop.
Richard M. Stallman <rms@gnu.org>
parents: 8762
diff changeset
257 Lisp_Object plist, prop;
3960
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 Lisp_Object value;
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
260
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
261 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
262 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
263 return XCONS (value)->car;
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
264 else
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
265 plist = XCONS (value)->cdr;
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
266
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
267 return Qunbound;
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
268 }
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
269
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
270 /* Set the properties of INTERVAL to PROPERTIES,
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
271 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
272 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
273
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
274 static void
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
275 set_properties (properties, interval, object)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
276 Lisp_Object properties, object;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
277 INTERVAL interval;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
278 {
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
279 Lisp_Object sym, value;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
280
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
281 if (BUFFERP (object))
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
282 {
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
283 /* 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
284 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
285 for (sym = interval->plist;
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
286 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
287 sym = XCONS (value)->cdr)
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
288 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
289 XCONS (value)->car))
4076
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
290 {
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
291 modify_region (XBUFFER (object),
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
292 make_number (interval->position),
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
293 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
294 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
295 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
296 object);
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
297 }
3960
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
298
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
299 /* 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
300 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
301 for (sym = properties;
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
302 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
303 sym = XCONS (value)->cdr)
7be89f84a882 * textprop.c (set_properties): Add undo records to remove entirely
Jim Blandy <jimb@redhat.com>
parents: 3858
diff changeset
304 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
305 {
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
306 modify_region (XBUFFER (object),
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
307 make_number (interval->position),
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
308 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
309 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
310 XCONS (sym)->car, Qnil,
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
311 object);
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
312 }
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
313 }
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
314
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
315 /* Store new properties. */
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
316 interval->plist = Fcopy_sequence (properties);
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
317 }
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
318
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
319 /* Add the properties of PLIST to the interval I, or set
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
320 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
321 if they are different.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
322
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
323 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
324
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
325 Return nonzero if this changes I (i.e., if any members of PLIST
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
326 are actually added to I's plist) */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
327
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
328 static int
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
329 add_properties (plist, i, object)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
330 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
331 INTERVAL i;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
332 Lisp_Object object;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
333 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
334 register Lisp_Object tail1, tail2, sym1, val1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
335 register int changed = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
336 register int found;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
337
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
338 /* Go through each element of PLIST. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
339 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
340 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
341 sym1 = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
342 val1 = Fcar (Fcdr (tail1));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
343 found = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
344
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
345 /* Go through I's plist, looking for sym1 */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
346 for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
347 if (EQ (sym1, Fcar (tail2)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
348 {
6516
8278049ee7a7 (add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6064
diff changeset
349 register Lisp_Object this_cdr;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
350
6516
8278049ee7a7 (add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6064
diff changeset
351 this_cdr = Fcdr (tail2);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
352 /* Found the property. Now check its value. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
353 found = 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
354
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
355 /* The properties have the same value on both lists.
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
356 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
357 if (EQ (val1, Fcar (this_cdr)))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
358 break;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
359
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
360 /* Record this change in the buffer, for undo purposes. */
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
361 if (BUFFERP (object))
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
362 {
2783
789c11177579 The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents: 2762
diff changeset
363 modify_region (XBUFFER (object),
789c11177579 The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents: 2762
diff changeset
364 make_number (i->position),
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
365 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
366 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
367 sym1, Fcar (this_cdr), object);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
368 }
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
369
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
370 /* I's property has a different value -- change it */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
371 Fsetcar (this_cdr, val1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
372 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
373 break;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
374 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
375
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
376 if (! found)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
377 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
378 /* Record this change in the buffer, for undo purposes. */
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
379 if (BUFFERP (object))
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
380 {
2783
789c11177579 The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents: 2762
diff changeset
381 modify_region (XBUFFER (object),
789c11177579 The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents: 2762
diff changeset
382 make_number (i->position),
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
383 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
384 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
385 sym1, Qnil, object);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
386 }
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
387 i->plist = Fcons (sym1, Fcons (val1, i->plist));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
388 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
389 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
390 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
391
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
392 return changed;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
393 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
394
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
395 /* 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
396 from I's plist.
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
397 OBJECT is the string or buffer containing I. */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
398
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
399 static int
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
400 remove_properties (plist, i, object)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
401 Lisp_Object plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
402 INTERVAL i;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
403 Lisp_Object object;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
404 {
6516
8278049ee7a7 (add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6064
diff changeset
405 register Lisp_Object tail1, tail2, sym, current_plist;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
406 register int changed = 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
407
6516
8278049ee7a7 (add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6064
diff changeset
408 current_plist = i->plist;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
409 /* Go through each element of plist. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
410 for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
411 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
412 sym = Fcar (tail1);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
413
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
414 /* First, remove the symbol if its at the head of the list */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
415 while (! NILP (current_plist) && EQ (sym, Fcar (current_plist)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
416 {
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
417 if (BUFFERP (object))
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
418 {
4076
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
419 modify_region (XBUFFER (object),
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
420 make_number (i->position),
9fd5ecacfbbb (Qinsert_in_front_hooks, Qinsert_behind_hooks): New vars.
Richard M. Stallman <rms@gnu.org>
parents: 4007
diff changeset
421 make_number (i->position + LENGTH (i)));
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
422 record_property_change (i->position, LENGTH (i),
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
423 sym, Fcar (Fcdr (current_plist)),
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
424 object);
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
425 }
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
426
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
427 current_plist = Fcdr (Fcdr (current_plist));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
428 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
429 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
430
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
431 /* Go through i's plist, looking for sym */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
432 tail2 = current_plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
433 while (! NILP (tail2))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
434 {
6516
8278049ee7a7 (add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6064
diff changeset
435 register Lisp_Object this;
8278049ee7a7 (add_properties, remove_properties): Use assignment, not initialization.
Karl Heuer <kwzh@gnu.org>
parents: 6064
diff changeset
436 this = Fcdr (Fcdr (tail2));
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
437 if (EQ (sym, Fcar (this)))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
438 {
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
439 if (BUFFERP (object))
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
440 {
2783
789c11177579 The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents: 2762
diff changeset
441 modify_region (XBUFFER (object),
789c11177579 The text property routines can now modify buffers other
Jim Blandy <jimb@redhat.com>
parents: 2762
diff changeset
442 make_number (i->position),
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
443 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
444 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
445 sym, Fcar (Fcdr (this)), object);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
446 }
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
447
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
448 Fsetcdr (Fcdr (tail2), Fcdr (Fcdr (this)));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
449 changed++;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
450 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
451 tail2 = this;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
452 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
453 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
454
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
455 if (changed)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
456 i->plist = current_plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
457 return changed;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
458 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
459
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
460 #if 0
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
461 /* Remove all properties from interval I. Return non-zero
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
462 if this changes the interval. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
463
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
464 static INLINE int
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
465 erase_properties (i)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
466 INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
467 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
468 if (NILP (i->plist))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
469 return 0;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
470
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
471 i->plist = Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
472 return 1;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
473 }
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
474 #endif
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
475
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
476 DEFUN ("text-properties-at", Ftext_properties_at,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
477 Stext_properties_at, 1, 2, 0,
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
478 "Return the list of properties held by the character at POSITION\n\
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
479 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
480 defaults to the current buffer.\n\
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
481 If POSITION is at the end of OBJECT, the value is nil.")
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
482 (pos, object)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
483 Lisp_Object pos, object;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
484 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
485 register INTERVAL i;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
486
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
487 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
488 XSETBUFFER (object, current_buffer);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
489
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
490 i = validate_interval_range (object, &pos, &pos, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
491 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
492 return Qnil;
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
493 /* 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
494 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
495 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
496 since no character follows. */
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
497 if (XINT (pos) == LENGTH (i) + i->position)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
498 return Qnil;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
499
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
500 return i->plist;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
501 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
502
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
503 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
504 "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
505 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
506 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
507 (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
508 Lisp_Object pos, object;
8271
e8556db1b7f3 (Fget_text_property): Simplify using Ftext_properties_at.
Richard M. Stallman <rms@gnu.org>
parents: 7773
diff changeset
509 Lisp_Object prop;
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
510 {
8271
e8556db1b7f3 (Fget_text_property): Simplify using Ftext_properties_at.
Richard M. Stallman <rms@gnu.org>
parents: 7773
diff changeset
511 return textget (Ftext_properties_at (pos, object), prop);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
512 }
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
513
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
514 DEFUN ("get-char-property", Fget_char_property, Sget_char_property, 2, 3, 0,
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
515 "Return the value of position POS's property PROP, in OBJECT.\n\
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
516 OBJECT is optional and defaults to the current buffer.\n\
6681
9805eca29f39 (Fget_char_property): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6516
diff changeset
517 If POS is at the end of OBJECT, the value is nil.\n\
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
518 If OBJECT is a buffer, then overlay properties are considered as well as\n\
6064
bdfff039f6e3 (Fget_char_property): Fix docstring.
Karl Heuer <kwzh@gnu.org>
parents: 6063
diff changeset
519 text properties.\n\
bdfff039f6e3 (Fget_char_property): Fix docstring.
Karl Heuer <kwzh@gnu.org>
parents: 6063
diff changeset
520 If OBJECT is a window, then that window's buffer is used, but window-specific\n\
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
521 overlays are considered only if they are associated with OBJECT.")
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
522 (pos, prop, object)
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
523 Lisp_Object pos, object;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
524 register Lisp_Object prop;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
525 {
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
526 struct window *w = 0;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
527
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
528 CHECK_NUMBER_COERCE_MARKER (pos, 0);
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
529
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
530 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
531 XSETBUFFER (object, current_buffer);
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
532
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
533 if (WINDOWP (object))
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
534 {
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
535 w = XWINDOW (object);
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
536 object = w->buffer;
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
537 }
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
538 if (BUFFERP (object))
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
539 {
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
540 int posn = XINT (pos);
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
541 int noverlays;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
542 Lisp_Object *overlay_vec, tem;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
543 int next_overlay;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
544 int len;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
545
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
546 /* First try with room for 40 overlays. */
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
547 len = 40;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
548 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
549
8962
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
550 noverlays = overlays_at (posn, 0, &overlay_vec, &len,
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
551 &next_overlay, NULL);
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
552
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
553 /* If there are more than 40,
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
554 make enough space for all, and try again. */
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
555 if (noverlays > len)
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
556 {
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
557 len = noverlays;
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
558 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
8962
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
559 noverlays = overlays_at (posn, 0, &overlay_vec, &len,
722763fed8ce (Fget_char_property): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents: 8907
diff changeset
560 &next_overlay, NULL);
6063
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
561 }
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
562 noverlays = sort_overlays (overlay_vec, noverlays, w);
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
563
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
564 /* Now check the overlays in order of decreasing priority. */
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
565 while (--noverlays >= 0)
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
566 {
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
567 tem = Foverlay_get (overlay_vec[noverlays], prop);
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
568 if (!NILP (tem))
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
569 return (tem);
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
570 }
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
571 }
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
572 /* Not a buffer, or no appropriate overlay, so fall through to the
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
573 simpler case. */
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
574 return (Fget_text_property (pos, prop, object));
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
575 }
233fffcfb6c8 (Fget_char_property): New function.
Karl Heuer <kwzh@gnu.org>
parents: 5646
diff changeset
576
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
577 DEFUN ("next-property-change", Fnext_property_change,
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
578 Snext_property_change, 1, 3, 0,
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
579 "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
580 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
581 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
582 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
583 Return nil if the property is constant all the way to the end of OBJECT.\n\
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
584 If the value is non-nil, it is a position greater than POS, never equal.\n\n\
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
585 If the optional third argument LIMIT is non-nil, don't search\n\
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
586 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
587 (pos, object, limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
588 Lisp_Object pos, object, limit;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
589 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
590 register INTERVAL i, next;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
591
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
592 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
593 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
594
7092
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
595 if (!NILP (limit))
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
596 CHECK_NUMBER_COERCE_MARKER (limit, 0);
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
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))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
600 return limit;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
601
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
602 next = next_interval (i);
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
603 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
604 && (NILP (limit) || next->position < XFASTINT (limit)))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
605 next = next_interval (next);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
606
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
607 if (NULL_INTERVAL_P (next))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
608 return limit;
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
609 if (! NILP (limit) && !(next->position < XFASTINT (limit)))
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
610 return limit;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
611
9321
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
612 XSETFASTINT (pos, next->position - (STRINGP (object)));
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
613 return pos;
4381
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
614 }
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
615
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
616 /* Return 1 if there's a change in some property between BEG and END. */
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
617
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
618 int
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
619 property_change_between_p (beg, end)
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
620 int beg, end;
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
621 {
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
622 register INTERVAL i, next;
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
623 Lisp_Object object, pos;
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
624
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
625 XSETBUFFER (object, current_buffer);
9321
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
626 XSETFASTINT (pos, beg);
4381
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
627
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
628 i = validate_interval_range (object, &pos, &pos, soft);
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
629 if (NULL_INTERVAL_P (i))
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
630 return 0;
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
631
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
632 next = next_interval (i);
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
633 while (! NULL_INTERVAL_P (next) && intervals_equal (i, next))
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
634 {
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
635 next = next_interval (next);
4614
2c5557903994 (property_change_between_p): Test NULL_INTERVAL_P
Richard M. Stallman <rms@gnu.org>
parents: 4381
diff changeset
636 if (NULL_INTERVAL_P (next))
2c5557903994 (property_change_between_p): Test NULL_INTERVAL_P
Richard M. Stallman <rms@gnu.org>
parents: 4381
diff changeset
637 return 0;
4381
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
638 if (next->position >= end)
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
639 return 0;
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
640 }
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
641
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
642 if (NULL_INTERVAL_P (next))
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
643 return 0;
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
644
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
645 return 1;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
646 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
647
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
648 DEFUN ("next-single-property-change", Fnext_single_property_change,
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
649 Snext_single_property_change, 2, 4, 0,
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
650 "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
651 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
652 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
653 The optional third argument OBJECT is the string or buffer to scan.\n\
5020
94de08fd8a7c (Fnext_single_property_change): Fix missing \n\.
Richard M. Stallman <rms@gnu.org>
parents: 4986
diff changeset
654 The property values are compared with `eq'.\n\
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
655 Return nil if the property is constant all the way to the end of OBJECT.\n\
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
656 If the value is non-nil, it is a position greater than POS, never equal.\n\n\
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
657 If the optional fourth argument LIMIT is non-nil, don't search\n\
5645
214263de8277 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 5644
diff changeset
658 past position LIMIT; return LIMIT if nothing is found before LIMIT.")
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
659 (pos, prop, object, limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
660 Lisp_Object pos, prop, object, limit;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
661 {
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
662 register INTERVAL i, next;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
663 register Lisp_Object here_val;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
664
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
665 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
666 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
667
7092
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
668 if (!NILP (limit))
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
669 CHECK_NUMBER_COERCE_MARKER (limit, 0);
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
670
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
671 i = validate_interval_range (object, &pos, &pos, soft);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
672 if (NULL_INTERVAL_P (i))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
673 return limit;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
674
2762
dd28ed1e1928 * textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents: 2124
diff changeset
675 here_val = textget (i->plist, prop);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
676 next = next_interval (i);
2762
dd28ed1e1928 * textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents: 2124
diff changeset
677 while (! NULL_INTERVAL_P (next)
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
678 && EQ (here_val, textget (next->plist, prop))
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
679 && (NILP (limit) || next->position < XFASTINT (limit)))
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
680 next = next_interval (next);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
681
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
682 if (NULL_INTERVAL_P (next))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
683 return limit;
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
684 if (! NILP (limit) && !(next->position < XFASTINT (limit)))
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
685 return limit;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
686
9321
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
687 XSETFASTINT (pos, next->position - (STRINGP (object)));
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
688 return pos;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
689 }
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
690
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
691 DEFUN ("previous-property-change", Fprevious_property_change,
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
692 Sprevious_property_change, 1, 3, 0,
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
693 "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
694 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
695 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
696 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
697 Return nil if the property is constant all the way to the start of OBJECT.\n\
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
698 If the value is non-nil, it is a position less than POS, never equal.\n\n\
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
699 If the optional third argument LIMIT is non-nil, don't search\n\
5645
214263de8277 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 5644
diff changeset
700 back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
701 (pos, object, limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
702 Lisp_Object pos, object, limit;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
703 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
704 register INTERVAL i, previous;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
705
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
706 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
707 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
708
7092
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
709 if (!NILP (limit))
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
710 CHECK_NUMBER_COERCE_MARKER (limit, 0);
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
711
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
712 i = validate_interval_range (object, &pos, &pos, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
713 if (NULL_INTERVAL_P (i))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
714 return limit;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
715
5644
2abe67658895 (Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents: 5114
diff changeset
716 /* Start with the interval containing the char before point. */
2abe67658895 (Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents: 5114
diff changeset
717 if (i->position == XFASTINT (pos))
2abe67658895 (Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents: 5114
diff changeset
718 i = previous_interval (i);
2abe67658895 (Fprevious_property_change): Move back at least 1 char.
Richard M. Stallman <rms@gnu.org>
parents: 5114
diff changeset
719
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
720 previous = previous_interval (i);
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
721 while (! NULL_INTERVAL_P (previous) && intervals_equal (previous, i)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
722 && (NILP (limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
723 || previous->position + LENGTH (previous) > XFASTINT (limit)))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
724 previous = previous_interval (previous);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
725 if (NULL_INTERVAL_P (previous))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
726 return limit;
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
727 if (!NILP (limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
728 && !(previous->position + LENGTH (previous) > XFASTINT (limit)))
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
729 return limit;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
730
9321
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
731 XSETFASTINT (pos, (previous->position + LENGTH (previous)
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
732 - (STRINGP (object))));
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
733 return pos;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
734 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
735
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
736 DEFUN ("previous-single-property-change", Fprevious_single_property_change,
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
737 Sprevious_single_property_change, 2, 4, 0,
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
738 "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
739 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
740 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
741 The optional third argument OBJECT is the string or buffer to scan.\n\
4986
31b1545319dc (Fprevious_single_property_change): Fix missing \n\.
Richard M. Stallman <rms@gnu.org>
parents: 4797
diff changeset
742 The property values are compared with `eq'.\n\
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
743 Return nil if the property is constant all the way to the start of OBJECT.\n\
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
744 If the value is non-nil, it is a position less than POS, never equal.\n\n\
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
745 If the optional fourth argument LIMIT is non-nil, don't search\n\
5645
214263de8277 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 5644
diff changeset
746 back past position LIMIT; return LIMIT if nothing is found until LIMIT.")
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
747 (pos, prop, object, limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
748 Lisp_Object pos, prop, object, limit;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
749 {
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
750 register INTERVAL i, previous;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
751 register Lisp_Object here_val;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
752
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
753 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
754 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
755
7092
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
756 if (!NILP (limit))
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
757 CHECK_NUMBER_COERCE_MARKER (limit, 0);
b6b93953cc83 (F*_property_change): Typecheck limit argument.
Karl Heuer <kwzh@gnu.org>
parents: 6755
diff changeset
758
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
759 i = validate_interval_range (object, &pos, &pos, soft);
7773
2226c7efb3da (Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents: 7582
diff changeset
760
2226c7efb3da (Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents: 7582
diff changeset
761 /* Start with the interval containing the char before point. */
2226c7efb3da (Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents: 7582
diff changeset
762 if (! NULL_INTERVAL_P (i) && i->position == XFASTINT (pos))
2226c7efb3da (Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents: 7582
diff changeset
763 i = previous_interval (i);
2226c7efb3da (Fprevious_single_property_change): Check for null interval after correcting
Karl Heuer <kwzh@gnu.org>
parents: 7582
diff changeset
764
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
765 if (NULL_INTERVAL_P (i))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
766 return limit;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
767
2762
dd28ed1e1928 * textprop.c (Fnext_single_property_change,
Jim Blandy <jimb@redhat.com>
parents: 2124
diff changeset
768 here_val = textget (i->plist, prop);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
769 previous = previous_interval (i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
770 while (! NULL_INTERVAL_P (previous)
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
771 && EQ (here_val, textget (previous->plist, prop))
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
772 && (NILP (limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
773 || previous->position + LENGTH (previous) > XFASTINT (limit)))
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
774 previous = previous_interval (previous);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
775 if (NULL_INTERVAL_P (previous))
5086
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
776 return limit;
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
777 if (!NILP (limit)
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
778 && !(previous->position + LENGTH (previous) > XFASTINT (limit)))
6e9634463e93 (Ftext_property_not_all): Swap t and nil values in
Richard M. Stallman <rms@gnu.org>
parents: 5020
diff changeset
779 return limit;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
780
9321
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
781 XSETFASTINT (pos, (previous->position + LENGTH (previous)
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
782 - (STRINGP (object))));
8907
f7de8b4cb1b8 (validate_interval_range, property_value, Fget_char_property,
Karl Heuer <kwzh@gnu.org>
parents: 8856
diff changeset
783 return pos;
1211
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
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
786 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
787 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
788 "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
789 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
790 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
791 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
792 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
793 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
794 (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
795 Lisp_Object start, end, properties, object;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
796 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
797 register INTERVAL i, unchanged;
2124
54179ef9ce35 * textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents: 2058
diff changeset
798 register int s, len, modified = 0;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
799
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
800 properties = validate_plist (properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
801 if (NILP (properties))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
802 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
803
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
804 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
805 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
806
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
807 i = validate_interval_range (object, &start, &end, hard);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
808 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
809 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
810
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
811 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
812 len = XINT (end) - s;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
813
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
814 /* If we're not starting on an interval boundary, we have to
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
815 split this interval. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
816 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
817 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
818 /* If this interval already has the properties, we can
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
819 skip it. */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
820 if (interval_has_all_properties (properties, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
821 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
822 int got = (LENGTH (i) - (s - i->position));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
823 if (got >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
824 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
825 len -= got;
3858
e07d474bdba9 (Fremove_text_properties, Fadd_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 3698
diff changeset
826 i = next_interval (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
827 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
828 else
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
829 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
830 unchanged = i;
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
831 i = split_interval_right (unchanged, s - unchanged->position);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
832 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
833 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
834 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
835
3553
5f9688c0b704 (Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents: 2783
diff changeset
836 /* 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
837 for (;;)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
838 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
839 if (i == 0)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
840 abort ();
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
841
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
842 if (LENGTH (i) >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
843 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
844 if (interval_has_all_properties (properties, i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
845 return modified ? Qt : Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
846
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
847 if (LENGTH (i) == len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
848 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
849 add_properties (properties, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
850 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
851 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
852
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
853 /* i doesn't have the properties, and goes past the change limit */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
854 unchanged = i;
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
855 i = split_interval_left (unchanged, len);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
856 copy_properties (unchanged, i);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
857 add_properties (properties, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
858 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
859 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
860
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
861 len -= LENGTH (i);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
862 modified += add_properties (properties, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
863 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
864 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
865 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
866
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
867 DEFUN ("put-text-property", Fput_text_property,
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
868 Sput_text_property, 4, 5, 0,
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
869 "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
870 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
871 specify the property to add.\n\
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
872 The optional fifth argument, OBJECT,\n\
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
873 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
874 (start, end, prop, value, object)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
875 Lisp_Object start, end, prop, value, object;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
876 {
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
877 Fadd_text_properties (start, end,
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
878 Fcons (prop, Fcons (value, Qnil)),
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
879 object);
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
880 return Qnil;
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
881 }
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
882
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
883 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
884 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
885 "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
886 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
887 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
888 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
889 (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
890 Lisp_Object start, end, props, object;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
891 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
892 register INTERVAL i, unchanged;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
893 register INTERVAL prev_changed = NULL_INTERVAL;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
894 register int s, len;
9071
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
895 Lisp_Object ostart, oend;
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
896
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
897 ostart = start;
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
898 oend = end;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
899
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
900 props = validate_plist (props);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
901
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
902 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
903 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
904
8686
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
905 i = validate_interval_range (object, &start, &end, soft);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
906 if (NULL_INTERVAL_P (i))
8686
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
907 {
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
908 /* If buffer has no props, and we want none, return now. */
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
909 if (NILP (props))
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
910 return Qnil;
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
911
9071
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
912 /* Restore the original START and END values
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
913 because validate_interval_range increments them for strings. */
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
914 start = ostart;
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
915 end = oend;
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
916
8686
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
917 i = validate_interval_range (object, &start, &end, hard);
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
918 /* This can return if start == end. */
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
919 if (NULL_INTERVAL_P (i))
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
920 return Qnil;
c468db944aa2 (Fset_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 8271
diff changeset
921 }
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
922
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
923 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
924 len = XINT (end) - s;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
925
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
926 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
927 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
928 unchanged = i;
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
929 i = split_interval_right (unchanged, s - unchanged->position);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
930
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
931 if (LENGTH (i) > len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
932 {
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
933 copy_properties (unchanged, i);
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
934 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
935 set_properties (props, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
936 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
937 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
938
3553
5f9688c0b704 (Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents: 2783
diff changeset
939 set_properties (props, i, object);
5f9688c0b704 (Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents: 2783
diff changeset
940
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
941 if (LENGTH (i) == len)
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
942 return Qt;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
943
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
944 prev_changed = i;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
945 len -= LENGTH (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
946 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
947 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
948
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
949 /* 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
950 while (len > 0)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
951 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
952 if (i == 0)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
953 abort ();
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
954
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
955 if (LENGTH (i) >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
956 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
957 if (LENGTH (i) > len)
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
958 i = split_interval_left (i, len);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
959
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
960 if (NULL_INTERVAL_P (prev_changed))
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
961 set_properties (props, i, object);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
962 else
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
963 merge_interval_left (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
964 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
965 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
966
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
967 len -= LENGTH (i);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
968 if (NULL_INTERVAL_P (prev_changed))
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
969 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
970 set_properties (props, i, object);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
971 prev_changed = i;
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
972 }
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
973 else
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
974 prev_changed = i = merge_interval_left (i);
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
975
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
976 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
977 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
978
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
979 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
980 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
981
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
982 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
983 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
984 "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
985 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
986 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
987 \(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
988 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
989 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
990 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
991 (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
992 Lisp_Object start, end, props, object;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
993 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
994 register INTERVAL i, unchanged;
2124
54179ef9ce35 * textprop.c (Fadd_text_properties): Initialize the modified flag.
Jim Blandy <jimb@redhat.com>
parents: 2058
diff changeset
995 register int s, len, modified = 0;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
996
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
997 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
998 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
999
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1000 i = validate_interval_range (object, &start, &end, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1001 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1002 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1003
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1004 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1005 len = XINT (end) - s;
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
1006
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1007 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1008 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1009 /* No properties on this first interval -- return if
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1010 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
1011 if (! interval_has_some_properties (props, i))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1012 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1013 int got = (LENGTH (i) - (s - i->position));
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1014 if (got >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1015 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1016 len -= got;
3858
e07d474bdba9 (Fremove_text_properties, Fadd_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 3698
diff changeset
1017 i = next_interval (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1018 }
3553
5f9688c0b704 (Fadd_text_properties): Don't treat the initial
Richard M. Stallman <rms@gnu.org>
parents: 2783
diff changeset
1019 /* 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
1020 want to modify. */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1021 else
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1022 {
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1023 unchanged = i;
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1024 i = split_interval_right (unchanged, s - unchanged->position);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1025 copy_properties (unchanged, i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1026 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1027 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1028
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1029 /* 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
1030 for (;;)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1031 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1032 if (i == 0)
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1033 abort ();
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1034
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1035 if (LENGTH (i) >= len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1036 {
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
1037 if (! interval_has_some_properties (props, i))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1038 return modified ? Qt : Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1039
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1040 if (LENGTH (i) == len)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1041 {
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1042 remove_properties (props, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1043 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1044 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1045
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1046 /* 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
1047 unchanged = i;
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1048 i = split_interval_left (i, len);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1049 copy_properties (unchanged, i);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1050 remove_properties (props, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1051 return Qt;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1052 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1053
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1054 len -= LENGTH (i);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1055 modified += remove_properties (props, i, object);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1056 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1057 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1058 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1059
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1060 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
1061 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
1062 "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
1063 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
1064 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
1065 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
1066 containing the text.")
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1067 (start, end, prop, value, object)
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1068 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
1069 {
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1070 register INTERVAL i;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1071 register int e, pos;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1072
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1073 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
1074 XSETBUFFER (object, current_buffer);
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1075 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
1076 e = XINT (end);
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1077
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1078 while (! NULL_INTERVAL_P (i))
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1079 {
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1080 if (i->position >= e)
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1081 break;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1082 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
1083 {
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1084 pos = i->position;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1085 if (pos < XINT (start))
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1086 pos = XINT (start);
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
1087 return make_number (pos - (STRINGP (object)));
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1088 }
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1089 i = next_interval (i);
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1090 }
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1091 return Qnil;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1092 }
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1093
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1094 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
1095 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
1096 "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
1097 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
1098 `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
1099 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
1100 containing the text.")
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1101 (start, end, prop, value, object)
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1102 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
1103 {
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1104 register INTERVAL i;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1105 register int s, e;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1106
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1107 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
1108 XSETBUFFER (object, current_buffer);
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1109 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
1110 if (NULL_INTERVAL_P (i))
5114
b37f62d72049 (Ftext_property_not_all): For trivial yes, return start, not Qt.
Richard M. Stallman <rms@gnu.org>
parents: 5086
diff changeset
1111 return (NILP (value) || EQ (start, end)) ? Qnil : start;
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1112 s = XINT (start);
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1113 e = XINT (end);
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1114
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1115 while (! NULL_INTERVAL_P (i))
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1116 {
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1117 if (i->position >= e)
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1118 break;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1119 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
1120 {
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1121 if (i->position > s)
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1122 s = i->position;
9109
6e44ddc40153 (validate_interval_range, add_properties, remove_properties,
Karl Heuer <kwzh@gnu.org>
parents: 9071
diff changeset
1123 return make_number (s - (STRINGP (object)));
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1124 }
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1125 i = next_interval (i);
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1126 }
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1127 return Qnil;
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1128 }
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1129
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
1130 #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
1131
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1132 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
1133 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
1134 "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
1135 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
1136 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
1137 (start, end, object)
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
1138 Lisp_Object start, end, object;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1139 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1140 register INTERVAL i;
1305
5c19f71f0314 Fixed typeos.
Joseph Arceneaux <jla@gnu.org>
parents: 1302
diff changeset
1141 register INTERVAL prev_changed = NULL_INTERVAL;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1142 register int s, len, modified;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1143
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
1144 if (NILP (object))
9280
4b238c43e59f (Ftext_properties_at, Fget_char_property, Fnext_property_change,
Karl Heuer <kwzh@gnu.org>
parents: 9109
diff changeset
1145 XSETBUFFER (object, current_buffer);
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
1146
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1147 i = validate_interval_range (object, &start, &end, soft);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1148 if (NULL_INTERVAL_P (i))
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1149 return Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1150
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1151 s = XINT (start);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1152 len = XINT (end) - s;
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1153
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1154 if (i->position != s)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1155 {
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1156 register int got;
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1157 register INTERVAL unchanged = i;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1158
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1159 /* 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
1160 if (! NILP (i->plist))
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1161 {
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1162 i = split_interval_right (unchanged, s - unchanged->position);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1163 i->plist = Qnil;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1164 modified++;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1165
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1166 if (LENGTH (i) > len)
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1167 {
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1168 i = split_interval_right (i, len);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1169 copy_properties (unchanged, i);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1170 return Qt;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1171 }
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1172
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1173 if (LENGTH (i) == len)
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1174 return Qt;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1175
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1176 got = LENGTH (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1177 }
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1178 /* 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
1179 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
1180 anything.*/
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1181 else if (LENGTH (i) - (s - i->position) <= len)
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1182 return Qnil;
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1183 /* 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
1184 how much we've gotten. */
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1185 else
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1186 got = LENGTH (i) - (s - i->position);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1187
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1188 len -= got;
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1189 prev_changed = i;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1190 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1191 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1192
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1193 /* We are starting at the beginning of an interval, I. */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1194 while (len > 0)
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1195 {
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1196 if (LENGTH (i) >= len)
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1197 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1198 /* 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
1199 if (NILP (i->plist))
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1200 {
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1201 if (! NULL_INTERVAL_P (prev_changed))
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1202 merge_interval_left (i);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1203
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1204 return modified ? Qt : Qnil;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1205 }
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1206
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1207 if (LENGTH (i) > len)
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1208 i = split_interval_left (i, len);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1209 if (! NULL_INTERVAL_P (prev_changed))
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1210 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
1211 else
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1212 i->plist = Qnil;
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1213
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1214 return Qt;
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1215 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1216
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1217 /* Here if we still need to erase past the end of I */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1218 len -= LENGTH (i);
1272
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1219 if (NULL_INTERVAL_P (prev_changed))
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1220 {
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1221 modified += erase_properties (i);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1222 prev_changed = i;
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1223 }
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1224 else
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1225 {
1283
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1226 modified += ! NILP (i->plist);
6f4cbcc62eba Minor optimizations of Fset_text_properties and Ferase_text_properties.
Joseph Arceneaux <jla@gnu.org>
parents: 1272
diff changeset
1227 /* 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
1228 prev_changed = i = merge_interval_left (i);
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1229 }
bfd04f61eb16 Mods to Ferase_text_properties
Joseph Arceneaux <jla@gnu.org>
parents: 1211
diff changeset
1230
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1231 i = next_interval (i);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1232 }
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1233
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1234 return modified ? Qt : Qnil;
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1235 }
1857
9d65dfc7bdb7 (Fadd_text_properties): Put OBJECT arg last. Make it optional.
Richard M. Stallman <rms@gnu.org>
parents: 1715
diff changeset
1236 #endif /* 0 */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1237
4007
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1238 /* 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
1239 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
1240 around?
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1241
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1242 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
1243 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
1244 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
1245
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1246 /* 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
1247 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
1248 "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
1249 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
1250 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
1251 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
1252 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
1253
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1254 Lisp_Object
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1255 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
1256 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
1257 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1258 INTERVAL i;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1259 Lisp_Object res;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1260 Lisp_Object stuff;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1261 Lisp_Object plist;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1262 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
1263
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1264 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
1265 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
1266 return Qnil;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1267
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1268 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
1269 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1270 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
1271
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1272 dest_start = pos;
9321
e6759002383c (Fnext_property_change, property_change_between_p,
Karl Heuer <kwzh@gnu.org>
parents: 9280
diff changeset
1273 XSETFASTINT (dest_end, XINT (dest_start) + (XINT (end) - XINT (start)));
4007
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1274 /* 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
1275 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
1276 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
1277 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1278
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1279 s = XINT (start);
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1280 e = XINT (end);
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1281 p = XINT (pos);
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1282
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1283 stuff = Qnil;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1284
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1285 while (s < e)
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1286 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1287 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
1288 if (e2 > e)
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1289 e2 = e;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1290 len = e2 - s;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1291
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1292 plist = i->plist;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1293 if (! NILP (prop))
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1294 while (! NILP (plist))
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1295 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1296 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
1297 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1298 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
1299 break;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1300 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1301 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
1302 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1303 if (! NILP (plist))
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1304 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1305 /* 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
1306 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
1307 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
1308 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
1309 Fcons (plist, Qnil))),
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1310 stuff);
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1311 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1312
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1313 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
1314 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
1315 break;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1316
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1317 p += len;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1318 s = i->position;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1319 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1320
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1321 while (! NILP (stuff))
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1322 {
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1323 res = Fcar (stuff);
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1324 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
1325 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
1326 if (! NILP (res))
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1327 modified++;
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1328 stuff = Fcdr (stuff);
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1329 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1330
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1331 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
1332 }
55da23f04d01 * textprop.c (copy_text_properties): Pass a copy of POS to
Jim Blandy <jimb@redhat.com>
parents: 3998
diff changeset
1333
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1334 void
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1335 syms_of_textprop ()
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1336 {
4242
49007dbbec4c (syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents: 4214
diff changeset
1337 DEFVAR_LISP ("inhibit-point-motion-hooks", &Vinhibit_point_motion_hooks,
9071
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
1338 "If non-nil, don't run `point-left' and `point-entered' text properties.\n\
2d4d0f6e7be0 (syms_of_textprop): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8962
diff changeset
1339 This also inhibits the use of the `intangible' text property.");
4242
49007dbbec4c (syms_of_textprop): Set up Lisp var Vinhibit_point_motion_hooks.
Richard M. Stallman <rms@gnu.org>
parents: 4214
diff changeset
1340 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
1341
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1342 /* Common attributes one might give text */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1343
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1344 staticpro (&Qforeground);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1345 Qforeground = intern ("foreground");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1346 staticpro (&Qbackground);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1347 Qbackground = intern ("background");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1348 staticpro (&Qfont);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1349 Qfont = intern ("font");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1350 staticpro (&Qstipple);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1351 Qstipple = intern ("stipple");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1352 staticpro (&Qunderline);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1353 Qunderline = intern ("underline");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1354 staticpro (&Qread_only);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1355 Qread_only = intern ("read-only");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1356 staticpro (&Qinvisible);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1357 Qinvisible = intern ("invisible");
6755
a2bccbc870e6 (syms_of_textprop): Initialize Qintangible.
Karl Heuer <kwzh@gnu.org>
parents: 6681
diff changeset
1358 staticpro (&Qintangible);
a2bccbc870e6 (syms_of_textprop): Initialize Qintangible.
Karl Heuer <kwzh@gnu.org>
parents: 6681
diff changeset
1359 Qintangible = intern ("intangible");
2058
a43d0bb1b7d8 (Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents: 2053
diff changeset
1360 staticpro (&Qcategory);
a43d0bb1b7d8 (Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents: 2053
diff changeset
1361 Qcategory = intern ("category");
a43d0bb1b7d8 (Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents: 2053
diff changeset
1362 staticpro (&Qlocal_map);
a43d0bb1b7d8 (Fget_text_property): Use textget.
Richard M. Stallman <rms@gnu.org>
parents: 2053
diff changeset
1363 Qlocal_map = intern ("local-map");
4381
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
1364 staticpro (&Qfront_sticky);
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
1365 Qfront_sticky = intern ("front-sticky");
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
1366 staticpro (&Qrear_nonsticky);
b0556af4d680 (Qfront_sticky, Qrear_nonsticky): New variables.
Richard M. Stallman <rms@gnu.org>
parents: 4242
diff changeset
1367 Qrear_nonsticky = intern ("rear-nonsticky");
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1368
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1369 /* Properties that text might use to specify certain actions */
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1370
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1371 staticpro (&Qmouse_left);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1372 Qmouse_left = intern ("mouse-left");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1373 staticpro (&Qmouse_entered);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1374 Qmouse_entered = intern ("mouse-entered");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1375 staticpro (&Qpoint_left);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1376 Qpoint_left = intern ("point-left");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1377 staticpro (&Qpoint_entered);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1378 Qpoint_entered = intern ("point-entered");
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1379
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1380 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
1381 defsubr (&Sget_text_property);
7582
454c279b6d18 (syms_of_textprop): Set up Lisp fn get-char-property.
Richard M. Stallman <rms@gnu.org>
parents: 7307
diff changeset
1382 defsubr (&Sget_char_property);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1383 defsubr (&Snext_property_change);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
1384 defsubr (&Snext_single_property_change);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1385 defsubr (&Sprevious_property_change);
1211
9f50cccf5963 See ChangeLog
Joseph Arceneaux <jla@gnu.org>
parents: 1055
diff changeset
1386 defsubr (&Sprevious_single_property_change);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1387 defsubr (&Sadd_text_properties);
1965
2bdbd6ed2430 (Fadd_text_properties, Fremove_text_properties):
Richard M. Stallman <rms@gnu.org>
parents: 1930
diff changeset
1388 defsubr (&Sput_text_property);
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1389 defsubr (&Sset_text_properties);
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1390 defsubr (&Sremove_text_properties);
4144
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1391 defsubr (&Stext_property_any);
8f5545cf9774 * intervals.c (split_interval_left, split_interval_right): Change
Jim Blandy <jimb@redhat.com>
parents: 4076
diff changeset
1392 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
1393 /* 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
1394 /* defsubr (&Scopy_text_properties); */
1029
425f62908a54 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1395 }
1302
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
1396
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
1397 #else
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
1398
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
1399 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
1400
538cc0cd6d83 * textprop.c: Conditionalize all functions on
Joseph Arceneaux <jla@gnu.org>
parents: 1283
diff changeset
1401 #endif /* USE_TEXT_PROPERTIES */