"Fossies" - the Fresh Open Source Software Archive

Member "emacs-26.1/doc/emacs/frames.texi" (25 May 2018, 58145 Bytes) of package /linux/misc/emacs-26.1.tar.xz:

Caution: As a special service "Fossies" has tried to format the requested Texinfo source page into HTML format but that may be not always succeeeded perfectly. Alternatively you can here view or download the uninterpreted Texinfo source code. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the latest Fossies "Diffs" side-by-side code changes report for "frames.texi": 25.3_vs_26.1.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1 Frames and Graphical Displays

When Emacs is started on a graphical display, e.g., on the X Window System, it occupies a graphical system-level display region. In this manual, we call this a frame, reserving the word “window” for the part of the frame used for displaying a buffer. A frame initially contains one window, but it can be subdivided into multiple windows (@pxref{Windows}). A frame normally also contains a menu bar, tool bar, and echo area.

You can also create additional frames (see section Creating Frames). All frames created in the same Emacs session have access to the same underlying buffers and other data. For instance, if a buffer is being shown in more than one frame, any changes made to it in one frame show up immediately in the other frames too.

Typing C-x C-c closes all the frames on the current display, and ends the Emacs session if it has no frames open on any other displays (@pxref{Exiting}). To close just the selected frame, type C-x 5 0 (that is zero, not o).

This chapter describes Emacs features specific to graphical displays (particularly mouse commands), and features for managing multiple frames. On text terminals, many of these features are unavailable. However, it is still possible to create multiple frames on text terminals; such frames are displayed one at a time, filling the entire terminal screen (see section Non-Window Terminals). It is also possible to use the mouse on some text terminals (see section Using a Mouse in Text Terminals, for doing so on GNU and Unix systems; and @pxref{MS-DOS Mouse}, for doing so on MS-DOS). Menus are supported on all text terminals.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 Mouse Commands for Editing


Move point to where you click (mouse-set-point).


Activate the region around the text selected by dragging, and put the text in the primary selection (mouse-set-region).


Move point to where you click, and insert the contents of the primary selection there (mouse-yank-primary).


If the region is active, move the nearer end of the region to the click position; otherwise, set mark at the current value of point and point at the click position. Save the resulting region in the kill ring; on a second click, kill it (mouse-save-then-kill).

The most basic mouse command is mouse-set-point, which is invoked by clicking with the left mouse button, mouse-1, in the text area of a window. This moves point to the position where you clicked. If that window was not the selected window, it becomes the selected window. You can also activate a region by double-clicking mouse-1 (see section Mouse Commands for Words and Lines).

Normally, if the frame you clicked in was not the selected frame, it is made the selected frame, in addition to selecting the window and setting the cursor. On the X Window System, you can change this by setting the variable x-mouse-click-focus-ignore-position to t. In that case, the initial click on an unselected frame just selects the frame, without doing anything else; clicking again selects the window and sets the cursor position.

Holding down mouse-1 and dragging the mouse over a stretch of text activates the region around that text (mouse-set-region), placing the mark where you started holding down the mouse button, and point where you release it (@pxref{Mark}). In addition, the text in the region becomes the primary selection (@pxref{Primary Selection}).

If you change the variable mouse-drag-copy-region to a non-nil value, dragging the mouse over a stretch of text also adds the text to the kill ring. The default is nil.

If you move the mouse off the top or bottom of the window while dragging, the window scrolls at a steady rate until you move the mouse back into the window. This way, you can select regions that don’t fit entirely on the screen. The number of lines scrolled per step depends on how far away from the window edge the mouse has gone; the variable mouse-scroll-min-lines specifies a minimum step size.

Clicking with the middle mouse button, mouse-2, moves point to the position where you clicked and inserts the contents of the primary selection (mouse-yank-primary). @xref{Primary Selection}. This behavior is consistent with other X applications. Alternatively, you can rebind mouse-2 to mouse-yank-at-click, which performs a yank at the position you click.

If you change the variable mouse-yank-at-point to a non-nil value, mouse-2 does not move point; it inserts the text at point, regardless of where you clicked or even which of the frame’s windows you clicked on. This variable affects both mouse-yank-primary and mouse-yank-at-click.

Clicking with the right mouse button, mouse-3, runs the command mouse-save-then-kill. This performs several actions depending on where you click and the status of the region:

The mouse-save-then-kill command also obeys the variable mouse-drag-copy-region (described above). If the value is non-nil, then whenever the command sets or adjusts the active region, the text in the region is also added to the kill ring. If the latest kill ring entry had been added the same way, that entry is replaced rather than making a new entry.

Whenever you set the region using any of the mouse commands described above, the mark will be deactivated by any subsequent unshifted cursor motion command, in addition to the usual ways of deactivating the mark. @xref{Shift Selection}.

