unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* C-g while exiting the minibuffer
@ 2013-11-27 21:15 Stefan Monnier
  2013-11-28  1:54 ` Stefan Monnier
  2013-11-28 17:02 ` martin rudalics
  0 siblings, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 2013-11-27 21:15 UTC (permalink / raw)
  To: emacs-devel

I've been trying to track down a performance problem I've been
experimenting for a while now.  Along the way I found that the problem
shows up when frame-focus is redirected (at least, it's a necessary
ingredient, tho not sufficient).

But I also found out that sometimes I have a redirected frame-focus for
no reason.  And I finally yesterday caught the bugger that causes this:
C-h right while exiting the minibuffer: my minibuffer is in a separate
frame, so while in the minibuffer, the frame-focus is redirected (this
is perfectly normal so far).  When exiting the minibuffer, this focus is
supposed to be canceled, but this cancellation can fail:

the cancellation is done implicitly by the restoration of the previous
window-configuration.  The problem being that Fset_window_configuration
does

      /* In the following call to `select-window', prevent "swapping out
	 point" in the old selected window using the buffer that has
	 been restored into it.  We already swapped out that point from
	 that window's old buffer.  */
      select_window (data->current_window, Qnil, 1);
      BVAR (XBUFFER (XWINDOW (selected_window)->contents), last_selected_window)
	= selected_window;

just before

      if (NILP (data->focus_frame)
	  || (FRAMEP (data->focus_frame)
	      && FRAME_LIVE_P (XFRAME (data->focus_frame))))
	Fredirect_frame_focus (frame, data->focus_frame);

IOW just before resetting the frame-focus, we select the
selected-window.  So far this looks innocuous, but select_window (with
a 1 as last argument) calls record_buffer which calls Fdelq which uses
QUIT, so if you happen to hit C-g at the right time, the frame-focus
redirection is not properly canceled.

Now I wonder what should be the best way to fix this.  I can just switch
the above two code blocks, which will fix the immediate problem (a C-g
will not prevent canceling the frame-focus redirected), but I think this
points to a larger problem of hitting C-g while processing unwind forms.
Of course binding inhibit-quit during processing of unwind forms could
be a source of problem in itself (if those forms fail to terminate).

Any comment/idea/suggestion?


        Stefan



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-12-05 14:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-27 21:15 C-g while exiting the minibuffer Stefan Monnier
2013-11-28  1:54 ` Stefan Monnier
2013-11-28  3:53   ` Eli Zaretskii
2013-11-28 15:14     ` Stefan Monnier
2013-11-28 17:02 ` martin rudalics
2013-11-28 19:22   ` Stefan Monnier
2013-11-28 23:17     ` Andreas Schwab
2013-11-29  1:34       ` Stefan Monnier
2013-11-29  1:38       ` Stefan Monnier
2013-11-30 12:16     ` martin rudalics
2013-12-01 22:13       ` Stefan Monnier
2013-12-02  3:30         ` Stephen J. Turnbull
2013-12-05 14:02         ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).