1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 99, 2000
3 @c Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Frames, International, Windows, Top
6 @chapter Frames and X Windows
9 When using the X Window System, you can create multiple windows at the
10 X level in a single Emacs session. Each X window that belongs to Emacs
11 displays a @dfn{frame} which can contain one or several Emacs windows.
12 A frame initially contains a single general-purpose Emacs window which
13 you can subdivide vertically or horizontally into smaller windows. A
14 frame normally contains its own echo area and minibuffer, but you can
15 make frames that don't have these---they use the echo area and
16 minibuffer of another frame.
18 Editing you do in one frame also affects the other frames. For
19 instance, if you put text in the kill ring in one frame, you can yank it
20 in another frame. If you exit Emacs through @kbd{C-x C-c} in one frame,
21 it terminates all the frames. To delete just one frame, use @kbd{C-x 5
24 To avoid confusion, we reserve the word ``window'' for the
25 subdivisions that Emacs implements, and never use it to refer to a
28 Emacs compiled for MS-DOS emulates some aspects of the window system
29 so that you can use many of the features described in this chapter.
30 @xref{MS-DOS Input}, for more information.
33 Emacs compiled for MS Windows mostly supports the same features as
36 Features which rely on text in multiple faces (such as Font Lock mode)
37 will also work on non-windowed terminals that can display more than one
38 face, whether by colors or underlining and emboldening, such as the
39 Linux console. Emacs determines automatically whether the terminal has
43 * Mouse Commands:: Moving, cutting, and pasting, with the mouse.
44 * Secondary Selection:: Cutting without altering point and mark.
45 * Mouse References:: Using the mouse to select an item from a list.
46 * Menu Mouse Clicks:: Mouse clicks that bring up menus.
47 * Mode Line Mouse:: Mouse clicks on the mode line.
48 * Speedbar:: How to make and use a speedbar frame.
49 * Creating Frames:: Creating additional Emacs frames with various contents.
50 * Multiple Displays:: How one Emacs job can talk to several displays.
51 * Special Buffer Frames:: You can make certain buffers have their own frames.
52 * Frame Parameters:: Changing the colors and other modes of frames.
53 * Scroll Bars:: How to enable and disable scroll bars; how to use them.
54 * Wheeled Mice:: Using mouse wheels for scrolling.
55 * Menu Bars:: Enabling and disabling the menu bar.
56 @c * Tool Bars:: Enabling and disabling the tool bar.
57 * Dialog Boxes:: Controlling use of dialog boxes.
58 * Faces:: How to change the display style using faces.
59 * Font Lock:: Minor mode for syntactic highlighting using faces.
60 * Support Modes:: Font Lock support modes make Font Lock faster.
61 * Highlight Changes:: Using colors to show where you changed the buffer.
62 * Trailing Whitespace:: Showing possibly-spurious trailing whitespace.
63 * Tooltips:: Showing `tooltips', AKA `ballon help' for active text.
64 * Mouse Avoidance:: Moving the mouse pointer out of the way.
65 * Misc X:: Iconifying and deleting frames.
66 * Non-Window Terminals:: Multiple frames on terminals that show only one.
67 * XTerm Mouse:: Using the mouse in an XTerm terminal emulator.
71 @section Mouse Commands for Editing
72 @cindex mouse buttons (what they do)
74 The mouse commands for selecting and copying a region are mostly
75 compatible with the @code{xterm} program. You can use the same mouse
76 commands for copying between Emacs and other X client programs.
79 If you select a region with any of these mouse commands, and then
80 immediately afterward type the @key{DELETE} function key, it deletes the
81 region that you selected. The @key{BACKSPACE} function key and the
82 ASCII character @key{DEL} do not do this; if you type any other key
83 in between the mouse command and @key{DELETE}, it does not do this.
85 @findex mouse-set-region
86 @findex mouse-set-point
87 @findex mouse-yank-at-click
88 @findex mouse-save-then-click
94 Move point to where you click (@code{mouse-set-point}).
95 This is normally the left button.
98 Set the region to the text you select by dragging, and copy it to the
99 kill ring (@code{mouse-set-region}). You can specify both ends of the
100 region with this single command.
102 @vindex mouse-scroll-min-lines
103 If you move the mouse off the top or bottom of the window while
104 dragging, the window scrolls at a steady rate until you move the mouse
105 back into the window. This way, you can select regions that don't fit
106 entirely on the screen. The number of lines scrolled per step depends
107 on how far away from the window edge the mouse has gone; the variable
108 @code{mouse-scroll-min-lines} specifies a minimum step size.
111 Yank the last killed text, where you click (@code{mouse-yank-at-click}).
112 This is normally the middle button.
115 This command, @code{mouse-save-then-kill}, has several functions
116 depending on where you click and the status of the region.
118 The most basic case is when you click @kbd{Mouse-1} in one place and
119 then @kbd{Mouse-3} in another. This selects the text between those two
120 positions as the region. It also copies the new region to the kill
121 ring, so that you can copy it to someplace else.
123 If you click @kbd{Mouse-1} in the text, scroll with the scroll bar, and
124 then click @kbd{Mouse-3}, it remembers where point was before scrolling
125 (where you put it with @kbd{Mouse-1}), and uses that position as the
126 other end of the region. This is so that you can select a region that
127 doesn't fit entirely on the screen.
129 More generally, if you do not have a highlighted region, @kbd{Mouse-3}
130 selects the text between point and the click position as the region. It
131 does this by setting the mark where point was, and moving point to where
134 If you have a highlighted region, or if the region was set just before
135 by dragging button 1, @kbd{Mouse-3} adjusts the nearer end of the region
136 by moving it to where you click. The adjusted region's text also
137 replaces the old region's text in the kill ring.
139 If you originally specified the region using a double or triple
140 @kbd{Mouse-1}, so that the region is defined to consist of entire words
141 or lines, then adjusting the region with @kbd{Mouse-3} also proceeds by
142 entire words or lines.
144 If you use @kbd{Mouse-3} a second time consecutively, at the same place,
145 that kills the region already selected.
148 This key sets the region around the word which you click on. If you
149 click on a character with ``symbol'' syntax (such as underscore, in C
150 mode), it sets the region around the symbol surrounding that character.
152 If you click on a character with open-parenthesis or close-parenthesis
153 syntax, it sets the region around the parenthetical grouping (sexp)
154 which that character starts or ends. If you click on a character with
155 string-delimiter syntax (such as a singlequote or doublequote in C), it
156 sets the region around the string constant (using heuristics to figure
157 out whether that character is the beginning or the end of it).
159 @item Double-Drag-Mouse-1
160 This key selects a region made up of the words you drag across.
163 This key sets the region around the line you click on.
165 @item Triple-Drag-Mouse-1
166 This key selects a region made up of the lines you drag across.
169 The simplest way to kill text with the mouse is to press @kbd{Mouse-1}
170 at one end, then press @kbd{Mouse-3} twice at the other end.
171 @xref{Killing}. To copy the text into the kill ring without deleting it
172 from the buffer, press @kbd{Mouse-3} just once---or just drag across the
173 text with @kbd{Mouse-1}. Then you can copy it elsewhere by yanking it.
175 @vindex mouse-yank-at-point
176 To yank the killed or copied text somewhere else, move the mouse there
177 and press @kbd{Mouse-2}. @xref{Yanking}. However, if
178 @code{mouse-yank-at-point} is non-@code{nil}, @kbd{Mouse-2} yanks at
179 point. Then it does not matter where you click, or even which of the
180 frame's windows you click on. The default value is @code{nil}. This
181 variable also affects yanking the secondary selection.
183 @cindex cutting and X
184 @cindex pasting and X
185 @cindex X cutting and pasting
186 To copy text to another X window, kill it or save it in the kill ring.
187 Under X, this also sets the @dfn{primary selection}. Then use the
188 ``paste'' or ``yank'' command of the program operating the other window
189 to insert the text from the selection.
191 To copy text from another X window, use the ``cut'' or ``copy'' command
192 of the program operating the other window, to select the text you want.
193 Then yank it in Emacs with @kbd{C-y} or @kbd{Mouse-2}.
195 These cutting and pasting commands also work on MS-Windows.
197 @cindex primary selection
199 @cindex selection, primary
200 @vindex x-cut-buffer-max
201 When Emacs puts text into the kill ring, or rotates text to the front
202 of the kill ring, it sets the @dfn{primary selection} in the X server.
203 This is how other X clients can access the text. Emacs also stores the
204 text in the cut buffer, but only if the text is short enough
205 (@code{x-cut-buffer-max} specifies the maximum number of characters);
206 putting long strings in the cut buffer can be slow.
208 The commands to yank the first entry in the kill ring actually check
209 first for a primary selection in another program; after that, they check
210 for text in the cut buffer. If neither of those sources provides text
211 to yank, the kill ring contents are used.
213 @node Secondary Selection
214 @section Secondary Selection
215 @cindex secondary selection
217 The @dfn{secondary selection} is another way of selecting text using
218 X. It does not use point or the mark, so you can use it to kill text
219 without setting point or the mark.
222 @findex mouse-set-secondary
223 @kindex M-Drag-Mouse-1
225 Set the secondary selection, with one end at the place where you press
226 down the button, and the other end at the place where you release it
227 (@code{mouse-set-secondary}). The highlighting appears and changes as
230 If you move the mouse off the top or bottom of the window while
231 dragging, the window scrolls at a steady rate until you move the mouse
232 back into the window. This way, you can mark regions that don't fit
233 entirely on the screen.
235 @findex mouse-start-secondary
238 Set one endpoint for the @dfn{secondary selection}
239 (@code{mouse-start-secondary}).
241 @findex mouse-secondary-save-then-kill
244 Make a secondary selection, using the place specified with @kbd{M-Mouse-1}
245 as the other end (@code{mouse-secondary-save-then-kill}). A second click
246 at the same place kills the secondary selection just made.
248 @findex mouse-yank-secondary
251 Insert the secondary selection where you click
252 (@code{mouse-yank-secondary}). This places point at the end of the
256 Double or triple clicking of @kbd{M-Mouse-1} operates on words and
257 lines, much like @kbd{Mouse-1}.
259 If @code{mouse-yank-at-point} is non-@code{nil}, @kbd{M-Mouse-2}
260 yanks at point. Then it does not matter precisely where you click; all
261 that matters is which window you click on. @xref{Mouse Commands}.
263 @node Mouse References
264 @section Following References with the Mouse
265 @kindex Mouse-2 @r{(selection)}
267 Some Emacs buffers display lists of various sorts. These include
268 lists of files, of buffers, of possible completions, of matches for
269 a pattern, and so on.
271 Since yanking text into these buffers is not very useful, most of them
272 define @kbd{Mouse-2} specially, as a command to use or view the item you
275 For example, if you click @kbd{Mouse-2} on a file name in a Dired
276 buffer, you visit that file. If you click @kbd{Mouse-2} on an error
277 message in the @samp{*Compilation*} buffer, you go to the source code
278 for that error message. If you click @kbd{Mouse-2} on a completion in
279 the @samp{*Completions*} buffer, you choose that completion.
281 You can usually tell when @kbd{Mouse-2} has this special sort of
282 meaning because the sensitive text highlights when you move the mouse
285 @node Menu Mouse Clicks
286 @section Mouse Clicks for Menus
288 Mouse clicks modified with the @key{CTRL} and @key{SHIFT} keys
294 This menu is for selecting a buffer.
297 This menu is for specifying faces and other text properties
298 for editing formatted text. @xref{Formatted Text}.
301 This menu is mode-specific. For most modes, this menu has the same
302 items as all the mode-specific menu-bar menus put together. Some modes
303 may specify a different menu for this button.@footnote{Some systems use
304 @kbd{Mouse-3} for a mode-specific menu. We took a survey of users, and
305 found they preferred to keep @kbd{Mouse-3} for selecting and killing
306 regions. Hence the decision to use @kbd{C-Mouse-3} for this menu.}
309 This menu is for specifying the frame's principal font.
312 @node Mode Line Mouse
313 @section Mode Line Mouse Commands
315 You can use mouse clicks on window mode lines to select and manipulate
320 @kbd{Mouse-1} on a mode line selects the window above. By dragging
321 @kbd{Mouse-1} on the mode line, you can move it, thus changing the
322 height of the windows above and below.
325 @kbd{Mouse-2} on a mode line expands that window to fill its frame.
328 @kbd{Mouse-3} on a mode line deletes the window above.
331 @kbd{C-Mouse-2} on a mode line splits the window above
332 horizontally, above the place in the mode line where you click.
335 @kbd{C-Mouse-2} on a scroll bar splits the corresponding window
336 vertically. @xref{Split Window}.
338 The commands above apply to areas of the mode line which do not have
339 mouse bindings of their own. Normally some areas, such as those
340 displaying the buffer name and the major mode name, have their own mouse
341 bindings. Help on these bindings is echoed when the mouse is positioned
344 @node Creating Frames
345 @section Creating Frames
346 @cindex creating frames
349 The prefix key @kbd{C-x 5} is analogous to @kbd{C-x 4}, with parallel
350 subcommands. The difference is that @kbd{C-x 5} commands create a new
351 frame rather than just a new window in the selected frame (@pxref{Pop
352 Up Window}). If an existing visible or iconified frame already displays
353 the requested material, these commands use the existing frame, after
354 raising or deiconifying as necessary.
356 The various @kbd{C-x 5} commands differ in how they find or create the
362 @findex make-frame-command
363 Create a new frame (@code{make-frame-command}).
364 @item C-x 5 b @var{bufname} @key{RET}
365 Select buffer @var{bufname} in another frame. This runs
366 @code{switch-to-buffer-other-frame}.
367 @item C-x 5 f @var{filename} @key{RET}
368 Visit file @var{filename} and select its buffer in another frame. This
369 runs @code{find-file-other-frame}. @xref{Visiting}.
370 @item C-x 5 d @var{directory} @key{RET}
371 Select a Dired buffer for directory @var{directory} in another frame.
372 This runs @code{dired-other-frame}. @xref{Dired}.
374 Start composing a mail message in another frame. This runs
375 @code{mail-other-frame}. It is the other-frame variant of @kbd{C-x m}.
378 Find a tag in the current tag table in another frame. This runs
379 @code{find-tag-other-frame}, the multiple-frame variant of @kbd{M-.}.
381 @item C-x 5 r @var{filename} @key{RET}
383 @findex find-file-read-only-other-frame
384 Visit file @var{filename} read-only, and select its buffer in another
385 frame. This runs @code{find-file-read-only-other-frame}.
389 @cindex default-frame-alist
390 @cindex initial-frame-alist
391 You can control the appearance of new frames you create by setting the
392 frame parameters in @code{default-frame-alist}. You can use the
393 variable @code{initial-frame-alist} to specify parameters that affect
394 only the initial frame. @xref{Initial Parameters,,, elisp, The Emacs
395 Lisp Reference Manual}, for more information.
397 @cindex font (default)
398 The easiest way to specify the principal font for all your Emacs
399 frames is with an X resource (@pxref{Font X}), but you can also do it by
400 modifying @code{default-frame-alist} to specify the @code{font}
401 parameter, as shown here:
404 (add-to-list 'default-frame-alist '(font . "10x20"))
408 @section Making and Using a Speedbar Frame
411 An Emacs frame can have a @dfn{speedbar}, which is a vertical window
412 that serves as a scrollable menu of files you could visit and tags
413 within those files. To create a speedbar, type @kbd{M-x speedbar}; this
414 creates a speedbar window for the selected frame. From then on, you can
415 click on a file name in the speedbar to visit that file in the
416 corresponding Emacs frame, or click on a tag name to jump to that tag in
419 Initially the speedbar lists the immediate contents of the current
420 directory, one file per line. Each line also has a box, @samp{[+]} or
421 @samp{<+>}, that you can click on with @kbd{Mouse-2} to ``open up'' the
422 contents of that item. If the line names a directory, opening it adds
423 the contents of that directory to the speedbar display, underneath the
424 directory's own line. If the line lists an ordinary file, opening it up
425 adds a list of the tags in that file to the speedbar display. When a
426 file is opened up, the @samp{[+]} changes to @samp{[-]}; you can click
427 on that box to ``close up'' that file (hide its contents).
429 Some major modes, including Rmail mode, Info, and GUD, have
430 specialized ways of putting useful items into the speedbar for you to
431 select. For example, in Rmail mode, the speedbar shows a list of Rmail
432 files, and lets you move the current message to another Rmail file by
433 clicking on its @samp{<M>} box.
435 A speedbar belongs to one Emacs frame, and always operates on that
436 frame. If you use multiple frames, you can make a speedbar for some or
437 all of the frames; type @kbd{M-x speedbar} in any given frame to make a
440 @node Multiple Displays
441 @section Multiple Displays
442 @cindex multiple displays
444 A single Emacs can talk to more than one X Windows display.
445 Initially, Emacs uses just one display---the one specified with the
446 @env{DISPLAY} environment variable or with the @samp{--display} option
447 (@pxref{Initial Options}). To connect to another display, use the
448 command @code{make-frame-on-display}:
450 @findex make-frame-on-display
452 @item M-x make-frame-on-display @key{RET} @var{display} @key{RET}
453 Create a new frame on display @var{display}.
456 A single X server can handle more than one screen. When you open
457 frames on two screens belonging to one server, Emacs knows they share a
458 single keyboard, and it treats all the commands arriving from these
459 screens as a single stream of input.
461 When you open frames on different X servers, Emacs makes a separate
462 input stream for each server. This way, two users can type
463 simultaneously on the two displays, and Emacs will not garble their
464 input. Each server also has its own selected frame. The commands you
465 enter with a particular X server apply to that server's selected frame.
467 Despite these features, people using the same Emacs job from different
468 displays can still interfere with each other if they are not careful.
469 For example, if any one types @kbd{C-x C-c}, that exits the Emacs job
472 @node Special Buffer Frames
473 @section Special Buffer Frames
475 @vindex special-display-buffer-names
476 You can make certain chosen buffers, for which Emacs normally creates
477 a second window when you have just one window, appear in special frames
478 of their own. To do this, set the variable
479 @code{special-display-buffer-names} to a list of buffer names; any
480 buffer whose name is in that list automatically gets a special frame,
481 when an Emacs command wants to display it ``in another window.''
483 For example, if you set the variable this way,
486 (setq special-display-buffer-names
487 '("*Completions*" "*grep*" "*tex-shell*"))
491 then completion lists, @code{grep} output and the @TeX{} mode shell
492 buffer get individual frames of their own. These frames, and the
493 windows in them, are never automatically split or reused for any other
494 buffers. They continue to show the buffers they were created for,
495 unless you alter them by hand. Killing the special buffer deletes its
498 @vindex special-display-regexps
499 More generally, you can set @code{special-display-regexps} to a list
500 of regular expressions; then a buffer gets its own frame if its name
501 matches any of those regular expressions. (Once again, this applies only
502 to buffers that normally get displayed for you in a separate window.)
504 @vindex special-display-frame-alist
505 The variable @code{special-display-frame-alist} specifies the frame
506 parameters for these frames. It has a default value, so you don't need
509 For those who know Lisp, an element of
510 @code{special-display-buffer-names} or @code{special-display-regexps}
511 can also be a list. Then the first element is the buffer name or
512 regular expression; the rest of the list specifies how to create the
513 frame. It can be an association list specifying frame parameter values;
514 these values take precedence over parameter values specified in
515 @code{special-display-frame-alist}. Alternatively, it can have this
519 (@var{function} @var{args}...)
523 where @var{function} is a symbol. Then the frame is constructed by
524 calling @var{function}; its first argument is the buffer, and its
525 remaining arguments are @var{args}.
527 An analogous feature lets you specify buffers which should be
528 displayed in the selected window. @xref{Force Same Window}. The
529 same-window feature takes precedence over the special-frame feature;
530 therefore, if you add a buffer name to
531 @code{special-display-buffer-names} and it has no effect, check to see
532 whether that feature is also in use for the same buffer name.
534 @node Frame Parameters
535 @section Setting Frame Parameters
537 @cindex Auto-Raise mode
538 @cindex Auto-Lower mode
540 This section describes commands for altering the display style and
541 window management behavior of the selected frame.
543 @findex set-foreground-color
544 @findex set-background-color
545 @findex set-cursor-color
546 @findex set-mouse-color
547 @findex set-border-color
548 @findex auto-raise-mode
549 @findex auto-lower-mode
551 @item M-x set-foreground-color @key{RET} @var{color} @key{RET}
552 Specify color @var{color} for the foreground of the selected frame.
553 (This also changes the foreground color of the default face.)
555 @item M-x set-background-color @key{RET} @var{color} @key{RET}
556 Specify color @var{color} for the background of the selected frame.
557 (This also changes the background color of the default face.)
559 @item M-x set-cursor-color @key{RET} @var{color} @key{RET}
560 Specify color @var{color} for the cursor of the selected frame.
562 @item M-x set-mouse-color @key{RET} @var{color} @key{RET}
563 Specify color @var{color} for the mouse cursor when it is over the
566 @item M-x set-border-color @key{RET} @var{color} @key{RET}
567 Specify color @var{color} for the border of the selected frame.
569 @item M-x list-colors-display
570 Display the defined color names and show what the colors look like.
571 This command is somewhat slow.
573 @item M-x auto-raise-mode
574 Toggle whether or not the selected frame should auto-raise. Auto-raise
575 means that every time you move the mouse onto the frame, it raises the
578 Note that this auto-raise feature is implemented by Emacs itself. Some
579 window managers also implement auto-raise. If you enable auto-raise for
580 Emacs frames in your X window manager, it should work, but it is beyond
581 Emacs's control and therefore @code{auto-raise-mode} has no effect on
584 @item M-x auto-lower-mode
585 Toggle whether or not the selected frame should auto-lower.
586 Auto-lower means that every time you move the mouse off the frame,
587 the frame moves to the bottom of the stack of X windows.
589 The command @code{auto-lower-mode} has no effect on auto-lower
590 implemented by the X window manager. To control that, you must use
591 the appropriate window manager features.
593 @findex set-frame-font
594 @item M-x set-frame-font @key{RET} @var{font} @key{RET}
595 @cindex font (principal)
596 Specify font @var{font} as the principal font for the selected frame.
597 The principal font controls several face attributes of the
598 @code{default} face (@pxref{Faces}). For example, if the principal font
599 has a height of 12 pt, all text will be drawn in 12 pt fonts, unless you
600 use another face that specifies a different height. @xref{Font X}, for
601 ways to list the available fonts on your system.
604 You can also set a frame's principal font through a pop-up menu.
605 Press @kbd{S-Mouse-1} to activate this menu.
608 In Emacs versions that use an X toolkit, the color-setting and
609 font-setting functions don't affect menus and the menu bar, since they
610 are displayed by their own widget classes. To change the appearance of
611 the menus and menu bar, you must use X resources (@pxref{Resources X}).
612 @xref{Colors X}, regarding colors. @xref{Font X}, regarding choice of
615 For information on frame parameters and customization, see @ref{Frame
616 Parameters,,, elisp, The Emacs Lisp Reference Manual}.
620 @cindex Scroll Bar mode
621 @cindex mode, Scroll Bar
623 When using X, Emacs normally makes a @dfn{scroll bar} at the left of
624 each Emacs window.@footnote{Placing it at the left is usually more
625 useful with overlapping frames with text starting at the left margin.}
626 The scroll bar runs the height of the window, and shows a moving
627 rectangular inner box which represents the portion of the buffer
628 currently displayed. The entire height of the scroll bar represents the
629 entire length of the buffer.
631 You can use @kbd{Mouse-2} (normally, the middle button) in the scroll
632 bar to move or drag the inner box up and down. If you move it to the
633 top of the scroll bar, you see the top of the buffer. If you move it to
634 the bottom of the scroll bar, you see the bottom of the buffer.
636 The left and right buttons in the scroll bar scroll by controlled
637 increments. @kbd{Mouse-1} (normally, the left button) moves the line at
638 the level where you click up to the top of the window. @kbd{Mouse-3}
639 (normally, the right button) moves the line at the top of the window
640 down to the level where you click. By clicking repeatedly in the same
641 place, you can scroll by the same distance over and over.
643 Aside from scrolling, you can also click @kbd{C-Mouse-2} in the scroll
644 bar to split a window vertically. The split occurs on the line where
647 @findex scroll-bar-mode
648 @vindex scroll-bar-mode
649 You can enable or disable Scroll Bar mode with the command @kbd{M-x
650 scroll-bar-mode}. With no argument, it toggles the use of scroll bars.
651 With an argument, it turns use of scroll bars on if and only if the
652 argument is positive. This command applies to all frames, including
653 frames yet to be created. Customize the option @code{scroll-bar-mode}
654 to control the use of scroll bars at startup. You can use it to specify
655 that they are placed at the right of windows if you prefer that. You
656 can use the X resource @samp{verticalScrollBars} to control the initial
657 setting of Scroll Bar mode similarly. @xref{Resources X}.
659 @findex toggle-scroll-bar
660 To enable or disable scroll bars for just the selected frame, use the
661 @kbd{M-x toggle-scroll-bar} command.
664 @section Scrolling With `Wheeled' Mice
667 @findex mwheel-install
668 Some mice have a `wheel' instead of a third button. You can usually
669 click the wheel to act as @kbd{mouse-3}. You can also use the wheel to
670 scroll windows instead of using the scroll bar or keyboard commands.
671 Use @kbd{M-x mwheel-install} to set up the wheel for scrolling or put
672 @samp{(require 'mwheel)} in your @file{.emacs}. (Support for the wheel
673 depends on the window system generating appropriate events for Emacs.)
675 @vindex mwheel-follow-mouse
676 @vindex mwheel-scroll-amount
677 The variables @code{mwheel-follow-mouse} and @code{mwheel-scroll-amount}
678 determine where and by how much buffers are scrolled.
682 @cindex Menu Bar mode
683 @cindex mode, Menu Bar
685 You can turn display of menu bars on or off with @kbd{M-x
686 menu-bar-mode}. With no argument, this command toggles Menu Bar mode, a
687 minor mode. With an argument, the command turns Menu Bar mode on if the
688 argument is positive, off if the argument is not positive. You can use
689 the X resource @samp{menuBarLines} to control the initial setting of
690 Menu Bar mode. @xref{Resources X}. Expert users often turn off the
691 menu bar, especially on text-only terminals, where this makes one
692 additional line available for text.
694 @xref{Menu Bar}, for information on how to invoke commands with the
697 @c Presumably not useful until we make toolbar items.
699 @c @section Tool Bars
700 @c @cindex Tool Bar mode
701 @c @cindex mode, Tool Bar
703 @c You can turn display of tool bars on or off with @kbd{M-x
704 @c tool-bar-mode}. With no argument, this command toggles Tool Bar mode, a
705 @c minor mode. With an argument, the command turns Tool Bar mode on if the
706 @c argument is positive, off if the argument is not positive.
709 @section Using Dialog Boxes
712 @vindex use-dialog-box
713 Certain operations invoked from menus will use a window system dialog
714 box to get information via the mouse if such dialog boxes are supported.
715 This includes yes/no questions and file selection under Motif/LessTif
716 and MS Windows. Customize the option @code{use-dialog-box} to suppress
717 the use of dialog boxes.
720 @section Using Multiple Typefaces
723 When using Emacs with X, you can set up multiple styles of displaying
724 characters. The aspects of style that you can control are the type
725 font, the foreground color, the background color, and whether to
726 underline. Emacs on MS-DOS supports faces partially by letting you
727 control the foreground and background colors of each face
728 (@pxref{MS-DOS}). On non-windowed terminals faces are supported to the
729 extent the terminal can display them.
731 The way you control display style is by defining named @dfn{faces}.
732 Each face can specify a type font, a foreground color, a background
733 color, and an underline flag; but it does not have to specify all of
734 them. Then by specifying the face or faces to use for a given part
735 of the text in the buffer, you control how that text appears.
737 The style of display used for a given character in the text is
738 determined by combining several faces. Any aspect of the display style
739 that isn't specified by overlays or text properties comes from the frame
742 Enriched mode, the mode for editing formatted text, includes several
743 commands and menus for specifying faces. @xref{Format Faces}, for how
744 to specify the font for text in the buffer. @xref{Format Colors}, for
745 how to specify the foreground and background color.
747 To alter the appearance of a face, use the customization buffer.
748 @xref{Face Customization}. You can also use X resources to specify
749 attributes of particular faces (@pxref{Resources X}).
751 @findex list-faces-display
752 To see what faces are currently defined, and what they look like, type
753 @kbd{M-x list-faces-display}. It's possible for a given face to look
754 different in different frames; this command shows the appearance in the
755 frame in which you type it. Here's a list of the standardly defined
760 This face is used for ordinary text that doesn't specify any other face.
762 This face is used for mode lines. By default, it's drawn with shadows
763 for a `raised' effect under X and set up as the inverse of the default
764 face on non-windowed terminals. @xref{Display Vars}.
766 Similar to @code{modeline} for a window's header line.
768 This face is used for highlighting portions of text, in various modes.
770 This face is used for displaying a selected region (when Transient Mark
771 mode is enabled---see below).
772 @item secondary-selection
773 This face is used for displaying a secondary selection (@pxref{Secondary
776 This face uses a bold variant of the default font, if it has one.
778 This face uses an italic variant of the default font, if it has one.
780 This face uses a bold italic variant of the default font, if it has one.
782 This face underlines text.
784 The basic fixed-pitch face.
786 The face for the fringes to the left and right of windows under X.
788 This face determines the colors of the scroll bar.
790 This face determines the color of the frame border.
792 This face determines the color of the cursor.
794 This face determines the color of the mouse pointer.
796 The basic tool-bar face.
798 This face determines the colors and font of Emacs's menus. Setting the
799 font of LessTif/Motif menus is currently not supported; attempts to set
800 the font are ignored in this case.
801 @item trailing-whitespace
802 The face for highlighting trailing whitespace when
803 @code{show-trailing-whitespace} is non-nil.
805 The basic variable-pitch face.
808 @cindex @code{region} face
809 When Transient Mark mode is enabled, the text of the region is
810 highlighted when the mark is active. This uses the face named
811 @code{region}; you can control the style of highlighting by changing the
812 style of this face (@pxref{Face Customization}). @xref{Transient Mark},
813 for more information about Transient Mark mode and activation and
814 deactivation of the mark.
816 One easy way to use faces is to turn on Font Lock mode. This minor
817 mode, which is always local to a particular buffer, arranges to
818 choose faces according to the syntax of the text you are editing. It
819 can recognize comments and strings in most languages; in several
820 languages, it can also recognize and properly highlight various other
821 important constructs. @xref{Font Lock}, for more information about
822 Font Lock mode and syntactic highlighting.
824 You can print out the buffer with the highlighting that appears
825 on your screen using the command @code{ps-print-buffer-with-faces}.
829 @section Font Lock mode
830 @cindex Font Lock mode
831 @cindex mode, Font Lock
832 @cindex syntax highlighting
833 @cindex syntax coloring
835 Font Lock mode is a minor mode, always local to a particular
836 buffer, which highlights (or ``fontifies'') using various faces
837 according to the syntax of the text you are editing. It can
838 recognize comments and strings in most languages; in several
839 languages, it can also recognize and properly highlight various other
840 important constructs---for example, names of functions being defined
841 or reserved keywords.
843 @findex font-lock-mode
844 @findex turn-on-font-lock
845 The command @kbd{M-x font-lock-mode} turns Font Lock mode on or off
846 according to the argument, and toggles the mode when it has no argument.
847 The function @code{turn-on-font-lock} unconditionally enables Font Lock
848 mode. This is useful in mode-hook functions. For example, to enable
849 Font Lock mode whenever you edit a C file, you can do this:
852 (add-hook 'c-mode-hook 'turn-on-font-lock)
855 @findex global-font-lock-mode
856 @vindex global-font-lock-mode
857 To turn on Font Lock mode automatically in all modes which support it,
858 customize the user option @code{global-font-lock-mode} or use the
859 function @code{global-font-lock-mode}, like this:
862 (global-font-lock-mode 1)
866 @findex font-lock-fontify-block
867 In Font Lock mode, when you edit the text, the highlighting updates
868 automatically in the line that you changed. Most changes don't affect
869 the highlighting of subsequent lines, but occasionally they do. To
870 rehighlight a range of lines, use the command @kbd{M-g M-g}
871 (@code{font-lock-fontify-block}).
873 @vindex font-lock-mark-block-function
874 In certain major modes, @kbd{M-g M-g} refontifies the entire current
875 function. (The variable @code{font-lock-mark-block-function} controls
876 how to find the current function.) In other major modes, @kbd{M-g M-g}
877 refontifies 16 lines above and below point.
879 With a prefix argument @var{n}, @kbd{M-g M-g} refontifies @var{n}
880 lines above and below point, regardless of the mode.
882 To get the full benefit of Font Lock mode, you need to choose a
883 default font which has bold, italic, and bold-italic variants; or else
884 you need to have a color or gray-scale screen.
886 @vindex font-lock-maximum-decoration
887 The variable @code{font-lock-maximum-decoration} specifies the
888 preferred level of fontification, for modes that provide multiple
889 levels. Level 1 is the least amount of fontification; some modes
890 support levels as high as 3. The normal default is ``as high as
891 possible.'' You can specify an integer, which applies to all modes, or
892 you can specify different numbers for particular major modes; for
893 example, to use level 1 for C/C++ modes, and the default level
897 (setq font-lock-maximum-decoration
898 '((c-mode . 1) (c++-mode . 1)))
901 @vindex font-lock-maximum-size
902 Fontification can be too slow for large buffers, so you can suppress
903 it. The variable @code{font-lock-maximum-size} specifies a buffer size,
904 beyond which buffer fontification is suppressed.
906 @c @w is used below to prevent a bad page-break.
907 @vindex font-lock-beginning-of-syntax-function
908 Comment and string fontification (or ``syntactic'' fontification)
909 relies on analysis of the syntactic structure of the buffer text. For
910 the purposes of speed, some modes including C mode and Lisp mode rely on
911 a special convention: an open-parenthesis in the leftmost column always
912 defines the @w{beginning} of a defun, and is thus always outside any string
913 or comment. (@xref{Defuns}.) If you don't follow this convention,
914 then Font Lock mode can misfontify the text after an open-parenthesis in
915 the leftmost column that is inside a string or comment.
917 The variable @code{font-lock-beginning-of-syntax-function} (always
918 buffer-local) specifies how Font Lock mode can find a position
919 guaranteed to be outside any comment or string. In modes which use the
920 leftmost column parenthesis convention, the default value of the variable
921 is @code{beginning-of-defun}---that tells Font Lock mode to use the
922 convention. If you set this variable to @code{nil}, Font Lock no longer
923 relies on the convention. This avoids incorrect results, but the price
924 is that, in some cases, fontification for a changed text must rescan
925 buffer text from the beginning of the buffer.
927 @findex font-lock-add-keywords
928 Font Lock highlighting patterns already exist for many modes, but you
929 may want to fontify additional patterns. You can use the function
930 @code{font-lock-add-keywords}, to add your own highlighting patterns for
931 a particular mode. For example, to highlight @samp{FIXME:} words in C
935 (font-lock-add-keywords
937 '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t)))
941 @section Font Lock Support Modes
943 Font Lock support modes make Font Lock mode faster for large buffers.
944 There are two support modes: Fast Lock mode and Lazy Lock mode. They
945 use two different methods of speeding up Font Lock mode.
948 * Fast Lock Mode:: Saving font information in files.
949 * Lazy Lock Mode:: Fontifying only text that is actually displayed.
950 * JIT Lock Mode:: Like Lazy Lock, but generally faster.
951 * Fast or Lazy:: Which support mode is best for you?
955 @subsection Fast Lock Mode
957 @cindex Fast Lock mode
958 @cindex mode, Fast Lock
959 To make Font Lock mode faster for buffers visiting large files, you
960 can use Fast Lock mode. Fast Lock mode saves the font information for
961 each file in a separate cache file; each time you visit the file, it
962 rereads the font information from the cache file instead of refontifying
963 the text from scratch.
965 @findex fast-lock-mode
966 The command @kbd{M-x fast-lock-mode} turns Fast Lock mode on or off,
967 according to the argument (with no argument, it toggles). You can also
968 arrange to enable Fast Lock mode whenever you use Font Lock mode, like
972 (setq font-lock-support-mode 'fast-lock-mode)
975 @vindex fast-lock-minimum-size
976 It is not worth writing a cache file for small buffers. Therefore,
977 the variable @code{fast-lock-minimum-size} specifies a minimum file size
978 for caching font information.
980 @vindex fast-lock-cache-directories
981 The variable @code{fast-lock-cache-directories} specifies where to put
982 the cache files. Its value is a list of directories to try; @code{"."}
983 means the same directory as the file being edited. The default value is
984 @w{@code{("." "~/.emacs-flc")}}, which means to use the same directory if
985 possible, and otherwise the directory @file{~/.emacs-flc}.
987 @vindex fast-lock-save-others
988 The variable @code{fast-lock-save-others} specifies whether Fast Lock
989 mode should save cache files for files that you do not own. A
990 non-@code{nil} value means yes (and that is the default).
993 @subsection Lazy Lock Mode
994 @cindex Lazy Lock mode
995 @cindex mode, Lazy Lock
997 To make Font Lock mode faster for large buffers, you can use Lazy Lock
998 mode to reduce the amount of text that is fontified. In Lazy Lock mode,
999 buffer fontification is demand-driven; it happens to portions of the
1000 buffer that are about to be displayed. And fontification of your
1001 changes is deferred; it happens only when Emacs has been idle for a
1002 certain short period of time.
1004 @findex lazy-lock-mode
1005 The command @kbd{M-x lazy-lock-mode} turns Lazy Lock mode on or off,
1006 according to the argument (with no argument, it toggles). You can also
1007 arrange to enable Lazy Lock mode whenever you use Font Lock mode, like
1011 (setq font-lock-support-mode 'lazy-lock-mode)
1014 @vindex lazy-lock-minimum-size
1015 It is not worth avoiding buffer fontification for small buffers.
1016 Therefore, the variable @code{lazy-lock-minimum-size} specifies a
1017 minimum buffer size for demand-driven buffer fontification. Buffers
1018 smaller than that are fontified all at once, as in plain Font Lock mode.
1020 @vindex lazy-lock-defer-time
1021 When you alter the buffer, Lazy Lock mode defers fontification of the
1022 text you changed. The variable @code{lazy-lock-defer-time} specifies
1023 how many seconds Emacs must be idle before it starts fontifying your
1024 changes. If the value is 0, then changes are fontified immediately, as
1025 in plain Font Lock mode.
1027 @vindex lazy-lock-defer-on-scrolling
1028 Lazy Lock mode normally fontifies newly visible portions of the buffer
1029 before they are first displayed. However, if the value of
1030 @code{lazy-lock-defer-on-scrolling} is non-@code{nil}, newly visible
1031 text is fontified only when Emacs is idle for
1032 @code{lazy-lock-defer-time} seconds.
1034 @vindex lazy-lock-defer-contextually
1035 In some modes, including C mode and Emacs Lisp mode, changes in one
1036 line's contents can alter the context for subsequent lines, and thus
1037 change how they ought to be fontified. Ordinarily, you must type
1038 @kbd{M-g M-g} to refontify the subsequent lines. However, if you set
1039 the variable @code{lazy-lock-defer-contextually} to non-@code{nil}, Lazy
1040 Lock mode does this automatically, after @code{lazy-lock-defer-time}
1043 @cindex stealth fontification
1044 When Emacs is idle for a long time, Lazy Lock fontifies additional
1045 portions of the buffer, not yet displayed, in case you will display them
1046 later. This is called @dfn{stealth fontification}.
1048 @vindex lazy-lock-stealth-time
1049 @vindex lazy-lock-stealth-lines
1050 @vindex lazy-lock-stealth-verbose
1051 The variable @code{lazy-lock-stealth-time} specifies how many seconds
1052 Emacs has to be idle before stealth fontification starts. A value of
1053 @code{nil} means no stealth fontification. The variables
1054 @code{lazy-lock-stealth-lines} and @code{lazy-lock-stealth-verbose}
1055 specify the granularity and verbosity of stealth fontification.
1058 @subsection JIT Lock Mode
1060 @findex jit-lock-mode
1061 The command @kbd{M-x lazy-lock-mode} turns JIT Lock mode on or off,
1062 according to the argument (with no argument, it toggles). This support
1063 mode is roughly equivalent to Lazy Lock but is generally faster. It
1064 supports stealth and deferred fontification.
1066 Font-lock uses @code{jit-lock-mode} as default support mode, so you
1067 don't have to do anything to activate it.
1070 @subsection Fast Lock or Lazy Lock?
1072 Here is a simple guide to help you choose one of the Font Lock support
1077 Fast Lock mode intervenes only during file visiting and buffer
1078 killing (and related events); therefore buffer editing and window
1079 scrolling are no faster or slower than in plain Font Lock mode.
1082 Fast Lock mode is slower at reading a cache file than Lazy Lock
1083 mode is at fontifying a window; therefore Fast Lock mode is slower at
1084 visiting a file than Lazy Lock mode.
1087 Lazy Lock mode intervenes during window scrolling to fontify text that
1088 scrolls onto the screen; therefore, scrolling is slower than in plain
1092 Lazy Lock mode doesn't fontify during buffer editing (it defers
1093 fontification of changes); therefore, editing is faster than in plain
1097 Fast Lock mode can be fooled by a file that is kept under version
1098 control software; therefore buffer fontification may occur even when
1099 a cache file exists for the file.
1102 Fast Lock mode only works with a buffer visiting a file; Lazy Lock
1103 mode works with any buffer.
1106 Fast Lock mode generates cache files; Lazy Lock mode does not.
1109 @vindex font-lock-support-mode
1110 The variable @code{font-lock-support-mode} specifies which of these
1111 support modes to use; for example, to specify that Fast Lock mode is
1112 used for C/C++ modes, and Lazy Lock mode otherwise, set the variable
1116 (setq font-lock-support-mode
1117 '((c-mode . fast-lock-mode) (c++-mode . fast-lock-mode)
1118 (t . lazy-lock-mode)))
1121 @node Highlight Changes
1122 @section Highlight Changes Mode
1124 @findex highlight-changes-mode
1125 Use @kbd{M-x highlight-changes-mode} to enable a minor mode
1126 that uses faces (colors, typically) to indicate which parts of
1127 the buffer were changed most recently.
1129 @node Trailing Whitespace
1130 @section Trailing Whitespace
1132 @cindex trailing whitespace
1133 @cindex whitespace, trailing
1134 @vindex show-trailing-whitespace
1135 The option @code{show-trailing-whitespace} can be customized so that
1136 Emacs displays trailing whitespace in the face
1137 @code{trailing-whitespace}. Trailing whitespace is defined as spaces or
1138 tabs at the end of a line. To avoid busy highlighting when entering new
1139 text, trailing whitespace is not displayed if point is at the end of the
1140 line containing the whitespace.
1143 @section Tooltips (or `Balloon Help')
1145 @cindex balloon help
1146 @findex tooltip-mode
1147 Tooltips are small X windows displaying a help string at the current
1148 mouse position, typically over text---including the mode line---which
1149 can be activated with the mouse or other keys. (This facility is
1150 sometimes known as `balloon help'.) Tooltips may be available for menu
1153 To use tooltips, customize the user option @code{tooltip-mode}. The
1154 customization group @code{tooltip} controls various aspects of their
1155 display. If Tooltip mode is not activated, the help text is displayed
1156 in the echo area instead.
1158 @node Mouse Avoidance
1159 @section Mouse Avoidance
1161 Mouse Avoidance mode keeps the window system mouse pointer away from
1162 point to avoid obscuring text. Whenever the mouse is moved, the frame
1163 is also raised. To use it, customize the option
1164 @code{mouse-avoidance-mode}. You can set this to various values to move
1165 the mouse in several ways:
1169 Move the mouse to the upper-right corner on any keypress;
1171 Move the mouse to the corner only if the cursor gets too close,
1172 and allow it to return once the cursor is out of the way;
1174 If the cursor gets too close to the mouse, displace the mouse
1175 a random distance & direction;
1177 As @code{jump}, but shows steps along the way for illusion of motion;
1179 The same as @code{animate};
1181 As @code{animate}, but changes the shape of the mouse pointer too.
1184 You can also use the command @kbd{M-x mouse-avoidance-mode} to turn on
1188 @section Miscellaneous X Window Features
1190 The following commands let you create, delete and operate on frames:
1194 @kindex C-z @r{(X windows)}
1195 @findex iconify-or-deiconify-frame
1196 Iconify the selected Emacs frame (@code{iconify-or-deiconify-frame}).
1197 The normal meaning of @kbd{C-z}, to suspend Emacs, is not useful under a
1198 window system, so it has a different binding in that case.
1200 If you type this command on an Emacs frame's icon, it deiconifies the frame.
1204 @findex delete-frame
1205 Delete the selected frame (@code{delete-frame}). This is not allowed if
1206 there is only one frame.
1211 Select another frame, raise it, and warp the mouse to it so that it
1212 stays selected. If you repeat this command, it cycles through all the
1213 frames on your terminal.
1217 @findex delete-other-frames
1218 Delete all frames except the selected one.
1221 @node Non-Window Terminals
1222 @section Non-Window Terminals
1223 @cindex non-window terminals
1224 @cindex single-frame terminals
1226 If your terminal does not have a window system that Emacs supports,
1227 then it can display only one Emacs frame at a time. However, you can
1228 still create multiple Emacs frames, and switch between them. Switching
1229 frames on these terminals is much like switching between different
1230 window configurations.
1232 Use @kbd{C-x 5 2} to create a new frame and switch to it; use @kbd{C-x
1233 5 o} to cycle through the existing frames; use @kbd{C-x 5 0} to delete
1236 Each frame has a number to distinguish it. If your terminal can
1237 display only one frame at a time, the selected frame's number @var{n}
1238 appears near the beginning of the mode line, in the form
1241 @findex set-frame-name
1242 @findex select-frame-by-name
1243 @samp{F@var{n}} is actually the frame's name. You can also specify a
1244 different name if you wish, and you can select a frame by its name. Use
1245 the command @kbd{M-x set-frame-name @key{RET} @var{name} @key{RET}} to
1246 specify a new name for the selected frame, and use @kbd{M-x
1247 select-frame-by-name @key{RET} @var{name} @key{RET}} to select a frame
1248 according to its name. The name you specify appears in the mode line
1249 when the frame is selected.
1252 @section Using a Mouse in Terminal Emulators
1253 @cindex xterm, mouse support
1254 @cindex terminal emulators, mouse support
1256 Some terminal emulators under X support mouse clicks in the terminal
1257 window. In a terminal emulator which is compatible with @code{xterm},
1258 you can use @kbd{M-x xterm-mouse-mode} to enable simple use of the
1259 mouse---only single clicks are supported. The normal @code{xterm} mouse
1260 functionality is still available by holding down the @kbd{SHIFT} key
1261 when you press the mouse button.