Some mice have a “wheel” which can be used for scrolling. Emacs supports scrolling windows with the mouse wheel, by default, on most graphical displays. To toggle this feature, use M-x mouse-wheel-mode. The variables mouse-wheel-follow-mouse and mouse-wheel-scroll-amount determine where and by how much buffers are scrolled. The variable mouse-wheel-progressive-speed determines whether the scroll speed is linked to how fast you move the wheel.

Emacs can also support horizontal scrolling if your mouse’s wheel can be tilted. This feature is off by default; the variable mouse-wheel-tilt-scroll turns it on. If you’d like to reverse the direction of horizontal scrolling, customize the variable mouse-wheel-flip-direction to a non-nil value.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.2 Mouse Commands for Words and Lines

These variants of mouse-1 select entire words or lines at a time. Emacs activates the region around the selected text, which is also copied to the kill ring.


Select the text around the word or character which you click on.

Double-clicking on a character with symbol syntax (such as underscore, in C mode) selects the symbol surrounding that character. Double-clicking on a character with open- or close-parenthesis syntax selects the parenthetical grouping which that character starts or ends. Double-clicking on a character with string-delimiter syntax (such as a single-quote or double-quote in C) selects the string constant (Emacs uses heuristics to figure out whether that character is the beginning or the end of it).

Double-clicking on the beginning of a parenthetical grouping or beginning string-delimiter moves point to the end of the region, scrolling the buffer display forward if necessary to show the new location of point. Double-clicking on the end of a parenthetical grouping or end string-delimiter keeps point at the end of the region by default, so the beginning of the region will not be visible if it is above the top of the window; setting the user option mouse-select-region-move-to-beginning to non-nil changes this to move point to the beginning of the region, scrolling the display backward if necessary.


Select the text you drag across, in units of whole words.


Select the line you click on.


Select the text you drag across, in units of whole lines.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.3 Following References with the Mouse

Some Emacs buffers include buttons, or hyperlinks: pieces of text that perform some action (e.g., following a reference) when activated (e.g., by clicking on them). Usually, a button’s text is visually highlighted: it is underlined, or a box is drawn around it. If you move the mouse over a button, the shape of the mouse cursor changes and the button lights up. If you change the variable mouse-highlight to nil, Emacs disables this highlighting.

You can activate a button by moving point to it and typing <RET>, or by clicking either mouse-1 or mouse-2 on the button. For example, in a Dired buffer, each file name is a button; activating it causes Emacs to visit that file (@pxref{Dired}). In a ‘*Compilation*’ buffer, each error message is a button, and activating it visits the source code for that error (@pxref{Compilation}).

Although clicking mouse-1 on a button usually activates the button, if you hold the mouse button down for a period of time before releasing it (specifically, for more than 450 milliseconds), then Emacs moves point where you clicked, without activating the button. In this way, you can use the mouse to move point over a button without activating it. Dragging the mouse over or onto a button has its usual behavior of setting the region, and does not activate the button.

You can change how mouse-1 applies to buttons by customizing the variable mouse-1-click-follows-link. If the value is a positive integer, that determines how long you need to hold the mouse button down for, in milliseconds, to cancel button activation; the default is 450, as described in the previous paragraph. If the value is nil, mouse-1 just sets point where you clicked, and does not activate buttons. If the value is double, double clicks activate buttons but single clicks just set point.

Normally, mouse-1 on a button activates the button even if it is in a non-selected window. If you change the variable mouse-1-click-in-non-selected-windows to nil, mouse-1 on a button in an unselected window moves point to the clicked position and selects that window, without activating the button.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.4 Mouse Clicks for Menus

Several mouse clicks with the <Ctrl> and <SHIFT> modifiers bring up menus.


This menu is for selecting a buffer.

The MSB (“mouse select buffer”) global minor mode makes this menu smarter and more customizable. @xref{Buffer Menus}.


This menu contains entries for examining faces and other text properties, and well as for setting them (the latter is mainly useful when editing enriched text; @pxref{Enriched Text}).


This menu is mode-specific. For most modes if Menu-bar mode is on, this menu has the same items as all the mode-specific menu-bar menus put together. Some modes may specify a different menu for this button. If Menu Bar mode is off, this menu contains all the items which would be present in the menu bar—not just the mode-specific ones—so that you can access them without having to display the menu bar.


This menu is for changing the default face within the window’s buffer. @xref{Text Scale}.

Some graphical applications use mouse-3 for a mode-specific menu. If you prefer mouse-3 in Emacs to bring up such a menu instead of running the mouse-save-then-kill command, rebind mouse-3 by adding the following line to your init file (@pxref{Init Rebinding}):

