aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorStefan Monnier2003-07-08 22:09:23 +0000
committerStefan Monnier2003-07-08 22:09:23 +0000
commita615c6dcea08f51f0e159213a5cb5b77a78dbf62 (patch)
tree92e7c3a689a3c3855ae12dd7020e951161dfab90 /src/buffer.c
parent49f601d9604dd4421401d783cfdb096e72803e9e (diff)
downloademacs-a615c6dcea08f51f0e159213a5cb5b77a78dbf62.tar.gz
emacs-a615c6dcea08f51f0e159213a5cb5b77a78dbf62.zip
(report_overlay_modification): Don't run hooks while
traversing the list of overlays.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c212
1 files changed, 87 insertions, 125 deletions
diff --git a/src/buffer.c b/src/buffer.c
index ba441387e17..aeb64e90d88 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4056,153 +4056,117 @@ report_overlay_modification (start, end, after, arg1, arg2, arg3)
4056 Lisp_Object prop, overlay, tail; 4056 Lisp_Object prop, overlay, tail;
4057 /* 1 if this change is an insertion. */ 4057 /* 1 if this change is an insertion. */
4058 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); 4058 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
4059 int tail_copied; 4059 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4060 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
4061 4060
4062 overlay = Qnil; 4061 overlay = Qnil;
4063 tail = Qnil; 4062 tail = Qnil;
4064 GCPRO5 (overlay, tail, arg1, arg2, arg3);
4065
4066 if (after)
4067 {
4068 /* Call the functions recorded in last_overlay_modification_hooks
4069 rather than scanning the overlays again.
4070 First copy the vector contents, in case some of these hooks
4071 do subsequent modification of the buffer. */
4072 int size = last_overlay_modification_hooks_used;
4073 Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object));
4074 int i;
4075
4076 bcopy (XVECTOR (last_overlay_modification_hooks)->contents,
4077 copy, size * sizeof (Lisp_Object));
4078 gcpro1.var = copy;
4079 gcpro1.nvars = size;
4080
4081 for (i = 0; i < size;)
4082 {
4083 Lisp_Object prop, overlay;
4084 prop = copy[i++];
4085 overlay = copy[i++];
4086 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4087 }
4088 UNGCPRO;
4089 return;
4090 }
4091 4063
4092 /* We are being called before a change. 4064 if (!after)
4093 Scan the overlays to find the functions to call. */
4094 last_overlay_modification_hooks_used = 0;
4095 tail_copied = 0;
4096 for (tail = current_buffer->overlays_before;
4097 CONSP (tail);
4098 tail = XCDR (tail))
4099 { 4065 {
4100 int startpos, endpos; 4066 /* We are being called before a change.
4101 Lisp_Object ostart, oend; 4067 Scan the overlays to find the functions to call. */
4102 4068 last_overlay_modification_hooks_used = 0;
4103 overlay = XCAR (tail); 4069 for (tail = current_buffer->overlays_before;
4104 4070 CONSP (tail);
4105 ostart = OVERLAY_START (overlay); 4071 tail = XCDR (tail))
4106 oend = OVERLAY_END (overlay);
4107 endpos = OVERLAY_POSITION (oend);
4108 if (XFASTINT (start) > endpos)
4109 break;
4110 startpos = OVERLAY_POSITION (ostart);
4111 if (insertion && (XFASTINT (start) == startpos
4112 || XFASTINT (end) == startpos))
4113 { 4072 {
4114 prop = Foverlay_get (overlay, Qinsert_in_front_hooks); 4073 int startpos, endpos;
4115 if (!NILP (prop)) 4074 Lisp_Object ostart, oend;
4075
4076 overlay = XCAR (tail);
4077
4078 ostart = OVERLAY_START (overlay);
4079 oend = OVERLAY_END (overlay);
4080 endpos = OVERLAY_POSITION (oend);
4081 if (XFASTINT (start) > endpos)
4082 break;
4083 startpos = OVERLAY_POSITION (ostart);
4084 if (insertion && (XFASTINT (start) == startpos
4085 || XFASTINT (end) == startpos))
4116 { 4086 {
4117 /* Copy TAIL in case the hook recenters the overlay lists. */ 4087 prop = Foverlay_get (overlay, Qinsert_in_front_hooks);
4118 if (!tail_copied) 4088 if (!NILP (prop))
4119 tail = Fcopy_sequence (tail); 4089 add_overlay_mod_hooklist (prop, overlay);
4120 tail_copied = 1;
4121 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4122 } 4090 }
4123 } 4091 if (insertion && (XFASTINT (start) == endpos
4124 if (insertion && (XFASTINT (start) == endpos 4092 || XFASTINT (end) == endpos))
4125 || XFASTINT (end) == endpos))
4126 {
4127 prop = Foverlay_get (overlay, Qinsert_behind_hooks);
4128 if (!NILP (prop))
4129 { 4093 {
4130 if (!tail_copied) 4094 prop = Foverlay_get (overlay, Qinsert_behind_hooks);
4131 tail = Fcopy_sequence (tail); 4095 if (!NILP (prop))
4132 tail_copied = 1; 4096 add_overlay_mod_hooklist (prop, overlay);
4133 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4134 } 4097 }
4135 } 4098 /* Test for intersecting intervals. This does the right thing
4136 /* Test for intersecting intervals. This does the right thing 4099 for both insertion and deletion. */
4137 for both insertion and deletion. */ 4100 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)
4138 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)
4139 {
4140 prop = Foverlay_get (overlay, Qmodification_hooks);
4141 if (!NILP (prop))
4142 { 4101 {
4143 if (!tail_copied) 4102 prop = Foverlay_get (overlay, Qmodification_hooks);
4144 tail = Fcopy_sequence (tail); 4103 if (!NILP (prop))
4145 tail_copied = 1; 4104 add_overlay_mod_hooklist (prop, overlay);
4146 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4147 } 4105 }
4148 } 4106 }
4149 }
4150
4151 tail_copied = 0;
4152 for (tail = current_buffer->overlays_after;
4153 CONSP (tail);
4154 tail = XCDR (tail))
4155 {
4156 int startpos, endpos;
4157 Lisp_Object ostart, oend;
4158 4107
4159 overlay = XCAR (tail); 4108 for (tail = current_buffer->overlays_after;
4160 4109 CONSP (tail);
4161 ostart = OVERLAY_START (overlay); 4110 tail = XCDR (tail))
4162 oend = OVERLAY_END (overlay);
4163 startpos = OVERLAY_POSITION (ostart);
4164 endpos = OVERLAY_POSITION (oend);
4165 if (XFASTINT (end) < startpos)
4166 break;
4167 if (insertion && (XFASTINT (start) == startpos
4168 || XFASTINT (end) == startpos))
4169 { 4111 {
4170 prop = Foverlay_get (overlay, Qinsert_in_front_hooks); 4112 int startpos, endpos;
4171 if (!NILP (prop)) 4113 Lisp_Object ostart, oend;
4114
4115 overlay = XCAR (tail);
4116
4117 ostart = OVERLAY_START (overlay);
4118 oend = OVERLAY_END (overlay);
4119 startpos = OVERLAY_POSITION (ostart);
4120 endpos = OVERLAY_POSITION (oend);
4121 if (XFASTINT (end) < startpos)
4122 break;
4123 if (insertion && (XFASTINT (start) == startpos
4124 || XFASTINT (end) == startpos))
4172 { 4125 {
4173 if (!tail_copied) 4126 prop = Foverlay_get (overlay, Qinsert_in_front_hooks);
4174 tail = Fcopy_sequence (tail); 4127 if (!NILP (prop))
4175 tail_copied = 1; 4128 add_overlay_mod_hooklist (prop, overlay);
4176 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4177 } 4129 }
4178 } 4130 if (insertion && (XFASTINT (start) == endpos
4179 if (insertion && (XFASTINT (start) == endpos 4131 || XFASTINT (end) == endpos))
4180 || XFASTINT (end) == endpos))
4181 {
4182 prop = Foverlay_get (overlay, Qinsert_behind_hooks);
4183 if (!NILP (prop))
4184 { 4132 {
4185 if (!tail_copied) 4133 prop = Foverlay_get (overlay, Qinsert_behind_hooks);
4186 tail = Fcopy_sequence (tail); 4134 if (!NILP (prop))
4187 tail_copied = 1; 4135 add_overlay_mod_hooklist (prop, overlay);
4188 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4189 } 4136 }
4190 } 4137 /* Test for intersecting intervals. This does the right thing
4191 /* Test for intersecting intervals. This does the right thing 4138 for both insertion and deletion. */
4192 for both insertion and deletion. */ 4139 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)
4193 if (XFASTINT (end) > startpos && XFASTINT (start) < endpos)
4194 {
4195 prop = Foverlay_get (overlay, Qmodification_hooks);
4196 if (!NILP (prop))
4197 { 4140 {
4198 if (!tail_copied) 4141 prop = Foverlay_get (overlay, Qmodification_hooks);
4199 tail = Fcopy_sequence (tail); 4142 if (!NILP (prop))
4200 tail_copied = 1; 4143 add_overlay_mod_hooklist (prop, overlay);
4201 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4202 } 4144 }
4203 } 4145 }
4204 } 4146 }
4205 4147
4148 GCPRO4 (overlay, arg1, arg2, arg3);
4149 {
4150 /* Call the functions recorded in last_overlay_modification_hooks.
4151 First copy the vector contents, in case some of these hooks
4152 do subsequent modification of the buffer. */
4153 int size = last_overlay_modification_hooks_used;
4154 Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object));
4155 int i;
4156
4157 bcopy (XVECTOR (last_overlay_modification_hooks)->contents,
4158 copy, size * sizeof (Lisp_Object));
4159 gcpro1.var = copy;
4160 gcpro1.nvars = size;
4161
4162 for (i = 0; i < size;)
4163 {
4164 Lisp_Object prop, overlay;
4165 prop = copy[i++];
4166 overlay = copy[i++];
4167 call_overlay_mod_hooks (prop, overlay, after, arg1, arg2, arg3);
4168 }
4169 }
4206 UNGCPRO; 4170 UNGCPRO;
4207} 4171}
4208 4172
@@ -4215,8 +4179,6 @@ call_overlay_mod_hooks (list, overlay, after, arg1, arg2, arg3)
4215 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4179 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4216 4180
4217 GCPRO4 (list, arg1, arg2, arg3); 4181 GCPRO4 (list, arg1, arg2, arg3);
4218 if (! after)
4219 add_overlay_mod_hooklist (list, overlay);
4220 4182
4221 while (CONSP (list)) 4183 while (CONSP (list))
4222 { 4184 {