diff options
| author | Jimmy Aguilar Mena | 2019-10-13 16:56:50 +0200 |
|---|---|---|
| committer | Jimmy Aguilar Mena | 2019-10-14 14:18:42 +0200 |
| commit | 501846c85932f1c11405f0a1748b884074a76004 (patch) | |
| tree | 6744cd3205a394ee957b06a2db973096b8730a23 /src | |
| parent | cc47cd4202aa474cf83d6fc42d959460d3cf823f (diff) | |
| download | emacs-501846c85932f1c11405f0a1748b884074a76004.tar.gz emacs-501846c85932f1c11405f0a1748b884074a76004.zip | |
Modify face_at_pos to not modify change IT.
src/xdisp.c (face_at_pos): Removed code to that modified
it->start_of_box_run_p and it->face_box_p. This function should not
modify it.
(handle_face_prop): Added code to update it->start_of_box_run_p and
it->face_box_p.
(underlying_face_id): Input IT made CONST.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 86 |
1 files changed, 42 insertions, 44 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 6c0b1f88488..d54b717a507 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -993,7 +993,7 @@ static int handle_display_spec (struct it *, Lisp_Object, Lisp_Object, | |||
| 993 | static int handle_single_display_spec (struct it *, Lisp_Object, Lisp_Object, | 993 | static int handle_single_display_spec (struct it *, Lisp_Object, Lisp_Object, |
| 994 | Lisp_Object, struct text_pos *, | 994 | Lisp_Object, struct text_pos *, |
| 995 | ptrdiff_t, int, bool, bool); | 995 | ptrdiff_t, int, bool, bool); |
| 996 | static int underlying_face_id (struct it *); | 996 | static int underlying_face_id (const struct it *); |
| 997 | 997 | ||
| 998 | #define face_before_it_pos(IT) face_before_or_after_it_pos (IT, true) | 998 | #define face_before_it_pos(IT) face_before_or_after_it_pos (IT, true) |
| 999 | #define face_after_it_pos(IT) face_before_or_after_it_pos (IT, false) | 999 | #define face_after_it_pos(IT) face_before_or_after_it_pos (IT, false) |
| @@ -4158,23 +4158,20 @@ handle_fontified_prop (struct it *it) | |||
| 4158 | ***********************************************************************/ | 4158 | ***********************************************************************/ |
| 4159 | 4159 | ||
| 4160 | static int | 4160 | static int |
| 4161 | face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | 4161 | face_at_pos (const struct it *it, enum lface_attribute_index attr_filter) |
| 4162 | { | 4162 | { |
| 4163 | int new_face_id; | ||
| 4164 | ptrdiff_t next_stop; | 4163 | ptrdiff_t next_stop; |
| 4165 | const bool is_string = STRINGP (it->string); | 4164 | |
| 4166 | 4165 | if (!STRINGP (it->string)) | |
| 4167 | if (!is_string) | 4166 | { |
| 4168 | { | 4167 | return face_at_buffer_position (it->w, |
| 4169 | new_face_id | 4168 | IT_CHARPOS (*it), |
| 4170 | = face_at_buffer_position (it->w, | 4169 | &next_stop, |
| 4171 | IT_CHARPOS (*it), | 4170 | (IT_CHARPOS (*it) |
| 4172 | &next_stop, | 4171 | + TEXT_PROP_DISTANCE_LIMIT), |
| 4173 | (IT_CHARPOS (*it) | 4172 | false, it->base_face_id, |
| 4174 | + TEXT_PROP_DISTANCE_LIMIT), | 4173 | attr_filter); |
| 4175 | false, it->base_face_id, | 4174 | } |
| 4176 | attr_filter); | ||
| 4177 | } | ||
| 4178 | else | 4175 | else |
| 4179 | { | 4176 | { |
| 4180 | int base_face_id; | 4177 | int base_face_id; |
| @@ -4183,7 +4180,7 @@ face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | |||
| 4183 | Lisp_Object from_overlay | 4180 | Lisp_Object from_overlay |
| 4184 | = (it->current.overlay_string_index >= 0 | 4181 | = (it->current.overlay_string_index >= 0 |
| 4185 | ? it->string_overlays[it->current.overlay_string_index | 4182 | ? it->string_overlays[it->current.overlay_string_index |
| 4186 | % OVERLAY_STRING_CHUNK_SIZE] | 4183 | % OVERLAY_STRING_CHUNK_SIZE] |
| 4187 | : Qnil); | 4184 | : Qnil); |
| 4188 | 4185 | ||
| 4189 | /* See if we got to this string directly or indirectly from | 4186 | /* See if we got to this string directly or indirectly from |
| @@ -4198,7 +4195,7 @@ face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | |||
| 4198 | if (it->stack[i].current.overlay_string_index >= 0) | 4195 | if (it->stack[i].current.overlay_string_index >= 0) |
| 4199 | from_overlay | 4196 | from_overlay |
| 4200 | = it->string_overlays[it->stack[i].current.overlay_string_index | 4197 | = it->string_overlays[it->stack[i].current.overlay_string_index |
| 4201 | % OVERLAY_STRING_CHUNK_SIZE]; | 4198 | % OVERLAY_STRING_CHUNK_SIZE]; |
| 4202 | else if (! NILP (it->stack[i].from_overlay)) | 4199 | else if (! NILP (it->stack[i].from_overlay)) |
| 4203 | from_overlay = it->stack[i].from_overlay; | 4200 | from_overlay = it->stack[i].from_overlay; |
| 4204 | 4201 | ||
| @@ -4213,11 +4210,11 @@ face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | |||
| 4213 | only on text properties and ignores overlays. */ | 4210 | only on text properties and ignores overlays. */ |
| 4214 | base_face_id | 4211 | base_face_id |
| 4215 | = face_for_overlay_string (it->w, | 4212 | = face_for_overlay_string (it->w, |
| 4216 | IT_CHARPOS (*it), | 4213 | IT_CHARPOS (*it), |
| 4217 | &next_stop, | 4214 | &next_stop, |
| 4218 | (IT_CHARPOS (*it) | 4215 | (IT_CHARPOS (*it) |
| 4219 | + TEXT_PROP_DISTANCE_LIMIT), | 4216 | + TEXT_PROP_DISTANCE_LIMIT), |
| 4220 | false, | 4217 | false, |
| 4221 | from_overlay); | 4218 | from_overlay); |
| 4222 | } | 4219 | } |
| 4223 | else | 4220 | else |
| @@ -4247,14 +4244,24 @@ face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | |||
| 4247 | : underlying_face_id (it); | 4244 | : underlying_face_id (it); |
| 4248 | } | 4245 | } |
| 4249 | 4246 | ||
| 4250 | new_face_id = face_at_string_position (it->w, | 4247 | return face_at_string_position (it->w, |
| 4251 | it->string, | 4248 | it->string, |
| 4252 | IT_STRING_CHARPOS (*it), | 4249 | IT_STRING_CHARPOS (*it), |
| 4253 | bufpos, | 4250 | bufpos, |
| 4254 | &next_stop, | 4251 | &next_stop, |
| 4255 | base_face_id, false, | 4252 | base_face_id, false, |
| 4256 | attr_filter); | 4253 | attr_filter); |
| 4257 | } /* !is_string. */ | 4254 | } // !STRINGP (it->string)) |
| 4255 | } | ||
| 4256 | |||
| 4257 | |||
| 4258 | /* Set up iterator IT from face properties at its current position. | ||
| 4259 | Called from handle_stop. */ | ||
| 4260 | static enum prop_handled | ||
| 4261 | handle_face_prop (struct it *it) | ||
| 4262 | { | ||
| 4263 | const int new_face_id = face_at_pos (it, 0); | ||
| 4264 | |||
| 4258 | 4265 | ||
| 4259 | /* Is this a start of a run of characters with box face? | 4266 | /* Is this a start of a run of characters with box face? |
| 4260 | Caveat: this can be called for a freshly initialized | 4267 | Caveat: this can be called for a freshly initialized |
| @@ -4273,11 +4280,11 @@ face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | |||
| 4273 | /* If the value of face_id of the iterator is -1, we have to | 4280 | /* If the value of face_id of the iterator is -1, we have to |
| 4274 | look in front of IT's position and see whether there is a | 4281 | look in front of IT's position and see whether there is a |
| 4275 | face there that's different from new_face_id. */ | 4282 | face there that's different from new_face_id. */ |
| 4276 | if (!is_string | 4283 | if (!STRINGP (it->string) |
| 4277 | && !old_face | 4284 | && !old_face |
| 4278 | && IT_CHARPOS (*it) > BEG) | 4285 | && IT_CHARPOS (*it) > BEG) |
| 4279 | { | 4286 | { |
| 4280 | int prev_face_id = face_before_it_pos (it); | 4287 | const int prev_face_id = face_before_it_pos (it); |
| 4281 | 4288 | ||
| 4282 | old_face = FACE_FROM_ID_OR_NULL (it->f, prev_face_id); | 4289 | old_face = FACE_FROM_ID_OR_NULL (it->f, prev_face_id); |
| 4283 | } | 4290 | } |
| @@ -4285,21 +4292,12 @@ face_at_pos (struct it *it, enum lface_attribute_index attr_filter) | |||
| 4285 | /* If the new face has a box, but the old face does not, | 4292 | /* If the new face has a box, but the old face does not, |
| 4286 | this is the start of a run of characters with box face, | 4293 | this is the start of a run of characters with box face, |
| 4287 | i.e. this character has a shadow on the left side. */ | 4294 | i.e. this character has a shadow on the left side. */ |
| 4295 | it->face_id = new_face_id; | ||
| 4288 | it->start_of_box_run_p = (new_face->box != FACE_NO_BOX | 4296 | it->start_of_box_run_p = (new_face->box != FACE_NO_BOX |
| 4289 | && (old_face == NULL || !old_face->box)); | 4297 | && (old_face == NULL || !old_face->box)); |
| 4290 | it->face_box_p = new_face->box != FACE_NO_BOX; | 4298 | it->face_box_p = new_face->box != FACE_NO_BOX; |
| 4291 | } | 4299 | } |
| 4292 | 4300 | ||
| 4293 | return new_face_id; | ||
| 4294 | } | ||
| 4295 | |||
| 4296 | |||
| 4297 | /* Set up iterator IT from face properties at its current position. | ||
| 4298 | Called from handle_stop. */ | ||
| 4299 | static enum prop_handled | ||
| 4300 | handle_face_prop (struct it *it) | ||
| 4301 | { | ||
| 4302 | it->face_id = face_at_pos (it, 0); | ||
| 4303 | return HANDLED_NORMALLY; | 4301 | return HANDLED_NORMALLY; |
| 4304 | } | 4302 | } |
| 4305 | 4303 | ||
| @@ -4310,7 +4308,7 @@ handle_face_prop (struct it *it) | |||
| 4310 | Otherwise, use the iterator's base_face_id. */ | 4308 | Otherwise, use the iterator's base_face_id. */ |
| 4311 | 4309 | ||
| 4312 | static int | 4310 | static int |
| 4313 | underlying_face_id (struct it *it) | 4311 | underlying_face_id (const struct it *it) |
| 4314 | { | 4312 | { |
| 4315 | int face_id = it->base_face_id, i; | 4313 | int face_id = it->base_face_id, i; |
| 4316 | 4314 | ||