Emacs Lisp - opening a new window

I would like to write an emacs lisp function that will write the output to a window other than the current one. He must create a new window if only the current exists, and otherwise he must use the existing one. This is similar to what happens when you start Chf (describe the function), and the description appears in another window. What is the best way to do this?

+4
source share
1 answer

See display-buffer :

display-buffer - interactive compiled Lisp function in `window.el '.

It is associated with Cx 4 Co.

(display-buffer buffer-or-name & optional frame of this window)

Make a buffer buffer or name in some window, but do not select it. buffer-or-name must be a buffer or the name of an existing buffer. Return the window selected to display buffer-or-name or nil, if no such window is found.

The optional argument not-this-window non-nil means that the buffer is displayed in a window other than the one selected, even if it is already displayed in the selected window.

The optional argument frame indicates which is based on whether the specified buffer is already displayed. If the buffer is already displayed in a window on one of these frames, simply return this window. Possible frame values:

`visible '- view windows on all visible frames.

0 - view windows in all visible or selected frames.

t - consider windows in all frames.

A specific frame - we will consider windows on only this frame.

nil - view the windows on the selected frame (in fact, the last frame without a minibuffer). If, however, either display-buffer-reuse-frames' or pop-up-frames' is not nil (non-nil and not just for text. Terminal), consider all visible or selected frames.

Or you can use pop-to-buffer if you want this buffer to be selected (which seems like you don't like it) or with-output-to-temp-buffer , which binds the standard-output that will be sent to the temporary buffer - read the documentation for more details (tooltip for Michael ).

+9
source

All Articles