Subject: Inconsistent behaviour of display-buffer, pop-to-buffer

From: "Otto Maddox" <[email-masked]>
Date: Sat, 01 Mar 2008 04:27:23 +0000

When running Emacs on either X or Mac OS X:

;; Similar to display-buffer-other-frame, but without all the
;; raise-frame, make-frame-{in,}visible stuff.  The point is to
;; illustrate annoyingly inconsistent behaviour of display-buffer.
(defun my-display-buffer (buf)
  (let ((pop-up-frames t)
        same-window-buffer-names
        same-window-regexps)
    (display-buffer buf t)))

Create but don't display a buffer named "foo":
(get-buffer-create "foo")

Pop up a new frame, selected and WITH focus:
(my-display-buffer "foo")

Go back to the original frame with C-x 5 o

Pop up the "foo" frame, selected but WITHOUT focus this time:
(my-display-buffer "foo")

????

Again, go back to the original frame with C-x 5 o and also do
C-x b foo RET to make "foo" the current buffer.  Two issues this time.
The other "foo" frame is not raised but a new frame is unnecessarily
created (the doc says that pop-up-frames means that visible and
iconified frames should be searched).  Also, the newly created frame
is WITH focus this time:
(my-display-buffer "foo")

The same inconsistent behaviour happens if you substitute
pop-to-buffer for display-buffer in the definition of
my-display-buffer, which seems definitely buggy because the doc for
pop-to-buffer says that it should select the buffer.

In GNU Emacs 22.1.1 (powerpc-apple-darwin8.9.0, Carbon Version 1.6.0)
 of 2007-06-08
-- 
  Otto Maddox
  [email-masked]

-- 
http://www.fastmail.fm - The professional email service