Skip to main content

29.8 Finding All Frames

function frame-list​

This function returns a list of all the live frames, i.e., those that have not been deleted. It is analogous to buffer-list for buffers, and includes frames on all terminals. The list that you get is newly created, so modifying the list doesn’t have any effect on the internals of Emacs.

function visible-frame-list​

This function returns a list of just the currently visible frames. See Visibility of Frames. Frames on text terminals always count as visible, even though only the selected one is actually displayed.

function frame-list-z-order \&optional display​

This function returns a list of Emacs’ frames, in Z (stacking) order (see Raising and Lowering). The optional argument display specifies which display to poll. display should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame’s display. It returns nil if display contains no Emacs frame.

Frames are listed from topmost (first) to bottommost (last). As a special case, if display is non-nil and specifies a live frame, it returns the child frames of that frame in Z (stacking) order.

This function is not meaningful on text terminals.

function next-frame \&optional frame minibuf​

This function lets you cycle conveniently through all the frames on a specific terminal from an arbitrary starting point. It returns the frame following frame, in the list of all live frames, on frame’s terminal. The argument frame must specify a live frame and defaults to the selected frame. It never returns a frame whose no-other-frame parameter (see Frame Interaction Parameters) is non-nil.

The second argument, minibuf, says which frames to consider:

nil​

Exclude minibuffer-only frames.

visible​

Consider all visible frames.

0​

Consider all visible or iconified frames.

a window​

Consider only the frames using that particular window as their minibuffer.

anything else​

Consider all frames.

function previous-frame \&optional frame minibuf​

Like next-frame, but cycles through all frames in the opposite direction.

See also next-window and previous-window, in Cyclic Window Ordering.