From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: run_window_configuration_change_hook Date: Tue, 19 Apr 2011 14:43:10 +0200 Message-ID: <4DAD835E.9010301@gmx.at> References: <4DAC398A.204@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1303217013 16194 80.91.229.12 (19 Apr 2011 12:43:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 19 Apr 2011 12:43:33 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 19 14:43:27 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QCAH8-0004fL-OU for ged-emacs-devel@m.gmane.org; Tue, 19 Apr 2011 14:43:26 +0200 Original-Received: from localhost ([::1]:38845 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCAH8-00019G-B8 for ged-emacs-devel@m.gmane.org; Tue, 19 Apr 2011 08:43:26 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:57850) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QCAH5-000181-3y for emacs-devel@gnu.org; Tue, 19 Apr 2011 08:43:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QCAH4-0000ol-3a for emacs-devel@gnu.org; Tue, 19 Apr 2011 08:43:23 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:52561) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1QCAH3-0000oc-Nj for emacs-devel@gnu.org; Tue, 19 Apr 2011 08:43:22 -0400 Original-Received: (qmail invoked by alias); 19 Apr 2011 12:43:14 -0000 Original-Received: from 62-47-40-89.adsl.highway.telekom.at (EHLO [62.47.40.89]) [62.47.40.89] by mail.gmx.net (mp063) with SMTP; 19 Apr 2011 14:43:14 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18ITkQLKQQIJpxYG8oGsO1VxUw8BHH18DSSHWHlPS 6mjAb4ygFdZOTV User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) In-Reply-To: <4DAC398A.204@gmx.at> X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.23 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138571 Archived-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.