[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [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 &optional norecord

This function makes window the selected window. The cursor then appears in window (on redisplay). Unless window was already selected, select-window makes window's buffer the current buffer.

Normally window's selected buffer is moved to the front of the buffer list, but if norecord is non-nil, the buffer list order is unchanged.

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 frame, as well as the selected window of each frame, executes forms in sequence, then restores the earlier selected frame and windows. It also saves and restores the current buffer. It returns the value of the last form in forms.

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. If the previously selected window of some frame is no longer live at the time of exit from forms, that frame's selected window is left alone. If the previously selected window is no longer live, then whatever window is selected at the end of forms remains selected.

Macro: with-selected-window window forms…

This macro selects window (without changing the buffer list), executes forms in sequence, then restores the previously selected window and current buffer. It is just like save-selected-window, except that it explicitly selects window, also without altering the buffer list sequence.

The following functions choose one of the windows on the screen, offering various criteria for the choice.

Function: get-lru-window &optional frame dedicated

This function returns the window least recently “used” (that is, selected). If any full-width windows are present, it only considers these. 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. Dedicated windows are never candidates unless the dedicated argument is non-nil, so if all existing windows are dedicated, the value is nil.

The argument frame controls which windows are considered.

Function: get-largest-window &optional frame dedicated

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. Dedicated windows are never candidates unless the dedicated argument is non-nil, so if all existing windows are dedicated, the value is nil.

If there are two candidate windows of the same size, this function prefers the one that comes 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 (voir la section Cyclic Ordering of Windows), calling predicate on each 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 Cyclic Ordering of Windows, for details.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 13 Octobre 2007 en utilisant texi2html 1.78.