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 (see Windows).  A frame normally also contains a menu bar, tool bar, and echo area.

You can also create additional frames (see 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 (see 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 Non-Window Terminals).  It is also possible to use the mouse on some text terminals (see Text-Only Mouse, for doing so on GNU and Unix systems; and see MS-DOS Mouse, for doing so on MS-DOS).  Menus are supported on all text terminals.

Mouse Commands for Editing
==========================

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

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

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

Mouse-3
     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.

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 (see Mark). In addition, the text in the region becomes the primary selection (see 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).  See 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:

  * If no region is active, clicking Mouse-3 activates the region, placing the mark where point was and point at the clicked position.

  * If a region is active, clicking Mouse-3 adjusts the nearer end of the region by moving it to the clicked position.  The adjusted region's text is copied to the kill ring; if the text in the original region was already on the kill ring, it replaces it there.

  * If you originally specified the region using a double or triple Mouse-1, so that the region is defined to consist of entire words or lines (see Word and Line Mouse), then adjusting the region with Mouse-3 also proceeds by entire words or lines.

  * If you use Mouse-3 a second time consecutively, at the same place, that kills the region already selected.  Thus, the simplest way to kill text with the mouse is to click Mouse-1 at one end, then click Mouse-3 twice at the other end.  To copy the text into the kill ring without deleting it from the buffer, press Mouse-3 just once---or just drag across the text with Mouse-1.  Then you can copy it elsewhere by yanking it.

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.  See 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.

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.

Double-Mouse-1
     Select the text around the word 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-Drag-Mouse-1
     Select the text you drag across, in the form of whole words.

Triple-Mouse-1
     Select the line you click on.

Triple-Drag-Mouse-1
     Select the text you drag across, in the form of whole lines.

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 (see Dired).  In a *Compilation* buffer, each error message is a button, and activating it visits the source code for that error (see 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.

Mouse Clicks for Menus
======================

Several mouse clicks with the CTRL and SHIFT modifiers bring up menus.

C-Mouse-1
     This menu is for selecting a buffer.

     The MSB (``mouse select buffer'') global minor mode makes this menu smarter and more customizable.  See Buffer Menus.

C-Mouse-2
     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; see Enriched Text).

C-Mouse-3
     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.

S-Mouse-1
     This menu is for changing the default face within the window's buffer. See 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 (see Init Rebinding):

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

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 Tooltips).  This section's commands do not apply in those areas.

Mouse-1
     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
     Mouse-2 on a mode line expands that window to fill its frame.

Mouse-3
     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
     C-Mouse-2 on a mode line splits that window, producing two side-by-side windows with the boundary running through the click position (see 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 Split Window.

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 (see Pop Up Window), the C-x 5 commands use a different frame.  If an existing visible or iconified (a.k.a. ``minimized'') 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.  See Visiting.

C-x 5 d DIRECTORY RET
     Select a Dired buffer for directory DIRECTORY in another frame. This runs dired-other-frame.  See 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.  See 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-..  See 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. See Visiting.

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

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.

C-z
     Minimize (or iconify) the selected Emacs frame (suspend-frame).  See 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.

M-<F10>
     Toggle the maximization state of the current frame.  When a frame is maximized, it fills the screen.

<F11>
     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 (see 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 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.

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:

  * Click on Set Default Font in the Options menu.  This makes the selected font the default on all existing graphical frames. To save this for future sessions, click on Save Options in the Options menu.

  * Add a line to your init file, modifying the variable default-frame-alist to specify the font parameter (see Frame Parameters), like this:

          (add-to-list 'default-frame-alist
                       '(font . "DejaVu Sans Mono-10"))

     This makes the font the default on all graphical frames created after restarting Emacs with that init file.

  * Add an emacs.font X resource setting to your X resource file, like this:

          emacs.font: DejaVu Sans Mono-12

     You must restart X, or use the xrdb command, for the X resources file to take effect.  See Resources.  Do not quote font names in X resource files.

  * If you are running Emacs on the GNOME desktop, you can tell Emacs to use the default system font by setting the variable font-use-system-font to t (the default is nil). For this to work, Emacs must have been compiled with Gconf support.

  * Use the command line option -fn (or --font).  See Font X.

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:

     FONTNAME[-FONTSIZE][:NAME1=VALUES1][:NAME2=VALUES2]...

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:

slant
     One of italic, oblique, or roman.

weight
     One of light, medium, demibold, bold or black.

style
     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.

width
     One of condensed, normal, or expanded.

spacing
     One of monospace, proportional, dual-width, or charcell.

Here are some examples of Fontconfig patterns:

     Monospace
     Monospace-12
     Monospace-12:bold
     DejaVu Sans Mono:bold:italic
     Monospace-12:weight=bold:slant=italic

For a more detailed description of Fontconfig patterns, see the Fontconfig manual, which is distributed with Fontconfig and available online at http://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:

  * Slant properties: Italic or Oblique.  If omitted, the default (roman) slant is implied.

  * Weight properties: Bold, Book, Light, Medium, Semi-bold, or Ultra-light.  If omitted, Medium weight is implied.

  * Width properties: Semi-Condensed or Condensed.  If omitted, a default width is used.

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:

     -misc-fixed-medium-r-semicondensed--13-*-*-*-c-60-iso8859-1

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:

     -MAKER-FAMILY-WEIGHT-SLANT-WIDTHTYPE-STYLE...
     ...-PIXELS-HEIGHT-HORIZ-VERT-SPACING-WIDTH-REGISTRY-ENCODING

The entries have the following meanings:

maker
     The name of the font manufacturer.

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

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

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

widthtype
     The font width---normally normal, condensed, semicondensed, or extended.  Some font names support other values.

style
     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.

pixels
     The font height, in pixels.

height
     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.

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

vert
     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.

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

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

registry
encoding
     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

     -misc-fixed-medium-r-semicondensed--13-*-*-*-c-60-iso8859-1

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*' | egrep "^[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 (see Faces), or a particular frame (see Frame Parameters).

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 file name visits that file in the selected window of the attached frame, and clicking on a directory name shows that directory in the speedbar (see Mouse References).  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 (Speedbar Manual).

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.

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 (see 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 (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.

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.  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 (see Moving Point).  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 Mac OS; 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 (see Resources).  To control the scroll bar width, change the scroll-bar-width frame parameter (see Frame Parameters (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 can not over-scroll when the entire buffer is visible.

The visual appearance of the scroll bars is controlled by the scroll-bar face.

On graphical displays with toolkit support, Emacs may also supply a horizontal scroll bar on the bottom of each window.  Clicking Mouse-1 on the that scroll bar's left and right buttons scrolls the window horizontally by one column at a time.  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 (see Resources).  To control the scroll bar height, change the scroll-bar-height frame parameter (see Frame Parameters (The Emacs Lisp Reference Manual)).

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 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.

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

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.

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 Menu Mouse Clicks.

See Menu Bar, for information on how to invoke commands with the menu bar.  See X Resources, for how to customize the menu bar menus' visual appearance.

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 (The Emacs Lisp Reference Manual).

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.

Tooltips
========

Tooltips are small windows 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 variables tooltip-delay specifies how long Emacs should wait before displaying a tooltip.  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 (see X Resources).

GUD tooltips are special tooltips that show the values of variables when debugging a program with GUD.  See Debugger Operation.

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.

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:

banish
     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.

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

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

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

cat-and-mouse
     The same as animate.

proteus
     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.

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.

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 (see 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.

See MS-DOS Mouse, for information about mouse support on MS-DOS.