Subject: 26.1.90; Wrong unbinding order in x_consider_frame_title

From: martin rudalics <[email-masked]>
Date: Mon, 04 Feb 2019 19:49:54 +0100

The unbinding order in x_consider_frame_title is botched.  Hence,
while do_switch_frame will not resize the minibuffer window when the
frame of the title bar gets selected, it will still resize when the
old frame gets reselected in the unbind form.

The behavior can be seen with emacs -Q evaluating the following two
forms in row:

(make-frame '((minibuffer . nil)))
(y-or-n-p "\n")

The attached trivial patch cures it.  Obviously, there's no guarantee
that some other client relies on the wrong order.

martin
diff --git a/src/xdisp.c b/src/xdisp.c
index 274ab8d..0d084f8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12002,12 +12002,6 @@ static void ATTRIBUTE_FORMAT_PRINTF (1, 0)
       /* Set global variable indicating that multiple frames exist.  */
       multiple_frames = CONSP (tail);
 
-      /* Switch to the buffer of selected window of the frame.  Set up
-	 mode_line_target so that display_mode_element will output into
-	 mode_line_noprop_buf; then display the title.  */
-      record_unwind_protect (unwind_format_mode_line,
-			     format_mode_line_unwind_data
-			       (f, current_buffer, selected_window, false));
       /* select-frame calls resize_mini_window, which could resize the
 	 mini-window and by that undo the effect of this redisplay
 	 cycle wrt minibuffer and echo-area display.  Binding
@@ -12015,6 +12009,12 @@ static void ATTRIBUTE_FORMAT_PRINTF (1, 0)
 	 no-op, thus avoiding the adverse side effects.  */
       specbind (Qinhibit_redisplay, Qt);
 
+      /* Switch to the buffer of selected window of the frame.  Set up
+	 mode_line_target so that display_mode_element will output into
+	 mode_line_noprop_buf; then display the title.  */
+      record_unwind_protect (unwind_format_mode_line,
+			     format_mode_line_unwind_data
+			       (f, current_buffer, selected_window, false));
       Fselect_window (f->selected_window, Qt);
       set_buffer_internal_1
 	(XBUFFER (XWINDOW (f->selected_window)->contents));