23.10 Multiple Displays

A single Emacs can talk to more than one X display. Initially, Emacs uses just one display—the one specified with the DISPLAY environment variable or with the ‘--display’ option (see Initial Options). To connect to another display, use the command make-frame-on-display:

M-x make-frame-on-display RET display RET

Create a new frame on display display.

A single X server can handle more than one screen. When you open frames on two screens belonging to one server, Emacs knows they share a single keyboard, and it treats all the commands arriving from these screens as a single stream of input.

When you open frames on different X servers, Emacs makes a separate input stream for each server. Each server also has its own selected frame. The commands you enter with a particular X server apply to that server’s selected frame.

On multi-monitor displays it is possible to use the command make-frame-on-monitor:

M-x make-frame-on-monitor RET monitor RET

Create a new frame on monitor monitor whose screen area is a part of the current display.

23.10.1 Single-keyboard mode

Each display has an associated keyboard. Normally, Emacs assumes that these keyboards are physically distinct, so that someone could be typing on one keyboard and someone else typing on another, into different frames on different terminals. In certain situations, however, Emacs enters single-keyboard mode, in which input from all but one keyboard is blocked. This prevents keys typed on one keyboard from interfering with an operation started on another keyboard. The main operation to which this applies is entering a recursive edit (see Recursive Editing Levels), which includes all minibuffer prompting (see Using the Minibuffer).

Single-keyboard mode can be inconvenient when there are distinct displays and so distinct keyboards, but only one user and one physical keyboard in control of Emacs. This can happen with X forwarding: with a remote Emacs daemon and multiple frames created with a command like ssh -X daemon-host emacsclient -c, then from the remote Emacs daemon’s point of view there is one terminal and one keyboard per ssh -X daemon-host command invoked, but in fact a single local X server displays all frames, and there is just one physical keyboard.

In this situation, you may prefer to have the different frames behave as though they had been created with C-x 5 2 (see Creating Frames). In that case, starting a recursive edit in one frame does not mean that keyboard input into other frames is blocked. Customize the variable multiple-terminals-merge-keyboards to a non-nil value to achieve this.