Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Buffer in Other Window in Recent Emacs

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?

like image 596
Nordlöw Avatar asked May 09 '12 10:05

Nordlöw


Video Answer


2 Answers

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)
like image 180
phils Avatar answered Sep 26 '22 19:09

phils


The Emacs sources gave me the answer

(pop-to-buffer BUFFER 'other-window)
like image 35
Nordlöw Avatar answered Sep 23 '22 19:09

Nordlöw