(global-set-key [mouse-3] 'mouse-popup-menubar-stuff)

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.5 Mode Line Mouse Commands

You can use mouse clicks on window mode lines to select and manipulate windows.

Some areas of the mode line, such as the buffer name, and major and minor mode names, have their own special mouse bindings. These areas are highlighted when you hold the mouse over them, and information about the special bindings will be displayed (see section Tooltips). This section’s commands do not apply in those areas.


mouse-1 on a mode line selects the window it belongs to. By dragging mouse-1 on the mode line, you can move it, thus changing the height of the windows above and below. Changing heights with the mouse in this way never deletes windows, it just refuses to make any window smaller than the minimum height.


mouse-2 on a mode line expands that window to fill its frame.


mouse-3 on a mode line deletes the window it belongs to. If the frame has only one window, it does nothing.


C-mouse-2 on a mode line splits that window, producing two side-by-side windows with the boundary running through the click position (@pxref{Split Window}).

Furthermore, by clicking and dragging mouse-1 on the divider between two side-by-side mode lines, you can move the vertical boundary to the left or right.

Note that resizing windows is affected by the value of window-resize-pixelwise, see @ref{Split Window}.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.6 Creating Frames

The prefix key C-x 5 is analogous to C-x 4. Whereas each C-x 4 command pops up a buffer in a different window in the selected frame (@pxref{Pop Up Window}), the C-x 5 commands use a different frame. If an existing visible or iconified (a.k.a. “minimized”, see Visibility of Frames in The Emacs Lisp Reference Manual) frame already displays the requested buffer, that frame is raised and deiconified (“un-minimized”); otherwise, a new frame is created on the current display terminal.

The various C-x 5 commands differ in how they find or create the buffer to select:

C-x 5 2

Create a new frame (make-frame-command).

C-x 5 b bufname <RET>

Select buffer bufname in another frame. This runs switch-to-buffer-other-frame.

C-x 5 f filename <RET>

Visit file filename and select its buffer in another frame. This runs find-file-other-frame. @xref{Visiting}.

C-x 5 d directory <RET>

Select a Dired buffer for directory directory in another frame. This runs dired-other-frame. @xref{Dired}.

C-x 5 m

Start composing a mail message in another frame. This runs compose-mail-other-frame. It is the other-frame variant of C-x m. @xref{Sending Mail}.

C-x 5 .

Find the definition of an identifier in another frame. This runs xref-find-definitions-other-frame, the multiple-frame variant of M-.. @xref{Xref}.

C-x 5 r filename <RET>

Visit file filename read-only, and select its buffer in another frame. This runs find-file-read-only-other-frame. @xref{Visiting}.

You can control the appearance and behavior of the newly-created frames by specifying frame parameters. See section Frame Parameters.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.7 Frame Commands

The following commands are used to delete and operate on frames:

C-x 5 0

Delete the selected frame (delete-frame). This signals an error if there is only one frame.


Minimize (or iconify) the selected Emacs frame (suspend-frame). @xref{Exiting}.

C-x 5 o

Select another frame, and raise it. If you repeat this command, it cycles through all the frames on your terminal.

C-x 5 1

Delete all frames on the current terminal, except the selected one.


Toggle the maximization state of the current frame. When a frame is maximized, it fills the screen.


Toggle full-screen mode for the current frame. (The difference between full-screen and maximized is normally that the former hides window manager decorations, giving slightly more screen space to Emacs itself.)

Note that with some window managers you may have to customize the variable frame-resize-pixelwise to a non-nil value in order to make a frame truly maximized or full-screen. This variable, when set to a non-nil value, in general allows resizing frames at pixel resolution, rather than in integral multiples of lines and columns.

The C-x 5 0 (delete-frame) command deletes the selected frame. However, it will refuse to delete the last frame in an Emacs session, to prevent you from losing the ability to interact with the Emacs session. Note that when Emacs is run as a daemon (@pxref{Emacs Server}), there is always a virtual frame that remains after all the ordinary, interactive frames are deleted. In this case, C-x 5 0 can delete the last interactive frame; you can use emacsclient to reconnect to the Emacs session.

The C-x 5 1 (delete-other-frames) command deletes all other frames on the current terminal (this terminal refers to either a graphical display, or a text terminal; see section Non-Window Terminals). If the Emacs session has frames open on other graphical displays or text terminals, those are not deleted.

The C-x 5 o (other-frame) command selects the next frame on the current terminal. If you are using Emacs on the X Window System with a window manager that selects (or gives focus to) whatever frame the mouse cursor is over, you have to change the variable focus-follows-mouse to t in order for this command to work properly. Then invoking C-x 5 o will also warp the mouse cursor to the chosen frame.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.8 Fonts

By default, Emacs displays text on graphical displays using a 10-point monospace font. There are several different ways to specify a different font:

To check what font you’re currently using, the C-u C-x = command can be helpful. It describes the character at point, and names the font that it’s rendered in.

On X, there are four different ways to express a font name. The first is to use a Fontconfig pattern. Fontconfig patterns have the following form:


Within this format, any of the elements in brackets may be omitted. Here, fontname is the family name of the font, such as ‘Monospace’ or ‘DejaVu Sans Mono’; fontsize is the point size of the font (one printer’s point is about 1/72 of an inch); and the ‘name=values’ entries specify settings such as the slant and weight of the font. Each values may be a single value, or a list of values separated by commas. In addition, some property values are valid with only one kind of property name, in which case the ‘name=’ part may be omitted.

Here is a list of common font properties:


One of ‘italic’, ‘oblique’, or ‘roman’.


One of ‘light’, ‘medium’, ‘demibold’, ‘bold’ or ‘black’.


Some fonts define special styles which are a combination of slant and weight. For instance, ‘Dejavu Sans’ defines the ‘book’ style, which overrides the slant and weight properties.


One of ‘condensed’, ‘normal’, or ‘expanded’.


One of ‘monospace’, ‘proportional’, ‘dual-width’, or ‘charcell’.

Here are some examples of Fontconfig patterns:

DejaVu Sans Mono:bold:italic

For a more detailed description of Fontconfig patterns, see the Fontconfig manual, which is distributed with Fontconfig and available online at https://fontconfig.org/fontconfig-user.html.

The second way to specify a font is to use a GTK font pattern. These have the syntax

fontname [properties] [fontsize]

where fontname is the family name, properties is a list of property values separated by spaces, and fontsize is the point size. The properties that you may specify for GTK font patterns are as follows:

Here are some examples of GTK font patterns:

Monospace 12
Monospace Bold Italic 12

The third way to specify a font is to use an XLFD (X Logical Font Description). This is the traditional method for specifying fonts under X. Each XLFD consists of fourteen words or numbers, separated by dashes, like this:


A wildcard character (‘*’) in an XLFD matches any sequence of characters (including none), and ‘?’ matches any single character. However, matching is implementation-dependent, and can be inaccurate when wildcards match dashes in a long name. For reliable results, supply all 14 dashes and use wildcards only within a field. Case is insignificant in an XLFD. The syntax for an XLFD is as follows:


The entries have the following meanings:


The name of the font manufacturer.


The name of the font family (e.g., ‘courier’).


The font weight—normally either ‘bold’, ‘medium’ or ‘light’. Some font names support other values.


The font slant—normally ‘r’ (roman), ‘i’ (italic), ‘o’ (oblique), ‘ri’ (reverse italic), or ‘ot’ (other). Some font names support other values.


The font width—normally ‘normal’, ‘condensed’, ‘semicondensed’, or ‘extended’. Some font names support other values.


An optional additional style name. Usually it is empty—most XLFDs have two hyphens in a row at this point. The style name can also specify a two-letter ISO-639 language name, like ‘ja’ or ‘ko’; some fonts that support CJK scripts have that spelled out in the style name part.


The font height, in pixels.


The font height on the screen, measured in tenths of a printer’s point. This is the point size of the font, times ten. For a given vertical resolution, height and pixels are proportional; therefore, it is common to specify just one of them and use ‘*’ for the other.


The horizontal resolution, in pixels per inch, of the screen for which the font is intended.


The vertical resolution, in pixels per inch, of the screen for which the font is intended. Normally the resolution of the fonts on your system is the right value for your screen; therefore, you normally specify ‘*’ for this and horiz.


This is ‘m’ (monospace), ‘p’ (proportional) or ‘c’ (character cell).


The average character width, in pixels, multiplied by ten.


The X font character set that the font depicts. (X font character sets are not the same as Emacs character sets, but they are similar.) You can use the xfontsel program to check which choices you have. Normally you should use ‘iso8859’ for registry and ‘1’ for encoding.

The fourth and final method of specifying a font is to use a font nickname. Certain fonts have shorter nicknames, which you can use instead of a normal font specification. For instance, ‘6x13’ is equivalent to


On X, Emacs recognizes two types of fonts: client-side fonts, which are provided by the Xft and Fontconfig libraries, and server-side fonts, which are provided by the X server itself. Most client-side fonts support advanced font features such as antialiasing and subpixel hinting, while server-side fonts do not. Fontconfig and GTK patterns match only client-side fonts.

You will probably want to use a fixed-width default font—that is, a font in which all characters have the same width. For Xft and Fontconfig fonts, you can use the fc-list command to list the available fixed-width fonts, like this:

fc-list :spacing=mono
fc-list :spacing=charcell

For server-side X fonts, you can use the xlsfonts program to list the available fixed-width fonts, like this:

xlsfonts -fn '*x*' | grep -E '^[0-9]+x[0-9]+'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-m*'
xlsfonts -fn '*-*-*-*-*-*-*-*-*-*-*-c*'

Any font with ‘m’ or ‘c’ in the spacing field of the XLFD is a fixed-width font. To see what a particular font looks like, use the xfd command. For example:

xfd -fn 6x13

displays the entire font ‘6x13’.

While running Emacs, you can also set the font of a specific kind of text (@pxref{Faces}), or a particular frame (see section Frame Parameters).

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.9 Speedbar Frames

The speedbar is a special frame for conveniently navigating in or operating on another frame. The speedbar, when it exists, is always associated with a specific frame, called its attached frame; all speedbar operations act on that frame.

Type M-x speedbar to create the speedbar and associate it with the current frame. To dismiss the speedbar, type M-x speedbar again, or select the speedbar and type q. (You can also delete the speedbar frame like any other Emacs frame.) If you wish to associate the speedbar with a different frame, dismiss it and call M-x speedbar from that frame.

The speedbar can operate in various modes. Its default mode is File Display mode, which shows the files in the current directory of the selected window of the attached frame, one file per line. Clicking on a non-directory visits that file in the selected window of the attached frame, and clicking on a directory shows that directory in the speedbar (see section Following References with the Mouse). Each line also has a box, ‘[+]’ or ‘<+>’, that you can click on to expand the contents of that item. Expanding a directory adds the contents of that directory to the speedbar display, underneath the directory’s own line. Expanding an ordinary file adds a list of the tags in that file to the speedbar display; you can click on a tag name to jump to that tag in the selected window of the attached frame. When a file or directory is expanded, the ‘[+]’ changes to ‘[-]’; you can click on that box to contract the item, hiding its contents.

You navigate through the speedbar using the keyboard, too. Typing <RET> while point is on a line in the speedbar is equivalent to clicking the item on the current line, and <SPC> expands or contracts the item. U displays the parent directory of the current directory. To copy, delete, or rename the file on the current line, type C, D, and R respectively. To create a new directory, type M.

Another general-purpose speedbar mode is Buffer Display mode; in this mode, the speedbar displays a list of Emacs buffers. To switch to this mode, type b in the speedbar. To return to File Display mode, type f. You can also change the display mode by clicking mouse-3 anywhere in the speedbar window (or mouse-1 on the mode-line) and selecting ‘Displays’ in the pop-up menu.

Some major modes, including Rmail mode, Info, and GUD, have specialized ways of putting useful items into the speedbar for you to select. For example, in Rmail mode, the speedbar shows a list of Rmail files, and lets you move the current message to another Rmail file by clicking on its ‘<M>’ box.

For more details on using and programming the speedbar, See Speedbar in Speedbar Manual.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.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 (@pxref{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.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.11 Frame Parameters

You can control the default appearance and behavior of all frames by specifying a default list of frame parameters in the variable default-frame-alist. Its value should be a list of entries, each specifying a parameter name and a value for that parameter. These entries take effect whenever Emacs creates a new frame, including the initial frame.

For example, you can add the following lines to your init file (@pxref{Init File}) to set the default frame width to 90 character columns, the default frame height to 40 character rows, and the default font to ‘Monospace-10’:

(add-to-list 'default-frame-alist '(width  . 90))
(add-to-list 'default-frame-alist '(height . 40))
(add-to-list 'default-frame-alist '(font . "Monospace-10"))

For a list of frame parameters and their effects, see Frame Parameters in The Emacs Lisp Reference Manual.

You can also specify a list of frame parameters which apply to just the initial frame, by customizing the variable initial-frame-alist.

If Emacs is compiled to use an X toolkit, frame parameters that specify colors and fonts don’t affect menus and the menu bar, since those are drawn by the toolkit and not directly by Emacs.

Note that if you are using the desktop library to save and restore your sessions, the frames to be restored are recorded in the desktop file, together with their parameters. When these frames are restored, the recorded parameters take precedence over the frame parameters specified by default-frame-alist and initial-frame-alist in your init file. @xref{Saving Emacs Sessions}, for how to avoid that.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.12 Scroll Bars

On graphical displays, there is a vertical scroll bar on the side of each Emacs window. Clicking mouse-1 on the scroll bar’s up and down buttons scrolls the window by one line at a time (but some toolkits allow you to customize the scroll bars to not have those buttons). Clicking mouse-1 above or below the scroll bar’s inner box scrolls the window by nearly the entire height of the window, like M-v and C-v respectively (@pxref{Moving Point}). (This, too, can behave differently with some toolkits.) Dragging the inner box scrolls continuously.

If Emacs is compiled on the X Window System without X toolkit support, the scroll bar behaves differently. Clicking mouse-1 anywhere on the scroll bar scrolls forward like C-v, while mouse-3 scrolls backward like M-v. Clicking mouse-2 in the scroll bar lets you drag the inner box up and down.

To toggle the use of vertical scroll bars, type M-x scroll-bar-mode. This command applies to all frames, including frames yet to be created. To toggle vertical scroll bars for just the selected frame, use the command M-x toggle-scroll-bar.

To control the use of vertical scroll bars at startup, customize the variable scroll-bar-mode. Its value should be either right (put scroll bars on the right side of windows), left (put them on the left), or nil (disable vertical scroll bars). By default, Emacs puts scroll bars on the right if it was compiled with GTK+ support on the X Window System, and on MS-Windows or macOS; Emacs puts scroll bars on the left if compiled on the X Window System without GTK+ support (following the old convention for X applications).

You can also use the X resource ‘verticalScrollBars’ to enable or disable the scroll bars (@pxref{Resources}). To control the scroll bar width, change the scroll-bar-width frame parameter (see Frame Parameters in The Emacs Lisp Reference Manual).

If you’re using Emacs on X (with GTK+ or Motif), you can customize the variable scroll-bar-adjust-thumb-portion to control overscrolling of the scroll bar, i.e., dragging the thumb down even when the end of the buffer is visible. If its value is non-nil, the scroll bar can be dragged downwards even if the end of the buffer is shown; if nil, the thumb will be at the bottom when the end of the buffer is shown. You cannot over-scroll when the entire buffer is visible.

The visual appearance of the scroll bars is controlled by the scroll-bar face. (Some toolkits, such as GTK+ and MS-Windows, ignore this face; the scroll-bar appearance there can only be customized system-wide, for GTK+ @pxref{GTK resources}).

On graphical frames, vertical scroll bars implicitly serve to separate side-by-side windows visually. When vertical scroll bars are disabled, Emacs by default separates such windows with the help of a one-pixel wide vertical border. That border occupies the first pixel column of the window on the right and may thus overdraw the leftmost pixels of any glyph displayed there. If these pixels convey important information, you can make them visible by enabling window dividers, see Window Dividers. To replicate the look of vertical borders, set the right-divider-width parameter of frames to one and have the window-divider face inherit from that of vertical-border, Window Dividers in The Emacs Lisp Reference Manual.

On graphical displays with toolkit support, Emacs may also supply a horizontal scroll bar on the bottom of each window. Clicking mouse-1 on that scroll bar’s left and right buttons scrolls the window horizontally by one column at a time. (Note that some toolkits allow customizations of the scroll bar that cause these buttons not to be shown.) Clicking mouse-1 on the left or right of the scroll bar’s inner box scrolls the window by four columns. Dragging the inner box scrolls the window continuously.

Note that such horizontal scrolling can make the window’s position of point disappear on the left or the right. Typing a character to insert text or moving point with a keyboard command will usually bring it back into view.

To toggle the use of horizontal scroll bars, type M-x horizontal-scroll-bar-mode. This command applies to all frames, including frames yet to be created. To toggle horizontal scroll bars for just the selected frame, use the command M-x toggle-horizontal-scroll-bar.

To control the use of horizontal scroll bars at startup, customize the variable horizontal-scroll-bar-mode.

You can also use the X resource ‘horizontalScrollBars’ to enable or disable horizontal scroll bars (@pxref{Resources}). To control the scroll bar height, change the scroll-bar-height frame parameter (see Frame Parameters in The Emacs Lisp Reference Manual).

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.13 Window Dividers

On graphical displays, you can use window dividers in order to separate windows visually. Window dividers are bars that can be dragged with the mouse, thus allowing you to easily resize adjacent windows.

To toggle the display of window dividers, use the command M-x window-divider-mode.

To customize where dividers should appear, use the option window-divider-default-places. Its value should be either bottom-only (to show dividers only on the bottom of windows), right-only (to show dividers only on the right of windows), or t (to show them on the bottom and on the right).

To adjust the width of window dividers displayed by this mode customize the options window-divider-default-bottom-width and window-divider-default-right-width.

When vertical scroll bars are disabled, dividers can be also useful to make the first pixel column of a window visible, which would be otherwise covered by the vertical border used to separate side-by-side windows (see section Scroll Bars).

For more details about window dividers see Window Dividers in The Emacs Lisp Reference Manual.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.14 Drag and Drop

In most graphical desktop environments, Emacs has basic support for drag and drop operations. For instance, dropping text onto an Emacs frame inserts the text where it is dropped. Dropping a file onto an Emacs frame visits that file. As a special case, dropping the file on a Dired buffer moves or copies the file (according to the conventions of the application it came from) into the directory displayed in that buffer.

Dropping a file normally visits it in the window you drop it on. If you prefer to visit the file in a new window in such cases, customize the variable dnd-open-file-other-window.

The XDND and Motif drag and drop protocols, and the old KDE 1.x protocol, are currently supported.

Emacs can also optionally drag the region with the mouse into another portion of this or another buffer. To enable that, customize the variable mouse-drag-and-drop-region to a non-nil value. Normally, the text is moved, i.e. cut and pasted, when the destination is the same buffer as the origin; dropping the region on another buffer copies the text instead. If the value of this variable names a modifier key, such as ‘shift’, ‘control’ or ‘alt’, then pressing that modifier key when dropping the text will copy it instead of cutting it, even if you drop on the same buffer as the one from which the text came.

In order to cut text even when source and destination buffers differ, set the option mouse-drag-and-drop-region-cut-when-buffers-differ to a non-nil value. By default, on a graphic display the selected text is shown in a tooltip and point moves together with the mouse cursor during dragging. To suppress such behavior, set the options mouse-drag-and-drop-region-show-tooltip and/or mouse-drag-and-drop-region-show-cursor to nil.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.15 Menu Bars

You can toggle the use of menu bars with M-x menu-bar-mode. With no argument, this command toggles Menu Bar mode, a global minor mode. With an argument, the command turns Menu Bar mode on if the argument is positive, off if the argument is not positive. To control the use of menu bars at startup, customize the variable menu-bar-mode.

Expert users often turn off the menu bar, especially on text terminals, where this makes one additional line available for text. If the menu bar is off, you can still pop up a menu of its contents with C-mouse-3 on a display which supports pop-up menus. See section Mouse Clicks for Menus.

@xref{Menu Bar}, for information on how to invoke commands with the menu bar. @xref{X Resources}, for how to customize the menu bar menus’ visual appearance.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.16 Tool Bars

On graphical displays, Emacs puts a tool bar at the top of each frame, just below the menu bar. This is a row of icons which you can click on with the mouse to invoke various commands.

The global (default) tool bar contains general commands. Some major modes define their own tool bars; whenever a buffer with such a major mode is current, the mode’s tool bar replaces the global tool bar.

To toggle the use of tool bars, type M-x tool-bar-mode. This command applies to all frames, including frames yet to be created. To control the use of tool bars at startup, customize the variable tool-bar-mode.

When Emacs is compiled with GTK+ support, each tool bar item can consist of an image, or a text label, or both. By default, Emacs follows the Gnome desktop’s tool bar style setting; if none is defined, it displays tool bar items as just images. To impose a specific tool bar style, customize the variable tool-bar-style.

You can also control the placement of the tool bar for the GTK+ tool bar with the frame parameter tool-bar-position. See Frame Parameters in The Emacs Lisp Reference Manual.

NS builds consider the tool bar to be a window decoration, and therefore do not display it when a window is undecorated. See Frame Parameters in The Emacs Lisp Reference Manual. On macOS the tool bar is hidden when the frame is put into fullscreen, but can be displayed by moving the mouse pointer to the top of the screen.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.17 Using Dialog Boxes

A dialog box is a special kind of menu for asking you a yes-or-no question or some other special question. Many Emacs commands use a dialog box to ask a yes-or-no question, if you used the mouse to invoke the command that led to the question.

To disable the use of dialog boxes, change the variable use-dialog-box to nil. In that case, Emacs always performs yes-or-no prompts using the echo area and keyboard input. This variable also controls whether to use file selection windows (but those are not supported on all platforms).

A file selection window is a special kind of dialog box for asking for file names. You can customize the variable use-file-dialog to suppress the use of file selection windows, even if you still want other kinds of dialogs. This variable has no effect if you have suppressed all dialog boxes with the variable use-dialog-box.

When Emacs is compiled with GTK+ support, it uses the GTK+ file chooser dialog. Emacs adds an additional toggle button to this dialog, which you can use to enable or disable the display of hidden files (files starting with a dot) in that dialog. If you want this toggle to be activated by default, change the variable x-gtk-show-hidden-files to t. In addition, Emacs adds help text to the GTK+ file chooser dialog; to disable this help text, change the variable x-gtk-file-dialog-help-text to nil.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.18 Tooltips

Tooltips are small special frames that display text information at the current mouse position. They activate when there is a pause in mouse movement over some significant piece of text in a window, or the mode line, or some other part of the Emacs frame such as a tool bar button or menu item.

You can toggle the use of tooltips with the command M-x tooltip-mode. When Tooltip mode is disabled, the help text is displayed in the echo area instead. To control the use of tooltips at startup, customize the variable tooltip-mode.

The following variables provide customization options for tooltip display:


This variable specifies how long Emacs should wait before displaying the first tooltip. The value is in seconds.


This variable specifies how long Emacs should wait before displaying subsequent tooltips on different items, having already displayed the first tooltip. The value is in seconds.


The number of seconds since displaying a tooltip to hide it, if the mouse doesn’t move.


The X and Y offsets, in pixels, of the left top corner of the tooltip from the mouse pointer position. Note that these are ignored if tooltip-frame-parameters was customized to include, respectively, the left and top parameters. The values of the offsets should be chosen so that the tooltip doesn’t cover the mouse pointer’s hot spot, or it might interfere with clicking the mouse.


The frame parameters used for displaying tooltips. See Frame Parameters in The Emacs Lisp Reference Manual, and also Tooltips in The Emacs Lisp Reference Manual.

For additional customization options for displaying tooltips, use M-x customize-group <RET> tooltip <RET>.

If Emacs is built with GTK+ support, it displays tooltips via GTK+, using the default appearance of GTK+ tooltips. To disable this, change the variable x-gtk-use-system-tooltips to nil. If you do this, or if Emacs is built without GTK+ support, most attributes of the tooltip text are specified by the tooltip face, and by X resources (@pxref{X Resources}).

GUD tooltips are special tooltips that show the values of variables when debugging a program with GUD. @xref{Debugger Operation}.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.19 Mouse Avoidance

On graphical terminals, the mouse pointer may obscure the text in the Emacs frame. Emacs provides two methods to avoid this problem.

Firstly, Emacs hides the mouse pointer each time you type a self-inserting character, if the pointer lies inside an Emacs frame; moving the mouse pointer makes it visible again. To disable this feature, set the variable make-pointer-invisible to nil. @xref{Display Custom}.

Secondly, you can use Mouse Avoidance mode, a minor mode, to keep the mouse pointer away from point. To use Mouse Avoidance mode, customize the variable mouse-avoidance-mode. You can set this to various values to move the mouse in several ways:


Move the pointer to a corner of the frame on any key-press. You can customize the variable mouse-avoidance-banish-position to specify where the pointer goes when it is banished.


Banish the pointer only if the cursor gets too close, and allow it to return once the cursor is out of the way.


If the cursor gets too close to the pointer, displace the pointer by a random distance and direction.


As jump, but shows steps along the way for illusion of motion.


The same as animate.


As animate, but changes the shape of the mouse pointer too.

You can also use the command M-x mouse-avoidance-mode to enable the mode. Whenever Mouse Avoidance mode moves the mouse, it also raises the frame.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.20 Non-Window Terminals

On a text terminal, Emacs can display only one Emacs frame at a time. However, you can still create multiple Emacs frames, and switch between them. Switching frames on these terminals is much like switching between different window configurations.

Use C-x 5 2 to create a new frame and switch to it; use C-x 5 o to cycle through the existing frames; use C-x 5 0 to delete the current frame.

Each frame has a number to distinguish it. If your terminal can display only one frame at a time, the selected frame’s number n appears near the beginning of the mode line, in the form ‘Fn’.

Fn’ is in fact the frame’s initial name. You can give frames more meaningful names if you wish, and you can select a frame by its name. Use the command M-x set-frame-name <RET> name <RET> to specify a new name for the selected frame, and use M-x select-frame-by-name <RET> name <RET> to select a frame according to its name. The name you specify appears in the mode line when the frame is selected.

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.21 Using a Mouse in Text Terminals

Some text terminals support mouse clicks in the terminal window.

In a terminal emulator which is compatible with xterm, you can use M-x xterm-mouse-mode to give Emacs control over simple uses of the mouse—basically, only non-modified single clicks are supported. Newer versions of xterm also support mouse-tracking. The normal xterm mouse functionality for such clicks is still available by holding down the <SHIFT> key when you press the mouse button. Xterm Mouse mode is a global minor mode (@pxref{Minor Modes}). Repeating the command turns the mode off again.

In the console on GNU/Linux, you can use M-x gpm-mouse-mode to enable mouse support. You must have the gpm server installed and running on your system in order for this to work. Note that when this mode is enabled, you cannot use the mouse to transfer text between Emacs and other programs which use GPM. This is due to limitations in GPM and the Linux kernel.

@xref{MS-DOS Mouse}, for information about mouse support on MS-DOS.

[Top] [Contents] [Index] [ ? ]

About This Document

This document was generated on May 28, 2018 using texi2html.

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ << ] FastBack Beginning of this chapter or previous chapter 1
[ < ] Back Previous section in reading order 1.2.2
[ Up ] Up Up section 1.2
[ > ] Forward Next section in reading order 1.2.4
[ >> ] FastForward Next chapter 2
[Top] Top Cover (top) of document  
[Contents] Contents Table of contents  
[Index] Index Index  
[ ? ] About About (help)  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:

This document was generated on May 28, 2018 using texi2html.