aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/xdisp.c134
1 files changed, 75 insertions, 59 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 506af36dea4..a2e8a4b1b67 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -5370,15 +5370,32 @@ setup_echo_area_for_printing (multibyte_p)
5370} 5370}
5371 5371
5372 5372
5373/* Display the current echo area message in window W. Value is 5373/* Display an echo area message in window W. Value is non-zero if W's
5374 non-zero if W's height is changed. */ 5374 height is changed. If display_last_displayed_message_p is
5375 non-zero, display the message that was last displayed, otherwise
5376 display the current message. */
5375 5377
5376static int 5378static int
5377display_echo_area (w) 5379display_echo_area (w)
5378 struct window *w; 5380 struct window *w;
5379{ 5381{
5380 return with_echo_area_buffer (w, display_last_displayed_message_p, 5382 int i, no_message_p, window_height_changed_p;
5381 (int (*) ()) display_echo_area_1, w); 5383
5384 /* If there is no message, we must call display_echo_area_1
5385 nevertheless because it resizes the window. But we will have to
5386 reset the echo_area_buffer in question to nil at the end because
5387 with_echo_area_buffer will sets it to an empty buffer. */
5388 i = display_last_displayed_message_p ? 1 : 0;
5389 no_message_p = NILP (echo_area_buffer[i]);
5390
5391 window_height_changed_p
5392 = with_echo_area_buffer (w, display_last_displayed_message_p,
5393 (int (*) ()) display_echo_area_1, w);
5394
5395 if (no_message_p)
5396 echo_area_buffer[i] = Qnil;
5397
5398 return window_height_changed_p;
5382} 5399}
5383 5400
5384 5401
@@ -5406,10 +5423,6 @@ display_echo_area_1 (w)
5406 SET_TEXT_POS (start, BEG, BEG_BYTE); 5423 SET_TEXT_POS (start, BEG, BEG_BYTE);
5407 try_window (window, start); 5424 try_window (window, start);
5408 5425
5409 /* The current buffer is the one containing the last displayed
5410 echo area message. */
5411 XSETBUFFER (echo_area_buffer[1], current_buffer);
5412
5413 return window_height_changed_p; 5426 return window_height_changed_p;
5414} 5427}
5415 5428
@@ -5429,54 +5442,51 @@ resize_mini_window (w)
5429 if (!FRAME_MINIBUF_ONLY_P (f)) 5442 if (!FRAME_MINIBUF_ONLY_P (f))
5430 { 5443 {
5431 struct it it; 5444 struct it it;
5445 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
5446 int total_height = XFASTINT (root->height) + XFASTINT (w->height);
5447 int height, max_height;
5448 int unit = CANON_Y_UNIT (f);
5449 struct text_pos start;
5432 5450
5433 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID); 5451 init_iterator (&it, w, BEGV, BEGV_BYTE, NULL, DEFAULT_FACE_ID);
5434 if (!it.truncate_lines_p)
5435 {
5436 struct window *root = XWINDOW (FRAME_ROOT_WINDOW (f));
5437 int total_height = XFASTINT (root->height) + XFASTINT (w->height);
5438 int height, max_height;
5439 int unit = CANON_Y_UNIT (f);
5440 struct text_pos start;
5441
5442 /* Compute the max. number of lines specified by the user. */
5443 if (FLOATP (Vmax_mini_window_height))
5444 max_height = XFLOATINT (Vmax_mini_window_height) * total_height;
5445 else if (INTEGERP (Vmax_mini_window_height))
5446 max_height = XINT (Vmax_mini_window_height);
5447
5448 /* Correct that max. height if it's bogus. */
5449 max_height = max (1, max_height);
5450 max_height = min (total_height, max_height);
5451
5452 /* Find out the height of the text in the window. */
5453 move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS);
5454 height = (unit - 1 + it.current_y + last_height) / unit;
5455 height = max (1, height);
5456
5457 /* Compute a suitable window start. */
5458 if (height > max_height)
5459 {
5460 height = max_height;
5461 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
5462 move_it_vertically_backward (&it, (height - 1) * unit);
5463 start = it.current.pos;
5464 }
5465 else
5466 SET_TEXT_POS (start, BEGV, BEGV_BYTE);
5467 SET_MARKER_FROM_TEXT_POS (w->start, start);
5468 5452
5469 /* Change window's height, if necessary. */ 5453 /* Compute the max. number of lines specified by the user. */
5470 if (height != XFASTINT (w->height)) 5454 if (FLOATP (Vmax_mini_window_height))
5471 { 5455 max_height = XFLOATINT (Vmax_mini_window_height) * total_height;
5472 Lisp_Object old_selected_window; 5456 else if (INTEGERP (Vmax_mini_window_height))
5473 5457 max_height = XINT (Vmax_mini_window_height);
5474 old_selected_window = selected_window; 5458
5475 XSETWINDOW (selected_window, w); 5459 /* Correct that max. height if it's bogus. */
5476 change_window_height (height - XFASTINT (w->height), 0); 5460 max_height = max (1, max_height);
5477 selected_window = old_selected_window; 5461 max_height = min (total_height, max_height);
5478 window_height_changed_p = 1; 5462
5479 } 5463 /* Find out the height of the text in the window. */
5464 move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS);
5465 height = (unit - 1 + it.current_y + last_height) / unit;
5466 height = max (1, height);
5467
5468 /* Compute a suitable window start. */
5469 if (height > max_height)
5470 {
5471 height = max_height;
5472 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
5473 move_it_vertically_backward (&it, (height - 1) * unit);
5474 start = it.current.pos;
5475 }
5476 else
5477 SET_TEXT_POS (start, BEGV, BEGV_BYTE);
5478 SET_MARKER_FROM_TEXT_POS (w->start, start);
5479
5480 /* Change window's height, if necessary. */
5481 if (height != XFASTINT (w->height))
5482 {
5483 Lisp_Object old_selected_window;
5484
5485 old_selected_window = selected_window;
5486 XSETWINDOW (selected_window, w);
5487 change_window_height (height - XFASTINT (w->height), 0);
5488 selected_window = old_selected_window;
5489 window_height_changed_p = 1;
5480 } 5490 }
5481 } 5491 }
5482 5492
@@ -5813,10 +5823,9 @@ echo_area_display (update_frame_p)
5813 } 5823 }
5814 else if (!EQ (mini_window, selected_window)) 5824 else if (!EQ (mini_window, selected_window))
5815 windows_or_buffers_changed++; 5825 windows_or_buffers_changed++;
5816
5817 if (NILP (echo_area_buffer[0]))
5818 clear_message (0, 1);
5819 5826
5827 echo_area_buffer[1] = echo_area_buffer[0];
5828
5820 /* Prevent redisplay optimization in redisplay_internal by resetting 5829 /* Prevent redisplay optimization in redisplay_internal by resetting
5821 this_line_start_pos. This is done because the mini-buffer now 5830 this_line_start_pos. This is done because the mini-buffer now
5822 displays the message instead of its buffer text. */ 5831 displays the message instead of its buffer text. */
@@ -7007,6 +7016,7 @@ redisplay_internal (preserve_echo_area)
7007 { 7016 {
7008 int window_height_changed_p = echo_area_display (0); 7017 int window_height_changed_p = echo_area_display (0);
7009 must_finish = 1; 7018 must_finish = 1;
7019
7010 if (fonts_changed_p) 7020 if (fonts_changed_p)
7011 goto retry; 7021 goto retry;
7012 else if (window_height_changed_p) 7022 else if (window_height_changed_p)
@@ -7016,12 +7026,18 @@ redisplay_internal (preserve_echo_area)
7016 ++windows_or_buffers_changed; 7026 ++windows_or_buffers_changed;
7017 } 7027 }
7018 } 7028 }
7019 else if (w == XWINDOW (minibuf_window) && resize_mini_window (w)) 7029 else if (w == XWINDOW (minibuf_window)
7030 && (current_buffer->clip_changed
7031 || XFASTINT (w->last_modified) < MODIFF
7032 || XFASTINT (w->last_overlay_modified) < OVERLAY_MODIFF)
7033 && resize_mini_window (w))
7020 { 7034 {
7021 /* Resized active mini-window to fit the size of what it is 7035 /* Resized active mini-window to fit the size of what it is
7022 showing. */ 7036 showing if its contents might have changed. */
7037 must_finish = 1;
7038 consider_all_windows_p = 1;
7023 ++windows_or_buffers_changed; 7039 ++windows_or_buffers_changed;
7024 goto retry; 7040 ++update_mode_lines;
7025 } 7041 }
7026 7042
7027 7043