Next: , Previous: Creating Frames, Up: Frames

29.2 Multiple Terminals

Emacs represents each terminal as a terminal object data type (see Terminal Type). On GNU and Unix systems, Emacs can use multiple terminals simultaneously in each session. On other systems, it can only use a single terminal. Each terminal object has the following attributes:

There is no primitive for creating terminal objects. Emacs creates them as needed, such as when you call make-frame-on-display (described below).

— Function: terminal-name &optional terminal

This function returns the file name of the device used by terminal. If terminal is omitted or nil, it defaults to the selected frame's terminal. terminal can also be a frame, meaning that frame's terminal.

— Function: terminal-list

This function returns a list of all live terminal objects.

— Function: get-device-terminal device

This function returns a terminal whose device name is given by device. If device is a string, it can be either the file name of a terminal device, or the name of an X display of the form ‘host:server.screen’. If device is a frame, this function returns that frame's terminal; nil means the selected frame. Finally, if device is a terminal object that represents a live terminal, that terminal is returned. The function signals an error if its argument is none of the above.

— Function: delete-terminal &optional terminal force

This function deletes all frames on terminal and frees the resources used by it. It runs the abnormal hook delete-terminal-functions, passing terminal as the argument to each function.

If terminal is omitted or nil, it defaults to the selected frame's terminal. terminal can also be a frame, meaning that frame's terminal.

Normally, this function signals an error if you attempt to delete the sole active terminal, but if force is non-nil, you are allowed to do so. Emacs automatically calls this function when the last frame on a terminal is deleted (see Deleting Frames).

— Variable: delete-terminal-functions

An abnormal hook run by delete-terminal. Each function receives one argument, the terminal argument passed to delete-terminal. Due to technical details, the functions may be called either just before the terminal is deleted, or just afterwards.

A few Lisp variables are terminal-local; that is, they have a separate binding for each terminal. The binding in effect at any time is the one for the terminal that the currently selected frame belongs to. These variables include default-minibuffer-frame, defining-kbd-macro, last-kbd-macro, and system-key-alist. They are always terminal-local, and can never be buffer-local (see Buffer-Local Variables).

On GNU and Unix systems, each X display is a separate graphical terminal. When Emacs is started from within the X window system, it uses the X display specified by the DISPLAY environment variable, or by the ‘--display’ option (see Initial Options). Emacs can connect to other X displays via the command make-frame-on-display. Each X display has its own selected frame and its own minibuffer windows; however, only one of those frames is “the selected frame” at any given moment (see Input Focus). Emacs can even connect to other text terminals, by interacting with the emacsclient program. See Emacs Server.

A single X server can handle more than one display. Each X display has a three-part name, ‘host:server.screen’. The first two parts, host and server, identify the X server; the third part, screen, identifies a screen number on that X server. When you use two or more screens belonging to one server, Emacs knows by the similarity in their names that they share a single keyboard.

On some “multi-monitor” setups, a single X display outputs to more than one physical monitor. Currently, there is no way for Emacs to distinguish between the different physical monitors.

— Command: make-frame-on-display display &optional parameters

This function creates and returns a new frame on display, taking the other frame parameters from the alist parameters. display should be the name of an X display (a string).

Before creating the frame, this function ensures that Emacs is “set up” to display graphics. For instance, if Emacs has not processed X resources (e.g., if it was started on a text terminal), it does so at this time. In all other respects, this function behaves like make-frame (see Creating Frames).

— Function: x-display-list

This function returns a list that indicates which X displays Emacs has a connection to. The elements of the list are strings, and each one is a display name.

— Function: x-open-connection display &optional xrm-string must-succeed

This function opens a connection to the X display display, without creating a frame on that display. Normally, Emacs Lisp programs need not call this function, as make-frame-on-display calls it automatically. The only reason for calling it is to check whether communication can be established with a given X display.

The optional argument xrm-string, if not nil, is a string of resource names and values, in the same format used in the .Xresources file. See X Resources. These values apply to all Emacs frames created on this display, overriding the resource values recorded in the X server. Here's an example of what this string might look like:

          "*BorderWidth: 3\n*InternalBorder: 2\n"

If must-succeed is non-nil, failure to open the connection terminates Emacs. Otherwise, it is an ordinary Lisp error.

— Function: x-close-connection display

This function closes the connection to display display. Before you can do this, you must first delete all the frames that were open on that display (see Deleting Frames).