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#745: pop-to-buffer, frames, and input focus Date: Sat, 06 Sep 2008 13:56:14 +0200 Message-ID: <48C26FDE.9080101@gmx.at> References: <48ADD085.50505@gmx.at> <48AEEBB8.50201@gmx.at> <48AFFD26.3040204@gmx.at> <48B2B78C.9090407@gmx.at> <48B50C63.8010402@gmx.at> <48B69007.20604@gmx.at> <48B7181B.7080706@gmx.at> <48B7C0DA.8040104@gmx.at> <48B901B0.90701@gmx.at> <48B94E28.9040707@gmx.at> Reply-To: martin rudalics , 745@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1220702876 27317 80.91.229.12 (6 Sep 2008 12:07:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Sep 2008 12:07:56 +0000 (UTC) Cc: 745@emacsbugs.donarmstrong.com To: Helmut Eller Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 06 14:08:51 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 1Kbwaw-0002Kb-Ag for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Sep 2008 14:08:50 +0200 Original-Received: from localhost ([127.0.0.1]:59207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KbwZx-0006KV-57 for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Sep 2008 08:07:49 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KbwZk-0006CK-Mc for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 08:07:36 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KbwZj-0006BM-00 for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 08:07:35 -0400 Original-Received: from [199.232.76.173] (port=44662 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KbwZi-0006BI-SM for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 08:07:34 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:33182) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KbwZi-0003C8-2m for bug-gnu-emacs@gnu.org; Sat, 06 Sep 2008 08:07:34 -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 m86C7VKJ026373; Sat, 6 Sep 2008 05:07:32 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m86C553Q025045; Sat, 6 Sep 2008 05:05:05 -0700 X-Loop: don@donarmstrong.com Resent-From: martin rudalics Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 06 Sep 2008 12:05:05 +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.122070232922363 (code B ref 745); Sat, 06 Sep 2008 12:05:05 +0000 Original-Received: (at 745) by emacsbugs.donarmstrong.com; 6 Sep 2008 11:58:49 +0000 Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id m86Bweiu022357 for <745@emacsbugs.donarmstrong.com>; Sat, 6 Sep 2008 04:58:42 -0700 Original-Received: (qmail invoked by alias); 06 Sep 2008 11:58:34 -0000 Original-Received: from 62-47-38-100.adsl.highway.telekom.at (EHLO [62.47.38.100]) [62.47.38.100] by mail.gmx.net (mp028) with SMTP; 06 Sep 2008 13:58:34 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX1/NPmlQ0XrNxoZytsT3Lbbuve9EAxYSl0M9k9J2Pk zOg5fF6pz8vdXA User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) In-Reply-To: X-Y-GMX-Trusted: 0 X-FuHaFi: 0.62 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Resent-Date: Sat, 06 Sep 2008 08:07:35 -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:20228 Archived-At: I'm currently using (defun pop-to-buffer (buffer-or-name &optional other-window norecord) "Select buffer BUFFER-OR-NAME in some window, preferably a different one. ...." (let ((buffer ;; FIXME: This behavior is carried over from the previous C version ;; of pop-to-buffer, but really we should use just ;; `get-buffer' here. (if (null buffer-or-name) (other-buffer (current-buffer)) (or (get-buffer buffer-or-name) (let ((buf (get-buffer-create buffer-or-name))) (set-buffer-major-mode buf) buf)))) (old-window (selected-window)) (old-frame (selected-frame)) new-window new-frame) (set-buffer buffer) (setq new-window (display-buffer buffer other-window) norecord) (unless (eq new-window old-window) ;; `display-buffer' has chosen another window. (setq new-frame (window-frame new-window)) (unless (eq new-frame old-frame) ;; `display-buffer' has chosen another frame, make sure it gets ;; input focus and is risen. (select-frame-set-input-focus new-frame)) ;; Make sure the window chosen by `display-buffer' gets selected. (select-window new-window)) buffer)) so `select-frame-set-input-focus' gets called iff `display-buffer' did choose another frame. I noticed that I cannot use `select-frame-set-input-focus' unconditionally for the following reason: On my Emacs `focus-follows-mouse' is t so the final check in `select-frame-set-input-focus' (when focus-follows-mouse (set-mouse-position (selected-frame) (1- (frame-width)) 0))) _always_ succeeds and sends my mouse cursor to the upper right corner of the corresponding frame. This is annoying whenever I click, for example, on a button in a help buffer to follow a link, causing the window returned by `display-buffer' show up on the already _selected_ frame. Since I additionally have `mouse-autoselect-window' non-nil, an unrelated window on top of the selected frame may get selected too. One annyoing aspect of the rigid use of `set-mouse-position' in `select-frame-set-input-focus' obviously remains, namely that with `mouse-autoselect-window' non-nil `other-frame' (and related functions) may change the selected window on the other frame :-( This has to be fixed independently. Please check whether `pop-to-buffer' as defined above fits your needs. If so, and no one else protests, I'll install this next week. martin