From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#12766: read-from-minibuffer does not preserve current-buffer Date: Tue, 30 Oct 2012 19:49:23 +0100 Message-ID: <50902133.1070703@gmx.at> References: <508FABAE.4050104@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1351623045 7145 80.91.229.3 (30 Oct 2012 18:50:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2012 18:50:45 +0000 (UTC) Cc: 12766@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 30 19:50:51 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TTGtl-0007h2-Vj for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2012 19:50:50 +0100 Original-Received: from localhost ([::1]:38718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTGtd-0001n4-El for geb-bug-gnu-emacs@m.gmane.org; Tue, 30 Oct 2012 14:50:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTGtV-0001iK-Dy for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 14:50:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTGtS-0003U7-2D for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 14:50:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58038) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTGtR-0003U3-Uq for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 14:50:29 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TTGvu-0007Rc-Ek for bug-gnu-emacs@gnu.org; Tue, 30 Oct 2012 14:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 30 Oct 2012 18:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12766 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12766-submit@debbugs.gnu.org id=B12766.135162312328534 (code B ref 12766); Tue, 30 Oct 2012 18:53:02 +0000 Original-Received: (at 12766) by debbugs.gnu.org; 30 Oct 2012 18:52:03 +0000 Original-Received: from localhost ([127.0.0.1]:40052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TTGuw-0007QB-Ra for submit@debbugs.gnu.org; Tue, 30 Oct 2012 14:52:03 -0400 Original-Received: from mailout-de.gmx.net ([213.165.64.23]:55364) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1TTGuu-0007Pm-AR for 12766@debbugs.gnu.org; Tue, 30 Oct 2012 14:52:01 -0400 Original-Received: (qmail invoked by alias); 30 Oct 2012 18:49:25 -0000 Original-Received: from 62-47-63-38.adsl.highway.telekom.at (EHLO [62.47.63.38]) [62.47.63.38] by mail.gmx.net (mp031) with SMTP; 30 Oct 2012 19:49:25 +0100 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX18v9KE3WI4vLH9XOrS216dcl8N9NfYigsTEuAAtM+ 1Pmpxqx8i+4K7/ In-Reply-To: X-Y-GMX-Trusted: 0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:66242 Archived-At: >>> % src/emacs -Q --eval "(setq initial-frame-alist '((minibuffer . nil)))" >>> M-: (with-temp-buffer (list (read-string "toto: ") (current-buffer))) RET >> Two changes I made could be involved: >> (1) `select-window' now always makes the window's buffer current. >> (2) read_minibuf now calls set_window_buffer instead of >> Fset_window_buffer. > > I think (1) is more likely to be the problem. Verified (sloppily). > Could you check > read_minibuf to see which unwind is supposed to reset the > current buffer? IIUC read_minibuf doesn't care about restoring the current buffer. > Maybe that code worked by accident (.e.g relying on the fact that > select-window didn't set current-buffer in that corner case) and the > right fix is simply to explicitly save&restore current buffer. FWIW the problem already happens when choose_minibuf_frame calls Fset_frame_selected_window. The patch below seems to fix it. martin, completely lost in the labyrinth of read_minibuf *** src/minibuf.c 2012-10-11 16:23:37 +0000 --- src/minibuf.c 2012-10-30 18:25:26 +0000 *************** *** 472,477 **** --- 472,479 ---- /* Choose the minibuffer window and frame, and take action on them. */ + record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); + choose_minibuf_frame (); record_unwind_protect (choose_minibuf_frame_1, Qnil);