30 Frames

A frame is a screen object that contains one or more Emacs windows (see Windows). It is the kind of object called a “window” in the terminology of graphical environments; but we can’t call it a “window” here, because Emacs uses that word in a different way. In Emacs Lisp, a frame object is a Lisp object that represents a frame on the screen. See Frame Type.

A frame initially contains a single main window and/or a minibuffer window; you can subdivide the main window vertically or horizontally into smaller windows. See Splitting Windows.

A terminal is a display device capable of displaying one or more Emacs frames. In Emacs Lisp, a terminal object is a Lisp object that represents a terminal. See Terminal Type.

There are two classes of terminals: text terminals and graphical terminals. Text terminals are non-graphics-capable displays, including xterm and other terminal emulators. On a text terminal, each Emacs frame occupies the terminal’s entire screen; although you can create additional frames and switch between them, the terminal only shows one non-child frame at a time. This frame is referred to as the top frame of that terminal and can be retrieved with the function tty-top-frame described below. A top frame may have child frames (see Child Frames), which will be shown together with it, but it cannot be a child frame itself.

Graphical terminals, on the other hand, are managed by graphical display systems such as the X Window System, which allow Emacs to show multiple frames simultaneously on the same display.

On GNU and Unix systems, you can create additional frames on any available terminal, within a single Emacs session, regardless of whether Emacs was started on a text or graphical terminal. Emacs can display on both, graphical and text terminals, simultaneously. This comes in handy, for instance, when you connect to the same session from several remote locations. See Multiple Terminals.

Function: framep object

This predicate returns a non-nil value if object is a frame, and nil otherwise. For a frame, the value indicates which kind of display the frame uses:

t

The frame is displayed on a text terminal.

x

The frame is displayed on an X graphical terminal.

w32

The frame is displayed on a MS-Windows graphical terminal.

ns

The frame is displayed on a GNUstep or Macintosh Cocoa graphical terminal.

pc

The frame is displayed on an MS-DOS terminal.

haiku

The frame is displayed using the Haiku Application Kit.

pgtk

The frame is displayed using pure GTK facilities.

android

The frame is displayed on an Android device.

Function: frame-terminal &optional frame

This function returns the terminal object that displays frame. If frame is nil or unspecified, it defaults to the selected frame (see Input Focus).

Function: terminal-live-p object

This predicate returns a non-nil value if object is a terminal that is live (i.e., not deleted), and nil otherwise. For live terminals, the return value indicates what kind of frames are displayed on that terminal; the list of possible values is the same as for framep above.

Function: frame-initial-p &optional frame

This predicate returns non-nil if frame is or holds the initial text frame that is used internally during daemon mode (see daemon in The GNU Emacs Manual), batch mode (see Batch Mode), and the early stages of startup (see Summary: Sequence of Actions at Startup). Interactive and graphical programs, for instance, can use this predicate to avoid operating on the initial frame, which is never displayed.

If frame is a terminal, this function returns non-nil if frame holds the initial frame. If frame is omitted or nil, it defaults to the selected one.

On a graphical terminal we distinguish two types of frames: A normal top-level frame is a frame whose window-system window is a child of the window-system’s root window for that terminal. A child frame is a frame whose window-system window is the child of the window-system window of another Emacs frame. See Child Frames.

On a text terminal you can get its top frame with the following function:

Function: tty-top-frame &optional terminal

This function returns the top frame on terminal. terminal should be a terminal object, a frame (meaning that frame’s terminal), or nil (meaning the selected frame’s terminal). If it does not refer to a text terminal, the return value is nil. A top frame must be a root frame, which means it cannot be a child frame itself (see Child Frames), but may have an arbitrary number of child frames descending from it.

Function: frame-id &optional frame

This function returns the unique identifier of a frame, an integer, assigned to frame. If frame is nil or unspecified, it defaults to the selected frame (see Input Focus). This can be used to unambiguously identify a frame in a context where you do not or cannot use a frame object.

A frame undeleted using undelete-frame will retain its identifier. A frame cloned using clone-frame will not retain its original identifier. See Frame Commands in the Emacs Manual.

Frame identifiers are not persisted using the desktop library (see Desktop Save Mode), frameset-to-register, or frameset-save, and each of their restored frames will bear a new unique id.