[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

28.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, unless it is no longer alive.

This macro does not save or restore anything about the sizes, arrangement or contents of windows; therefore, if the forms change them, the change persists.

Each frame, at any time, has a window selected within the frame. This macro saves only the selected window; it does not save anything about other frames. If the forms select some other frame and alter the window selected within it, the change persists.

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.

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 to consider. See get-lru-window, above.

Function: get-window-with-predicate predicate &optional minibuf all-frames default
This function returns a window satisfying predicate. It cycles through all visible windows using walk-windows (see section 28.5 Cyclic Ordering of Windows), calling predicate on each one one of them with that window as its argument. The function returns the first window for which predicate returns a non-nil value; if that never happens, it returns default.

The optional arguments minibuf and all-frames specify the set of windows to include in the scan. See the description of next-window in 28.5 Cyclic Ordering of Windows, for details.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on May 2, 2002 using texi2html