all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: C-g while exiting the minibuffer
Date: Wed, 27 Nov 2013 16:15:00 -0500	[thread overview]
Message-ID: <jwvk3ftk13i.fsf-monnier+emacs@gnu.org> (raw)

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



             reply	other threads:[~2013-11-27 21:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 21:15 Stefan Monnier [this message]
2013-11-28  1:54 ` C-g while exiting the minibuffer 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk3ftk13i.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.