all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: emacs-devel <emacs-devel@gnu.org>
Subject: Re: run_window_configuration_change_hook
Date: Tue, 19 Apr 2011 14:43:10 +0200	[thread overview]
Message-ID: <4DAD835E.9010301@gmx.at> (raw)
In-Reply-To: <4DAC398A.204@gmx.at>

A hopefully correct scenario for reproducing the bug goes as follows:
With the current trunk do emacs -Q and evaluate the following form:

(let ((frame (selected-frame))
       (window (frame-root-window (make-frame))))
   (set-window-buffer window "*Messages*")
   (split-window window)
   (select-frame frame)
   (with-current-buffer "*Messages*"
     (adjust-window-trailing-edge window 1 nil)
     (message "%s" (current-buffer))))

The call to `adjust-window-trailing-edge' changes the current buffer
from *Messages* to *scratch* here.

As stated before the reason is that run_window_configuration_change_hook
has this code

   if (SELECTED_FRAME () != f)
     {
       record_unwind_protect (select_frame_norecord, Fselected_frame ());
       Fselect_frame (frame, Qt);
     }

   /* Use the right buffer.  Matters when running the local hooks.  */
   if (current_buffer != XBUFFER (Fwindow_buffer (Qnil)))
     {
       record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
       Fset_buffer (Fwindow_buffer (Qnil));
     }

which implies to first restore the current buffer and afterwards the
selected frame which can make another buffer current.  Inverting the
order of the two clauses resolves the problem for me.  Since I hardly
ever use more than one frame, I'm not 100% sure whether reverting the
clauses can break existing code.  Comments welcome.

martin

Note: The bug cannot be reproduced by using `split-window' alone as I
tried earlier since that wraps run_window_configuration_change_hook in
set_window_buffer which takes some care to restore the current buffer.



  parent reply	other threads:[~2011-04-19 12:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-18 13:15 run_window_configuration_change_hook martin rudalics
2011-04-18 13:21 ` run_window_configuration_change_hook martin rudalics
2011-04-19 12:43 ` martin rudalics [this message]
2011-04-19 13:45   ` run_window_configuration_change_hook Stefan Monnier

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=4DAD835E.9010301@gmx.at \
    --to=rudalics@gmx.at \
    --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.