Next: , Previous: , Up: Windows   [Contents][Index]


38.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 &optional device

This function returns the selected window. This is the window in which the cursor appears and to which many commands apply. Each separate device can have its own selected window, which is remembered as focus changes from device to device. Optional argument device specifies which device to return the selected window for, and defaults to the selected device.

Function: select-window window &optional norecord

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.

If optional argument norecord is non-nil then the global and per-frame buffer orderings are not modified, as by the function record-buffer.

The return value is window.

(setq w (next-window))
(select-window w)
     ⇒ #<window 65 on windows.texi>
Special Form: save-selected-window forms…

This special form 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 which-frames which-devices

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.

By default, only the windows in the selected frame are considered. The optional argument which-frames changes this behavior. Here are the possible values and their meanings:

nil

Consider all the windows in the selected windows’s frame, plus the minibuffer used by that frame even if it lies in some other frame.

t

Consider all windows in all existing frames.

visible

Consider all windows in all visible frames. (To get useful results, you must ensure window is in a visible frame.)

0

Consider all windows in all visible or iconified frames.

frame

Consider all windows on frame frame.

anything else

Consider precisely the windows in the selected window’s frame, and no others.

The optional argument which-devices further clarifies on which devices to search for frames as specified by which-frames. This value is only meaningful if which-frames is non-nil.

nil

Consider all devices on the selected console.

device

Consider only the one device device.

console

Consider all devices on console.

device-type

Consider all devices with device type device-type.

window-system

Consider all devices on window system consoles.

anything else

Consider all devices without restriction.

Function: get-largest-window &optional which-frames which-devices

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 remaining arguments control which set of windows are considered. See next-window, above.


Next: , Previous: , Up: Windows   [Contents][Index]