GNU Emacs Lisp Reference Manual
25.4: Selecting Windows
When a window is selected, the buffer in the window becomes the current
buffer, and the cursor will appear in it.
- Function: selected-window
-
This function returns the selected window. This is the window in
which the cursor appears and to which many commands apply.
- Function: select-window
window
-
This function makes window the selected window. The cursor then
appears in window (on redisplay). The buffer being displayed in
window is immediately designated the current buffer.
The return value is window.
-
(setq w (next-window))
(select-window w)
=> #<window 65 on windows.texi>
- Macro: save-selected-window
forms...
-
This macro records the selected window, executes forms
in sequence, then restores the earlier selected window.
It does not save or restore anything about the sizes, arrangement
or contents of windows; therefore, if the forms change them,
the changes are permanent.
The following functions choose one of the windows on the screen,
offering various criteria for the choice.
- Function: get-lru-window
&optional frame
-
This function returns the window least recently ``used'' (that is,
selected). The selected window is always the most recently used window.
The selected window can be the least recently used window if it is the
only window. A newly created window becomes the least recently used
window until it is selected. A minibuffer window is never a candidate.
The argument frame controls which windows are considered.
-
If it is
nil, consider windows on the selected frame.
-
If it is
t, consider windows on all frames.
-
If it is
visible, consider windows on all visible frames.
-
If it is 0, consider windows on all visible or iconified frames.
-
If it is a frame, consider windows on that frame.
- Function: get-largest-window
&optional frame
-
This function returns the window with the largest area (height times
width). If there are no side-by-side windows, then this is the window
with the most lines. A minibuffer window is never a candidate.
If there are two windows of the same size, then the function returns
the window that is first in the cyclic ordering of windows (see
following section), starting from the selected window.
The argument frame controls which set of windows are
considered. See get-lru-window, above.