Next: , Previous: Recombining Windows, Up: Windows

28.8 Selecting Windows

— Function: select-window window &optional norecord

This function makes window the selected window and the window selected within its frame (see Basic Windows) and selects that frame. window must be a live window. This function also makes window's buffer (see Buffers and Windows) current and sets that buffer's value of point to the value of window-point (see Window Point) in window. The return value is window.

By default, this function also moves window's buffer to the front of the buffer list (see The Buffer List), and makes window the most recently selected window. However, if the optional argument norecord is non-nil, these additional actions are omitted.

The sequence of calls to select-window with a non-nil norecord argument determines an ordering of windows by their selection time. The function get-lru-window can be used to retrieve the least recently selected live window (see Cyclic Window Ordering).

— 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 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. The current buffer is restored if and only if it is still live when exiting forms.

This macro changes neither the ordering of recently selected windows nor the buffer list.

— Macro: with-selected-window window forms...

This macro selects window, executes forms in sequence, then restores the previously selected window and current buffer. The ordering of recently selected windows and the buffer list remain unchanged unless you deliberately change them within forms; for example, by calling select-window with argument norecord nil.

This macro does not change the order of recently selected windows or the buffer list.

— Function: frame-selected-window &optional frame

This function returns the window on frame that is selected within that frame. frame should be a live frame; if omitted or nil, it defaults to the selected frame.

— Function: set-frame-selected-window frame window &optional norecord

This function makes window the window selected within the frame frame. frame should be a live frame; if omitted or nil, it defaults to the selected frame. window should be a live window; if omitted or nil, it defaults to the selected window.

If frame is the selected frame, this makes window the selected window.

If the optional argument norecord is non-nil, this function does not alter the list of most recently selected windows, nor the buffer list.