Subject: bug#745: pop-to-buffer, frames, and input focus

From: Helmut Eller <[email-masked]>
Date: Wed, 20 Aug 2008 09:35:31 +0200

Hi,

The behavior of pop-to-buffer in combination with multiple frames is
rather unpredictable or at least not what I expected.

For example:

  shell$ cat pop-to-buffer-test.el
  
  (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"))
  
  shell$ emacs -Q -l pop-to-buffer-test.el

Pops up two frames, one frame displays the "foo" buffer and the other
the "*scratch*" buffer (so far so good).  But the "foo" frame has not
the input focus.  Isn't pop-to-buffer supposed to switch input focus
too?

Also note that I had to save and restore the selected frame
around display-buffer.  If I try

  emacs -Q --eval '(let ((pop-up-frames t)) 
                     (display-buffer (get-buffer-create "foo")))' 

the "foo" buffer is selected, even though display-buffer should not
switch the selected window.

Not even save-window-excursion stops display-buffer from switching the
frame:

  emacs -Q --eval '(save-window-excursion 
                     (let ((pop-up-frames t)) 
                        (display-buffer (get-buffer-create "foo"))))'

This is with:
 GNU Emacs 23.0.60.4 (i686-pc-linux-gnu, GTK+ Version 2.8.20)
 of 2008-08-15 on xaital
Windowing system distributor `The X.Org Foundation', version 11.0.70101000
configured using `configure  '--without-sound' '--without-pop' '--without-gif' '--without-tiff''

My window manager is Sawfish 1.3.

Helmut.