Subject: bug#29095: Bug: The '20a09de953f437109a098fa8c4d380663d921481' merge increased my Emacs configuration loading time from 9 s to 60 s

From: Noam Postavsky <[email-masked]>
Date: Tue, 07 Nov 2017 07:57:13 -0500

Noam Postavsky <[email-masked]> writes:

>>>From 9ab2cb84378dd73bd599a8445c32e305bb342819 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <[email-masked]>
> Date: Tue, 7 Nov 2017 03:41:34 -0500
> Subject: [PATCH] Don't wait for X events when auto-raising frame (Bug#29095)

Sorry, forgot the DEFSYM.  Here's a patch which compiles.

>From 37e98e2b1ecaa0e594bd5a92fbf8f55e7c918fde Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Tue, 7 Nov 2017 03:41:34 -0500
Subject: [PATCH] Don't wait for X events when auto-raising frame (Bug#29095)

* src/xdisp.c (message3_nolog)
(setup_echo_area_for_printing): Let-bind x-wait-for-event-timeout to
nil while calling raise-frame.
---
 src/xdisp.c | 13 +++++++++++--
 src/xterm.c |  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index 69b74dc629..18fd8c32b9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10530,7 +10530,12 @@ message3_nolog (Lisp_Object m)
 	{
 	  set_message (m);
 	  if (minibuffer_auto_raise)
-	    Fraise_frame (frame);
+            {
+              ptrdiff_t count = SPECPDL_INDEX ();
+              specbind (Qx_wait_for_event_timeout, Qnil);
+              Fraise_frame (frame);
+              unbind_to (count, Qnil);
+            }
 	  /* Assume we are not echoing.
 	     (If we are, echo_now will override this.)  */
 	  echo_message_buffer = Qnil;
@@ -10971,7 +10976,11 @@ setup_echo_area_for_printing (bool multibyte_p)
 	  struct frame *sf = SELECTED_FRAME ();
 	  Lisp_Object mini_window;
 	  mini_window = FRAME_MINIBUF_WINDOW (sf);
-	  Fraise_frame  (WINDOW_FRAME (XWINDOW (mini_window)));
+
+          ptrdiff_t count = SPECPDL_INDEX ();
+          specbind (Qx_wait_for_event_timeout, Qnil);
+          Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window)));
+          unbind_to (count, Qnil);
 	}
 
       message_log_maybe_newline ();
diff --git a/src/xterm.c b/src/xterm.c
index dbb8349452..d021546c5e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -13325,6 +13325,7 @@ syms_of_xterm (void)
 so it is important to limit the wait.
 
 If set to a non-float value, there will be no wait at all.  */);
+  DEFSYM (Qx_wait_for_event_timeout, "x-wait-for-event-timeout");
   Vx_wait_for_event_timeout = make_float (0.1);
 
   DEFVAR_LISP ("x-keysym-table", Vx_keysym_table,
-- 
2.11.0