Subject: Re: 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 04:10:14 -0500

martin rudalics <[email-masked]> writes:

>> Perhaps the thing to do is simply to disable x-wait-for-event-timeout if
>> we end up hitting the timeout.  Under most window managers the frame
>> becomes visible much faster than 100ms anyway, as far as I know.
>
> If and when we do that, we should also warn and inform the user.  And we
> probably should collect information about those window managers that are
> not able to inform us in due time that the frame has become visible.

Not sure what Alexander is using, but under i3 the problem is simply
that the frame doesn't become visible until the user switches to the
virtual workspace where Emacs is.  So it's not that we have a visible
frame which the window manager fails to inform us about in time, rather
the frame just doesn't become visible in time.

It occurs to me that another possibility is simply to disable the
timeout when doing the auto-raise.  We have the timeout due some users'
configurations accidentally relying on the fact that a frame will be
visible after make-frame returns, but it seems unlikely that anyone
would manage to rely on the frame being visible after a call to
`message' occurs.

>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)

* 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 +++++++++++--
 1 file changed, 11 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 ();
-- 
2.11.0