Subject: bug#15189: 24.3.50; display-buffer does not work well with custom frames.

From: martin rudalics <[email-masked]>
Date: Mon, 26 Aug 2013 18:34:33 +0200

Please keep [email-masked] CCed so others can read your mails
too.

 > Yes, that works now if we also add the following line to the end of
 > lawlist-display-buffer-function: (switch-to-buffer (get-file-buffer
 > buffer-filename))

I'm still not quite sure whether I understand what you want to do.
An idiom like

     (display-buffer
       (find-file buffer-filename))

is practically always wrong because it usually will (1) display the
buffer via `find-file' which calls `switch-to-buffer' which bypasses
`display-buffer' by calling `set-window-buffer' directly and (2) display
the buffer a second time which might result in reusing the window used
in (1) but may also use another window according to your buffer display
settings.  In any case, a doc-string like

   "Locate or create a specific frame, and then open the file."

is inappropriate because the function nowhere does what you say here.

 > I expected display-buffer to execute the display-buffer-function first
 > in time (e.g., before executing find-file), but that is not the case.

I'm afraid you're confusing things here.  `display-buffer' does execute
`display-buffer-function' first but its arguments get evaluated before
its body.  This is something you certainly want too because how would
`display-buffer' otherwise know the buffer it is supposed to display?

 > If the purpose of display-buffer is not to execute the
 > display-buffer-function first in time (e.g., before executing
 > find-file), then I made an erroneous assumption regarding the reason
 > for using display-buffer.

I suppose you made the erroneous assumption that `find-file' does not
display the file's buffer.  That's why I suggested to use
`find-file-noselect' instead.  Anyway, using `display-buffer-function'
is deprecated since Emacs 24.3 and was hardly used in previous versions.
What you probably want to do is to customize `display-buffer-alist'
instead.

martin