From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#745: pop-to-buffer, frames, and input focus Date: Thu, 21 Aug 2008 10:07:30 +0200 Message-ID: References: <48AC2F4A.1000507@gmx.at> <48AC851A.3020906@gmx.at> Reply-To: Helmut Eller , 745@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1219307300 23207 80.91.229.12 (21 Aug 2008 08:28:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Aug 2008 08:28:20 +0000 (UTC) Cc: 745@emacsbugs.donarmstrong.com To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 21 10:29:09 2008 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KW5XW-0003Rm-9u for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 10:29:06 +0200 Original-Received: from localhost ([127.0.0.1]:50883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KW5WY-0003ai-Sg for geb-bug-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 04:28:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KW5W1-0003Ot-Gv for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 04:27:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KW5Vy-0003Mx-I9 for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 04:27:33 -0400 Original-Received: from [199.232.76.173] (port=48697 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KW5Vy-0003Mh-Ad for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 04:27:30 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:39489) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KW5Vx-0005rF-UV for bug-gnu-emacs@gnu.org; Thu, 21 Aug 2008 04:27:30 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7L8RRTb001464; Thu, 21 Aug 2008 01:27:28 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m7L8F5WB029736; Thu, 21 Aug 2008 01:15:05 -0700 X-Loop: don@donarmstrong.com Resent-From: Helmut Eller Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 21 Aug 2008 08:15:04 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 745 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 745-submit@emacsbugs.donarmstrong.com id=B745.121930597827742 (code B ref 745); Thu, 21 Aug 2008 08:15:04 +0000 Original-Received: (at 745) by emacsbugs.donarmstrong.com; 21 Aug 2008 08:06:18 +0000 Original-Received: from rolmail.net (cgp1.rolmail.net [195.254.252.190]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7L86CSU027736 for <745@emacsbugs.donarmstrong.com>; Thu, 21 Aug 2008 01:06:14 -0700 Original-Received: from dummy.name; Thu, 21 Aug 2008 10:06:08 +0200 Original-Received: from dummy.name; Thu, 21 Aug 2008 10:07:30 +0200 In-Reply-To: <48AC851A.3020906@gmx.at> (martin rudalics's message of "Wed, 20 Aug 2008 22:56:58 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Thu, 21 Aug 2008 04:27:33 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:19593 Archived-At: * martin rudalics [2008-08-20 22:56+0200] writes: >> Are you saying, that pop-to-buffer can't be used to select the window, >> the frame, and input focus at the same time? If so, when should >> pop-to-buffer be used? Aren't that unusual situations when >> pop-to-buffer should not also select the input focus? > > With emacs -Q evaluating > > (let ((pop-up-frames t) > (buffer (get-buffer-create "foo"))) > (pop-to-buffer buffer)) > > here gets me a new frame on top of the previously selected one, the > window displaying buffer `foo' is the selected window, and when I now > start typing, characters get displayed in that window. What did you > expect and what did you get? Consider my original example: (progn (let ((frame (selected-frame)) (pop-up-frames t)) (display-buffer (get-buffer-create "foo")) (select-frame-set-input-focus frame)) (let ((display-buffer-reuse-frames t)) (pop-to-buffer "foo"))) First, display-buffer is just used to create two frames. This switches (surprisingly) focus to the "foo" buffer. select-frame-set-input-focus is used to force the focus back to the "*scratch*" buffer. Then we use pop-to-buffer, but the input focus remains (surprisingly) in the "*scratch*" buffer. I expect this: pop-to-buffer should switch the input focus display-buffer should not change the input focus >> If you have any hints or guidelines how be a good buffer/window/frame >> citizen in different scenarios, that would be much appreciated. > > I'm slightly confused because in your earlier scenario you bemoaned the > fact that the frame _was_ selected. All I wanted to say that raising a > frame, giving it input focus, and _not_ selecting it might be difficult. I see. But this is also not what I expect. >> I'm not using multiple frames myself, but I'm maintaining a package >> called SLIME[*] which is used by a number of people who use frames. I'm >> not excited at all about rewriting a dozen or so uses of pop-to-buffer >> just to support multiple frames. There are some variables like >> display-buffer-reuse-frames and special-display-buffer-names and I hoped >> that those variables were supposed to make it easy to support multiple >> frames without cluttering the source code. >> >> [*] http://www.common-lisp.net/project/slime/ > > I moved `pop-to-buffer' to window.el so you can easier try to play > around with it and propose a solution that fits your needs ;-) Thanks for the moving it :-) pop-to-buffer is more or less (select-window (display-buffer ...)). This looks very reasonable, but it doesn't transfer the input focus. (under X; in a tty everything works well.) On the other hand, display-buffer switches sometimes (when a new frame is created) the input focus, even when that was not asked for. Maybe pop-to-buffer could do something like (let ((window (display-buffer ...))) (select-window window) (select-frame-set-input-focus (window-frame window))) That would solve my immediate problem, but I suspect that select-window should be smarter. My naive interpretation of select-window's C source is that select-window tries to select the frame. But apparently forgets about the input focus. This may also be the reason why save-window-excursion doesn't restore the input focus. Selecting a window, without giving it the input focus is probably rarely needed. Perhaps select-window should transfer the input focus by default. Helmut.