help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: frames dedicated to buffers, or, always see specific buffers in a sp


From: João Távora
Subject: Re: frames dedicated to buffers, or, always see specific buffers in a specific frame
Date: Fri, 12 Apr 2013 13:12:55 +0100

On Fri, Apr 12, 2013 at 10:28 AM, martin rudalics <rudalics@gmx.at> wrote:

> `switch-to-buffer' uses `pop-to-buffer' to make sure the window
> displaying the buffer is selected.  You use `display-buffer' which
> doesn't necessarily make the window selected - IIUC you rely on the
> window manager to select the window.

yes, you understand correctly.

> Other from that I don't see anything hackish with your approach if the
> idea is to make `switch-to-buffer' do what you want when it's called
> from other code (which ideally should not happen).  In this case you
> might also want to advice `switch-to-buffer-other-window' accordingly.

I do want that precisely. `display-buffer-alist' apparently allows me (a LOT of)
control how `display-buffer' but not when it is called. The advice is because I
want ibuffer and ido to work with this as well.

The hackish part is was also that I call the predicate twice, but I can simplify
that...

(defadvice switch-to-buffer (around joaot/browse-buffer-maybe activate)
  (if (joaot/browse-buffer-p buffer-or-name nil)
      (let ((display-buffer-alist `(("" .
(joaot/browse-buffer-in-special-frame . nil)))))
        (display-buffer buffer-or-name))
    ad-do-it))

However, I still have to have to set `display-buffer-alist' globally for those
functions who call `display-buffer' directly, like `describe-function' does for
"*Help*" buffers, for example.

(setq display-buffer-alist
      `((joaot/browse-buffer-p . (joaot/browse-buffer-in-special-frame . nil))))

I'm quite happy with this functionally, and find this feature is quite useful to
keep focus on one frame, but be able to look at a secondary frame on a second
monitor for reference and only switching to it occasionally.

Ideally I would want anywthing with the meaning "switch to some buffer" (be it
`pop-to-buffer', `switch-to-buffer-other-window`, `display-buffer`, etc...) to
be be hookable at some common point, much as is already done with `display-
buffer'.

Or alternatively, and maybe simpler, if `display-buffer' is so powerful, why
can't it be used by `switch-to-buffer' and friends? I know `diplay-buffer''s
semantics are "display without selecting", but can't those be relaxed and the
"without selecting" part be just the default?

Another, distinct, small problem persists, and I suspect it has to do with not
understanding what the various alists are in the documentation of
`display-buffer'
and `display-buffer-alist'...

Specifically, how can I prevent `display-buffer' from stopping at one of
the actions that I specify in `display-buffer-alist'? For example,
`describe-function' shows me the buffer on the secondary "browse" frame" but
still keeps the current pop-to-frame behaviour. I'm going to have a look at
`display-buffer-overriding-alist', maybe that will do it.

Thanks
--
João Távora



reply via email to

[Prev in Thread] Current Thread [Next in Thread]