How do I programmatically display a buffer in a window other than the current
, similar to the behaviour of Emacs' grep next-error
. I want this to work in the most recent Emacs 24.1. Note that this logic recently was modified in Emacs trunk and merged into a single function display-buffer
with quite complicated calling semantics. I find it hard to figure out how use display-buffer
even after having read the help on it several times. Why isn't there a wrapper function for this such as display-buffer-other-window
?
The lengthy docstring to display-buffer
includes the following:
The ACTION argument to `display-buffer' can also have a non-nil and non-list value. This means to display the buffer in a window other than the selected one, even if it is already displayed in the selected window. If called interactively with a prefix argument, ACTION is t.
Therefore to display a specified buffer in a window other than the current, you can use:
(display-buffer BUFFER-OR-NAME t)
The Emacs sources gave me the answer
(pop-to-buffer BUFFER 'other-window)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With