aboutsummaryrefslogtreecommitdiffstats
path: root/src/xdisp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c111
1 files changed, 85 insertions, 26 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index a83ee8983dc..96244877a2e 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -963,8 +963,8 @@ static void compute_string_pos P_ ((struct text_pos *, struct text_pos,
963static int face_before_or_after_it_pos P_ ((struct it *, int)); 963static int face_before_or_after_it_pos P_ ((struct it *, int));
964static int next_overlay_change P_ ((int)); 964static int next_overlay_change P_ ((int));
965static int handle_single_display_spec P_ ((struct it *, Lisp_Object, 965static int handle_single_display_spec P_ ((struct it *, Lisp_Object,
966 Lisp_Object, struct text_pos *, 966 Lisp_Object, Lisp_Object,
967 int)); 967 struct text_pos *, int));
968static int underlying_face_id P_ ((struct it *)); 968static int underlying_face_id P_ ((struct it *));
969static int in_ellipses_for_invisible_text_p P_ ((struct display_pos *, 969static int in_ellipses_for_invisible_text_p P_ ((struct display_pos *,
970 struct window *)); 970 struct window *));
@@ -3077,16 +3077,18 @@ handle_stop (it)
3077 if (it->method == GET_FROM_DISPLAY_VECTOR) 3077 if (it->method == GET_FROM_DISPLAY_VECTOR)
3078 handle_overlay_change_p = 0; 3078 handle_overlay_change_p = 0;
3079 3079
3080 /* Handle overlay changes. */ 3080 /* Handle overlay changes.
3081 This sets HANDLED to HANDLED_RECOMPUTE_PROPS
3082 if it finds overlays. */
3081 if (handle_overlay_change_p) 3083 if (handle_overlay_change_p)
3082 handled = handle_overlay_change (it); 3084 handled = handle_overlay_change (it);
3083
3084 /* Determine where to stop next. */
3085 if (handled == HANDLED_NORMALLY)
3086 compute_stop_pos (it);
3087 } 3085 }
3088 } 3086 }
3089 while (handled == HANDLED_RECOMPUTE_PROPS); 3087 while (handled == HANDLED_RECOMPUTE_PROPS);
3088
3089 /* Determine where to stop next. */
3090 if (handled == HANDLED_NORMALLY)
3091 compute_stop_pos (it);
3090} 3092}
3091 3093
3092 3094
@@ -3367,18 +3369,58 @@ handle_face_prop (it)
3367 else 3369 else
3368 { 3370 {
3369 int base_face_id, bufpos; 3371 int base_face_id, bufpos;
3372 int i;
3373 Lisp_Object from_overlay
3374 = (it->current.overlay_string_index >= 0
3375 ? it->string_overlays[it->current.overlay_string_index]
3376 : Qnil);
3377
3378 /* See if we got to this string directly or indirectly from
3379 an overlay property. That includes the before-string or
3380 after-string of an overlay, strings in display properties
3381 provided by an overlay, their text properties, etc.
3382
3383 FROM_OVERLAY is the overlay that brought us here, or nil if none. */
3384 if (! NILP (from_overlay))
3385 for (i = it->sp - 1; i >= 0; i--)
3386 {
3387 if (it->stack[i].current.overlay_string_index >= 0)
3388 from_overlay
3389 = it->string_overlays[it->stack[i].current.overlay_string_index];
3390 else if (! NILP (it->stack[i].from_overlay))
3391 from_overlay = it->stack[i].from_overlay;
3370 3392
3371 if (it->current.overlay_string_index >= 0) 3393 if (!NILP (from_overlay))
3372 bufpos = IT_CHARPOS (*it); 3394 break;
3395 }
3396
3397 if (! NILP (from_overlay))
3398 {
3399 bufpos = IT_CHARPOS (*it);
3400 /* For a string from an overlay, the base face depends
3401 only on text properties and ignores overlays. */
3402 base_face_id
3403 = face_for_overlay_string (it->w,
3404 IT_CHARPOS (*it),
3405 it->region_beg_charpos,
3406 it->region_end_charpos,
3407 &next_stop,
3408 (IT_CHARPOS (*it)
3409 + TEXT_PROP_DISTANCE_LIMIT),
3410 0,
3411 from_overlay);
3412 }
3373 else 3413 else
3374 bufpos = 0; 3414 {
3415 bufpos = 0;
3375 3416
3376 /* For strings from a buffer, i.e. overlay strings or strings 3417 /* For strings from a `display' property, use the face at
3377 from a `display' property, use the face at IT's current 3418 IT's current buffer position as the base face to merge
3378 buffer position as the base face to merge with, so that 3419 with, so that overlay strings appear in the same face as
3379 overlay strings appear in the same face as surrounding 3420 surrounding text, unless they specify their own
3380 text, unless they specify their own faces. */ 3421 faces. */
3381 base_face_id = underlying_face_id (it); 3422 base_face_id = underlying_face_id (it);
3423 }
3382 3424
3383 new_face_id = face_at_string_position (it->w, 3425 new_face_id = face_at_string_position (it->w,
3384 it->string, 3426 it->string,
@@ -3789,7 +3831,7 @@ static enum prop_handled
3789handle_display_prop (it) 3831handle_display_prop (it)
3790 struct it *it; 3832 struct it *it;
3791{ 3833{
3792 Lisp_Object prop, object; 3834 Lisp_Object prop, object, overlay;
3793 struct text_pos *position; 3835 struct text_pos *position;
3794 /* Nonzero if some property replaces the display of the text itself. */ 3836 /* Nonzero if some property replaces the display of the text itself. */
3795 int display_replaced_p = 0; 3837 int display_replaced_p = 0;
@@ -3817,10 +3859,12 @@ handle_display_prop (it)
3817 if (!it->string_from_display_prop_p) 3859 if (!it->string_from_display_prop_p)
3818 it->area = TEXT_AREA; 3860 it->area = TEXT_AREA;
3819 3861
3820 prop = Fget_char_property (make_number (position->charpos), 3862 prop = get_char_property_and_overlay (make_number (position->charpos),
3821 Qdisplay, object); 3863 Qdisplay, object, &overlay);
3822 if (NILP (prop)) 3864 if (NILP (prop))
3823 return HANDLED_NORMALLY; 3865 return HANDLED_NORMALLY;
3866 /* Now OVERLAY is the overlay that gave us this property, or nil
3867 if it was a text property. */
3824 3868
3825 if (!STRINGP (it->string)) 3869 if (!STRINGP (it->string))
3826 object = it->w->buffer; 3870 object = it->w->buffer;
@@ -3842,7 +3886,7 @@ handle_display_prop (it)
3842 { 3886 {
3843 for (; CONSP (prop); prop = XCDR (prop)) 3887 for (; CONSP (prop); prop = XCDR (prop))
3844 { 3888 {
3845 if (handle_single_display_spec (it, XCAR (prop), object, 3889 if (handle_single_display_spec (it, XCAR (prop), object, overlay,
3846 position, display_replaced_p)) 3890 position, display_replaced_p))
3847 { 3891 {
3848 display_replaced_p = 1; 3892 display_replaced_p = 1;
@@ -3857,7 +3901,7 @@ handle_display_prop (it)
3857 { 3901 {
3858 int i; 3902 int i;
3859 for (i = 0; i < ASIZE (prop); ++i) 3903 for (i = 0; i < ASIZE (prop); ++i)
3860 if (handle_single_display_spec (it, AREF (prop, i), object, 3904 if (handle_single_display_spec (it, AREF (prop, i), object, overlay,
3861 position, display_replaced_p)) 3905 position, display_replaced_p))
3862 { 3906 {
3863 display_replaced_p = 1; 3907 display_replaced_p = 1;
@@ -3869,7 +3913,8 @@ handle_display_prop (it)
3869 } 3913 }
3870 else 3914 else
3871 { 3915 {
3872 int ret = handle_single_display_spec (it, prop, object, position, 0); 3916 int ret = handle_single_display_spec (it, prop, object, overlay,
3917 position, 0);
3873 if (ret < 0) /* Replaced by "", i.e. nothing. */ 3918 if (ret < 0) /* Replaced by "", i.e. nothing. */
3874 return HANDLED_RECOMPUTE_PROPS; 3919 return HANDLED_RECOMPUTE_PROPS;
3875 if (ret) 3920 if (ret)
@@ -3911,6 +3956,9 @@ display_prop_end (it, object, start_pos)
3911 replaced text display with something else, for example an image; 3956 replaced text display with something else, for example an image;
3912 we ignore such properties after the first one has been processed. 3957 we ignore such properties after the first one has been processed.
3913 3958
3959 OVERLAY is the overlay this `display' property came from,
3960 or nil if it was a text property.
3961
3914 If PROP is a `space' or `image' specification, and in some other 3962 If PROP is a `space' or `image' specification, and in some other
3915 cases too, set *POSITION to the position where the `display' 3963 cases too, set *POSITION to the position where the `display'
3916 property ends. 3964 property ends.
@@ -3920,11 +3968,12 @@ display_prop_end (it, object, start_pos)
3920 "something" is "nothing". */ 3968 "something" is "nothing". */
3921 3969
3922static int 3970static int
3923handle_single_display_spec (it, spec, object, position, 3971handle_single_display_spec (it, spec, object, overlay, position,
3924 display_replaced_before_p) 3972 display_replaced_before_p)
3925 struct it *it; 3973 struct it *it;
3926 Lisp_Object spec; 3974 Lisp_Object spec;
3927 Lisp_Object object; 3975 Lisp_Object object;
3976 Lisp_Object overlay;
3928 struct text_pos *position; 3977 struct text_pos *position;
3929 int display_replaced_before_p; 3978 int display_replaced_before_p;
3930{ 3979{
@@ -4034,7 +4083,7 @@ handle_single_display_spec (it, spec, object, position,
4034 return 0; 4083 return 0;
4035 } 4084 }
4036 4085
4037 /* Handle `(space_width WIDTH)'. */ 4086 /* Handle `(space-width WIDTH)'. */
4038 if (CONSP (spec) 4087 if (CONSP (spec)
4039 && EQ (XCAR (spec), Qspace_width) 4088 && EQ (XCAR (spec), Qspace_width)
4040 && CONSP (XCDR (spec))) 4089 && CONSP (XCDR (spec)))
@@ -4158,6 +4207,7 @@ handle_single_display_spec (it, spec, object, position,
4158 it->position = start_pos; 4207 it->position = start_pos;
4159 it->object = NILP (object) ? it->w->buffer : object; 4208 it->object = NILP (object) ? it->w->buffer : object;
4160 it->method = GET_FROM_IMAGE; 4209 it->method = GET_FROM_IMAGE;
4210 it->from_overlay = Qnil;
4161 it->face_id = face_id; 4211 it->face_id = face_id;
4162 4212
4163 /* Say that we haven't consumed the characters with 4213 /* Say that we haven't consumed the characters with
@@ -4228,6 +4278,7 @@ handle_single_display_spec (it, spec, object, position,
4228 it->position = *position; 4278 it->position = *position;
4229 push_it (it); 4279 push_it (it);
4230 it->position = save_pos; 4280 it->position = save_pos;
4281 it->from_overlay = overlay;
4231 4282
4232 if (NILP (location)) 4283 if (NILP (location))
4233 it->area = TEXT_AREA; 4284 it->area = TEXT_AREA;
@@ -5011,7 +5062,10 @@ load_overlay_strings (it, charpos)
5011 i = 0; 5062 i = 0;
5012 j = it->current.overlay_string_index; 5063 j = it->current.overlay_string_index;
5013 while (i < OVERLAY_STRING_CHUNK_SIZE && j < n) 5064 while (i < OVERLAY_STRING_CHUNK_SIZE && j < n)
5014 it->overlay_strings[i++] = entries[j++].string; 5065 {
5066 it->overlay_strings[i] = entries[j].string;
5067 it->string_overlays[i++] = entries[j++].overlay;
5068 }
5015 5069
5016 CHECK_IT (it); 5070 CHECK_IT (it);
5017} 5071}
@@ -5057,6 +5111,7 @@ get_overlay_strings_1 (it, charpos, compute_stop_p)
5057 string. */ 5111 string. */
5058 IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = 0; 5112 IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = 0;
5059 it->string = it->overlay_strings[0]; 5113 it->string = it->overlay_strings[0];
5114 it->from_overlay = Qnil;
5060 it->stop_charpos = 0; 5115 it->stop_charpos = 0;
5061 xassert (STRINGP (it->string)); 5116 xassert (STRINGP (it->string));
5062 it->end_charpos = SCHARS (it->string); 5117 it->end_charpos = SCHARS (it->string);
@@ -5110,6 +5165,7 @@ push_it (it)
5110 p->face_id = it->face_id; 5165 p->face_id = it->face_id;
5111 p->string = it->string; 5166 p->string = it->string;
5112 p->method = it->method; 5167 p->method = it->method;
5168 p->from_overlay = it->from_overlay;
5113 switch (p->method) 5169 switch (p->method)
5114 { 5170 {
5115 case GET_FROM_IMAGE: 5171 case GET_FROM_IMAGE:
@@ -5163,6 +5219,7 @@ pop_it (it)
5163 it->current = p->current; 5219 it->current = p->current;
5164 it->position = p->position; 5220 it->position = p->position;
5165 it->string = p->string; 5221 it->string = p->string;
5222 it->from_overlay = p->from_overlay;
5166 if (NILP (it->string)) 5223 if (NILP (it->string))
5167 SET_TEXT_POS (it->current.string_pos, -1, -1); 5224 SET_TEXT_POS (it->current.string_pos, -1, -1);
5168 it->method = p->method; 5225 it->method = p->method;
@@ -17545,7 +17602,9 @@ are the selected window and the window's buffer). */)
17545 buffer = w->buffer; 17602 buffer = w->buffer;
17546 CHECK_BUFFER (buffer); 17603 CHECK_BUFFER (buffer);
17547 17604
17548 if (NILP (format)) 17605 /* Make formatting the modeline a non-op when noninteractive, otherwise
17606 there will be problems later caused by a partially initialized frame. */
17607 if (NILP (format) || noninteractive)
17549 return empty_unibyte_string; 17608 return empty_unibyte_string;
17550 17609
17551 if (no_props) 17610 if (no_props)