(kill-comment): Fixed by rewriting it with syntax-tables rather than regexps
[emacs.git] / man / frames.texi
blob392e890c50c1ff75a0ff994f2498105f3519074a
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997 Free Software Foundation, Inc.
3 @c See file emacs.texi for copying conditions.
4 @node Frames, International, Windows, Top
5 @chapter Frames and X Windows
6 @cindex frames
8   When using the X Window System, you can create multiple windows at the
9 X level in a single Emacs session.  Each X window that belongs to Emacs
10 displays a @dfn{frame} which can contain one or several Emacs windows.
11 A frame initially contains a single general-purpose Emacs window which
12 you can subdivide vertically or horizontally into smaller windows.  A
13 frame normally contains its own echo area and minibuffer, but you can
14 make frames that don't have these---they use the echo area and
15 minibuffer of another frame.
17   Editing you do in one frame also affects the other frames.  For
18 instance, if you put text in the kill ring in one frame, you can yank it
19 in another frame.  If you exit Emacs through @kbd{C-x C-c} in one frame,
20 it terminates all the frames.  To delete just one frame, use @kbd{C-x 5
21 0}.
23   To avoid confusion, we reserve the word ``window'' for the
24 subdivisions that Emacs implements, and never use it to refer to a
25 frame.
27   Emacs compiled for MS-DOS emulates some aspects of the window system
28 so that you can use many of the features described in this chapter.
29 @xref{MS-DOS Input}, for more information.
31 @menu
32 * Mouse Commands::      Moving, cutting, and pasting, with the mouse.
33 * Secondary Selection:: Cutting without altering point and mark.
34 * Mouse References::    Using the mouse to select an item from a list.
35 * Menu Mouse Clicks::   Mouse clicks that bring up menus.
36 * Mode Line Mouse::     Mouse clicks on the mode line.
37 * Speedbar::            How to make and use a speedbar frame.
38 * Creating Frames::     Creating additional Emacs frames with various contents.
39 * Multiple Displays::   How one Emacs job can talk to several displays.
40 * Special Buffer Frames::  You can make certain buffers have their own frames.
41 * Frame Parameters::    Changing the colors and other modes of frames.
42 * Scroll Bars::         How to enable and disable scroll bars; how to use them.
43 * Menu Bars::           Enabling and disabling the menu bar.
44 * Faces::               How to change the display style using faces.
45 * Font Lock::           Minor mode for syntactic highlighting using faces.
46 * Support Modes::       Font Lock support modes make Font Lock faster.
47 * Highlight Changes::   Using colors to show where you changed the buffer.
48 * Misc X::              Iconifying and deleting frames. Region highlighting.
49 * Non-Window Terminals::  Multiple frames on terminals that show only one.
50 @end menu
52 @node Mouse Commands
53 @section Mouse Commands for Editing
54 @cindex mouse buttons (what they do)
56   The mouse commands for selecting and copying a region are mostly
57 compatible with the @code{xterm} program.  You can use the same mouse
58 commands for copying between Emacs and other X client programs.
60 @kindex DELETE
61   If you select a region with any of these mouse commands, and then
62 immediately afterward type the @key{DELETE} function key, it deletes the
63 region that you selected.  The @key{BACKSPACE} function key and the
64 ASCII character @key{DEL} do not do this; if you type any other key
65 in between the mouse command and @key{DELETE}, it does not do this.
67 @findex mouse-set-region
68 @findex mouse-set-point
69 @findex mouse-yank-at-click
70 @findex mouse-save-then-click
71 @kindex Mouse-1
72 @kindex Mouse-2
73 @kindex Mouse-3
74 @table @kbd
75 @item Mouse-1
76 Move point to where you click (@code{mouse-set-point}).
77 This is normally the left button.
79 @item Drag-Mouse-1
80 Set the region to the text you select by dragging, and copy it to the
81 kill ring (@code{mouse-set-region}).  You can specify both ends of the
82 region with this single command.
84 @vindex mouse-scroll-min-lines
85 If you move the mouse off the top or bottom of the window while
86 dragging, the window scrolls at a steady rate until you move the mouse
87 back into the window.  This way, you can select regions that don't fit
88 entirely on the screen.  The number of lines scrolled per step depends
89 on how far away from the window edge the mouse has gone; the variable
90 @code{mouse-scroll-min-lines} specifies a minimum step size.
92 @item Mouse-2
93 Yank the last killed text, where you click (@code{mouse-yank-at-click}).
94 This is normally the middle button.
96 @item Mouse-3
97 This command, @code{mouse-save-then-kill}, has several functions
98 depending on where you click and the status of the region.
100 The most basic case is when you click @kbd{Mouse-1} in one place and
101 then @kbd{Mouse-3} in another.  This selects the text between those two
102 positions as the region.  It also copies the new region to the kill
103 ring, so that you can copy it to someplace else.
105 If you click @kbd{Mouse-1} in the text, scroll with the scroll bar, and
106 then click @kbd{Mouse-3}, it remembers where point was before scrolling
107 (where you put it with @kbd{Mouse-1}), and uses that position as the
108 other end of the region.  This is so that you can select a region that
109 doesn't fit entirely on the screen.
111 More generally, if you do not have a highlighted region, @kbd{Mouse-3}
112 selects the text between point and the click position as the region.  It
113 does this by setting the mark where point was, and moving point to where
114 you click.
116 If you have a highlighted region, or if the region was set just before
117 by dragging button 1, @kbd{Mouse-3} adjusts the nearer end of the region
118 by moving it to where you click.  The adjusted region's text also
119 replaces the old region's text in the kill ring.
121 If you originally specified the region using a double or triple
122 @kbd{Mouse-1}, so that the region is defined to consist of entire words
123 or lines, then adjusting the region with @kbd{Mouse-3} also proceeds by
124 entire words or lines.
126 If you use @kbd{Mouse-3} a second time consecutively, at the same place,
127 that kills the region already selected.
129 @item Double-Mouse-1
130 This key sets the region around the word which you click on.  If you
131 click on a character with ``symbol'' syntax (such as underscore, in C
132 mode), it sets the region around the symbol surrounding that character.
134 If you click on a character with open-parenthesis or close-parenthesis
135 syntax, it sets the region around the parenthetical grouping (sexp)
136 which that character starts or ends.  If you click on a character with
137 string-delimiter syntax (such as a singlequote or doublequote in C), it
138 sets the region around the string constant (using heuristics to figure
139 out whether that character is the beginning or the end of it).
141 @item Double-Drag-Mouse-1
142 This key selects a region made up of the words you drag across.
144 @item Triple-Mouse-1
145 This key sets the region around the line you click on.
147 @item Triple-Drag-Mouse-1
148 This key selects a region made up of the lines you drag across.
149 @end table
151   The simplest way to kill text with the mouse is to press @kbd{Mouse-1}
152 at one end, then press @kbd{Mouse-3} twice at the other end.
153 @xref{Killing}.  To copy the text into the kill ring without deleting it
154 from the buffer, press @kbd{Mouse-3} just once---or just drag across the
155 text with @kbd{Mouse-1}.  Then you can copy it elsewhere by yanking it.
157 @vindex mouse-yank-at-point
158   To yank the killed or copied text somewhere else, move the mouse there
159 and press @kbd{Mouse-2}.  @xref{Yanking}.  However, if
160 @code{mouse-yank-at-point} is non-@code{nil}, @kbd{Mouse-2} yanks at
161 point.  Then it does not matter where you click, or even which of the
162 frame's windows you click on.  The default value is @code{nil}.  This
163 variable also affects yanking the secondary selection.
165 @cindex cutting and X
166 @cindex pasting and X
167 @cindex X cutting and pasting
168   To copy text to another X window, kill it or save it in the kill ring.
169 Under X, this also sets the @dfn{primary selection}.  Then use the
170 ``paste'' or ``yank'' command of the program operating the other window
171 to insert the text from the selection.
173   To copy text from another X window, use the ``cut'' or ``copy'' command
174 of the program operating the other window, to select the text you want.
175 Then yank it in Emacs with @kbd{C-y} or @kbd{Mouse-2}.
177   These cutting and pasting commands also work on MS-Windows.
179 @cindex primary selection
180 @cindex cut buffer
181 @cindex selection, primary
182 @vindex x-cut-buffer-max
183   When Emacs puts text into the kill ring, or rotates text to the front
184 of the kill ring, it sets the @dfn{primary selection} in the X server.
185 This is how other X clients can access the text.  Emacs also stores the
186 text in the cut buffer, but only if the text is short enough
187 (@code{x-cut-buffer-max} specifies the maximum number of characters);
188 putting long strings in the cut buffer can be slow.
190   The commands to yank the first entry in the kill ring actually check
191 first for a primary selection in another program; after that, they check
192 for text in the cut buffer.  If neither of those sources provides text
193 to yank, the kill ring contents are used.
195 @node Secondary Selection
196 @section Secondary Selection
197 @cindex secondary selection
199   The @dfn{secondary selection} is another way of selecting text using
200 X.  It does not use point or the mark, so you can use it to kill text
201 without setting point or the mark.
203 @table @kbd
204 @findex mouse-set-secondary
205 @kindex M-Drag-Mouse-1
206 @item M-Drag-Mouse-1
207 Set the secondary selection, with one end at the place where you press
208 down the button, and the other end at the place where you release it
209 (@code{mouse-set-secondary}).  The highlighting appears and changes as
210 you drag.
212 If you move the mouse off the top or bottom of the window while
213 dragging, the window scrolls at a steady rate until you move the mouse
214 back into the window.  This way, you can mark regions that don't fit
215 entirely on the screen.
217 @findex mouse-start-secondary
218 @kindex M-Mouse-1
219 @item M-Mouse-1
220 Set one endpoint for the @dfn{secondary selection}
221 (@code{mouse-start-secondary}).
223 @findex mouse-secondary-save-then-kill
224 @kindex M-Mouse-3
225 @item M-Mouse-3
226 Make a secondary selection, using the place specified with @kbd{M-Mouse-1}
227 as the other end (@code{mouse-secondary-save-then-kill}).  A second click
228 at the same place kills the secondary selection just made.
230 @findex mouse-yank-secondary
231 @kindex M-Mouse-2
232 @item M-Mouse-2
233 Insert the secondary selection where you click
234 (@code{mouse-yank-secondary}).  This places point at the end of the
235 yanked text.
236 @end table
238 Double or triple clicking of @kbd{M-Mouse-1} operates on words and
239 lines, much like @kbd{Mouse-1}.
241 If @code{mouse-yank-at-point} is non-@code{nil}, @kbd{M-Mouse-2}
242 yanks at point.  Then it does not matter precisely where you click; all
243 that matters is which window you click on.  @xref{Mouse Commands}.
245 @node Mouse References
246 @section Following References with the Mouse
247 @kindex Mouse-2 @r{(selection)}
249   Some Emacs buffers display lists of various sorts.  These include
250 lists of files, of buffers, of possible completions, of matches for
251 a pattern, and so on.
253   Since yanking text into these buffers is not very useful, most of them
254 define @kbd{Mouse-2} specially, as a command to use or view the item you
255 click on.
257   For example, if you click @kbd{Mouse-2} on a file name in a Dired
258 buffer, you visit that file.  If you click @kbd{Mouse-2} on an error
259 message in the @samp{*Compilation*} buffer, you go to the source code
260 for that error message.  If you click @kbd{Mouse-2} on a completion in
261 the @samp{*Completions*} buffer, you choose that completion.
263   You can usually tell when @kbd{Mouse-2} has this special sort of
264 meaning because the sensitive text highlights when you move the mouse
265 over it.
267 @node Menu Mouse Clicks
268 @section Mouse Clicks for Menus
270   Mouse clicks modified with the @key{CTRL} and @key{SHIFT} keys
271 bring up menus.
273 @kindex C-Mouse-3
274 @table @kbd
275 @item C-Mouse-1
276 This menu is for selecting a buffer.
278 @item C-Mouse-2
279 This menu is for specifying faces and other text properties
280 for editing formatted text.  @xref{Formatted Text}.
282 @item C-Mouse-3
283 This menu is mode-specific.  For most modes, this menu has the same
284 items as all the mode-specific menu-bar menus put together.  Some modes
285 may specify a different menu for this button.@footnote{Some systems use
286 @kbd{Mouse-3} for a mode-specific menu.  We took a survey of users, and
287 found they preferred to keep @kbd{Mouse-3} for selecting and killing
288 regions.  Hence the decision to use @kbd{C-Mouse-3} for this menu.}
290 @item S-mouse-1
291 This menu is for specifying the frame's principal font.
292 @end table
294 @node Mode Line Mouse
295 @section Mode Line Mouse Commands
297   You can use mouse clicks on window mode lines to select and manipulate
298 windows.
300 @table @kbd
301 @item Mouse-1
302 @kbd{Mouse-1} on a mode line selects the window above.  By dragging
303 @kbd{Mouse-1} on the mode line, you can move it, thus changing the
304 height of the windows above and below.
306 @item Mouse-2
307 @kbd{Mouse-2} on a mode line expands that window to fill its frame.
309 @item Mouse-3
310 @kbd{Mouse-3} on a mode line deletes the window above.
312 @item C-Mouse-2
313 @kbd{C-Mouse-2} on a mode line splits the window above
314 horizontally, above the place in the mode line where you click.
315 @end table
317   @kbd{C-Mouse-2} on a scroll bar splits the corresponding window
318 vertically.  @xref{Split Window}.
320 @node Creating Frames
321 @section Creating Frames
322 @cindex creating frames
324 @kindex C-x 5
325   The prefix key @kbd{C-x 5} is analogous to @kbd{C-x 4}, with parallel
326 subcommands.  The difference is that @kbd{C-x 5} commands create a new
327 frame rather than just a new window in the selected frame (@pxref{Pop
328 Up Window}).  If an existing visible or iconified frame already displays
329 the requested material, these commands use the existing frame, after
330 raising or deiconifying as necessary. 
332   The various @kbd{C-x 5} commands differ in how they find or create the
333 buffer to select:
335 @table @kbd
336 @item C-x 5 2
337 @kindex C-x 5 2
338 @findex make-frame-command
339 Create a new frame (@code{make-frame-command}).
340 @item C-x 5 b @var{bufname} @key{RET}
341 Select buffer @var{bufname} in another frame.  This runs
342 @code{switch-to-buffer-other-frame}.
343 @item C-x 5 f @var{filename} @key{RET}
344 Visit file @var{filename} and select its buffer in another frame.  This
345 runs @code{find-file-other-frame}.  @xref{Visiting}.
346 @item C-x 5 d @var{directory} @key{RET}
347 Select a Dired buffer for directory @var{directory} in another frame.
348 This runs @code{dired-other-frame}.  @xref{Dired}.
349 @item C-x 5 m
350 Start composing a mail message in another frame.  This runs
351 @code{mail-other-frame}.  It is the other-frame variant of @kbd{C-x m}.
352 @xref{Sending Mail}.
353 @item C-x 5 .
354 Find a tag in the current tag table in another frame.  This runs
355 @code{find-tag-other-frame}, the multiple-frame variant of @kbd{M-.}.
356 @xref{Tags}.
357 @item C-x 5 r @var{filename} @key{RET}
358 @kindex C-x 5 r
359 @findex find-file-read-only-other-frame
360 Visit file @var{filename} read-only, and select its buffer in another
361 frame.  This runs @code{find-file-read-only-other-frame}.
362 @xref{Visiting}.
363 @end table
365 @cindex default-frame-alist
366 @cindex initial-frame-alist
367   You can control the appearance of new frames you create by setting the
368 frame parameters in @code{default-frame-alist}.  You can use the
369 variable @code{initial-frame-alist} to specify parameters that affect
370 only the initial frame.  @xref{Initial Parameters,,, elisp, The Emacs
371 Lisp Reference Manual}, for more information.
373 @cindex font (default)
374   The easiest way to specify the principal font for all your Emacs
375 frames is with an X resource (@pxref{Font X}), but you can also do it by
376 modifying @code{default-frame-alist} to specify the @code{font}
377 parameter, as shown here:
379 @example
380 (add-to-list 'default-frame-alist '(font . "10x20"))
381 @end example
383 @node Speedbar
384 @section Making and Using a Speedbar Frame
385 @cindex speedbar
387   An Emacs frame can have a @dfn{speedbar}, which is a vertical window
388 that serves as a scrollable menu of files you could visit and tags
389 within those files.  To create a speedbar, type @kbd{M-x speedbar}; this
390 creates a speedbar window for the selected frame.  From then on, you can
391 click on a file name in the speedbar to visit that file in the
392 corresponding Emacs frame, or click on a tag name to jump to that tag in
393 the Emacs frame.
395   Initially the speedbar lists the immediate contents of the current
396 directory, one file per line.  Each line also has a box, @samp{[+]} or
397 @samp{<+>}, that you can click on with @kbd{Mouse-2} to ``open up'' the
398 contents of that item.  If the line names a directory, opening it adds
399 the contents of that directory to the speedbar display, underneath the
400 directory's own line.  If the line lists an ordinary file, opening it up
401 adds a list of the tags in that file to the speedbar display.  When a
402 file is opened up, the @samp{[+]} changes to @samp{[-]}; you can click
403 on that box to ``close up'' that file (hide its contents).
405   Some major modes, including Rmail mode, Info, and GUD, have
406 specialized ways of putting useful items into the speedbar for you to
407 select.  For example, in Rmail mode, the speedbar shows a list of Rmail
408 files, and lets you move the current message to another Rmail file by
409 clicking on its @samp{<M>} box.
411   A speedbar belongs to one Emacs frame, and always operates on that
412 frame.  If you use multiple frames, you can make a speedbar for some or
413 all of the frames; type @kbd{M-x speedbar} in any given frame to make a
414 speedbar for it.
416 @node Multiple Displays
417 @section Multiple Displays
418 @cindex multiple displays
420   A single Emacs can talk to more than one X Windows display.
421 Initially, Emacs uses just one display---the one specified with the
422 @code{DISPLAY} environment variable or with the @samp{--display} option
423 (@pxref{Initial Options}).  To connect to another display, use the
424 command @code{make-frame-on-display}:
426 @findex make-frame-on-display
427 @table @kbd
428 @item M-x make-frame-on-display @key{RET} @var{display} @key{RET}
429 Create a new frame on display @var{display}.
430 @end table
432   A single X server can handle more than one screen.  When you open
433 frames on two screens belonging to one server, Emacs knows they share a
434 single keyboard, and it treats all the commands arriving from these
435 screens as a single stream of input.
437   When you open frames on different X servers, Emacs makes a separate
438 input stream for each server.  This way, two users can type
439 simultaneously on the two displays, and Emacs will not garble their
440 input.  Each server also has its own selected frame.  The commands you
441 enter with a particular X server apply to that server's selected frame.
443   Despite these features, people using the same Emacs job from different
444 displays can still interfere with each other if they are not careful.
445 For example, if any one types @kbd{C-x C-c}, that exits the Emacs job
446 for all of them!
448 @node Special Buffer Frames
449 @section Special Buffer Frames
451 @vindex special-display-buffer-names
452   You can make certain chosen buffers, for which Emacs normally creates
453 a second window when you have just one window, appear in special frames
454 of their own.  To do this, set the variable
455 @code{special-display-buffer-names} to a list of buffer names; any
456 buffer whose name is in that list automatically gets a special frame,
457 when an Emacs command wants to display it ``in another window.''
459   For example, if you set the variable this way,
461 @example
462 (setq special-display-buffer-names
463       '("*Completions*" "*grep*" "*tex-shell*"))
464 @end example
466 @noindent
467 then completion lists, @code{grep} output and the @TeX{} mode shell
468 buffer get individual frames of their own.  These frames, and the
469 windows in them, are never automatically split or reused for any other
470 buffers.  They continue to show the buffers they were created for,
471 unless you alter them by hand.  Killing the special buffer deletes its
472 frame automatically.
474 @vindex special-display-regexps
475   More generally, you can set @code{special-display-regexps} to a list
476 of regular expressions; then a buffer gets its own frame if its name
477 matches any of those regular expressions.  (Once again, this applies only
478 to buffers that normally get displayed for you in a separate window.)
480 @vindex special-display-frame-alist
481   The variable @code{special-display-frame-alist} specifies the frame
482 parameters for these frames.  It has a default value, so you don't need
483 to set it.
485   For those who know Lisp, an element of
486 @code{special-display-buffer-names} or @code{special-display-regexps}
487 can also be a list.  Then the first element is the buffer name or
488 regular expression; the rest of the list specifies how to create the
489 frame.  It can be an association list specifying frame parameter values;
490 these values take precedence over parameter values specified in
491 @code{special-display-frame-alist}.  Alternatively, it can have this
492 form:
494 @example
495 (@var{function} @var{args}...)
496 @end example
498 @noindent
499 where @var{function} is a symbol.  Then the frame is constructed by
500 calling @var{function}; its first argument is the buffer, and its
501 remaining arguments are @var{args}.
503    An analogous feature lets you specify buffers which should be
504 displayed in the selected window.  @xref{Force Same Window}.  The
505 same-window feature takes precedence over the special-frame feature;
506 therefore, if you add a buffer name to
507 @code{special-display-buffer-names} and it has no effect, check to see
508 whether that feature is also in use for the same buffer name.
510 @node Frame Parameters
511 @section Setting Frame Parameters
512 @cindex colors
513 @cindex Auto-Raise mode
514 @cindex Auto-Lower mode
516   This section describes commands for altering the display style and
517 window management behavior of the selected frame.
519 @findex set-foreground-color
520 @findex set-background-color
521 @findex set-cursor-color
522 @findex set-mouse-color
523 @findex set-border-color
524 @findex auto-raise-mode
525 @findex auto-lower-mode
526 @table @kbd
527 @item M-x set-foreground-color @key{RET} @var{color} @key{RET}
528 Specify color @var{color} for the foreground of the selected frame.
529 (This also changes the foreground color of the default face.)
531 @item M-x set-background-color @key{RET} @var{color} @key{RET}
532 Specify color @var{color} for the background of the selected frame.
533 (This also changes the background color of the default face.)
535 @item M-x set-cursor-color @key{RET} @var{color} @key{RET}
536 Specify color @var{color} for the cursor of the selected frame.
538 @item M-x set-mouse-color @key{RET} @var{color} @key{RET}
539 Specify color @var{color} for the mouse cursor when it is over the
540 selected frame.
542 @item M-x set-border-color @key{RET} @var{color} @key{RET}
543 Specify color @var{color} for the border of the selected frame.
545 @item M-x list-colors-display
546 Display the defined color names and show what the colors look like.
547 This command is somewhat slow.
549 @item M-x auto-raise-mode
550 Toggle whether or not the selected frame should auto-raise.  Auto-raise
551 means that every time you move the mouse onto the frame, it raises the
552 frame.
554 Note that this auto-raise feature is implemented by Emacs itself.  Some
555 window managers also implement auto-raise.  If you enable auto-raise for
556 Emacs frames in your X window manager, it should work, but it is beyond
557 Emacs's control and therefore @code{auto-raise-mode} has no effect on
560 @item M-x auto-lower-mode
561 Toggle whether or not the selected frame should auto-lower.
562 Auto-lower means that every time you move the mouse off the frame,
563 the frame moves to the bottom of the stack of X windows.
565 The command @code{auto-lower-mode} has no effect on auto-lower
566 implemented by the X window manager.  To control that, you must use
567 the appropriate window manager features.
569 @findex set-frame-font
570 @item M-x set-frame-font @key{RET} @var{font} @key{RET}
571 @cindex font (principal)
572 Specify font @var{font} as the principal font for the selected frame.
573 The principal font controls several face attributes of the
574 @code{default} face (@pxref{Faces}).  For example, if the principal font
575 has a height of 12 pt, all text will be drawn in 12 pt fonts, unless you
576 use another face that specifies a different height.  @xref{Font X}, for
577 ways to list the available fonts on your system.
579 @kindex S-Mouse-1
580 You can also set a frame's principal font through a pop-up menu.
581 Press @kbd{S-Mouse-1} to activate this menu.
582 @end table
584   In Emacs versions that use an X toolkit, the color-setting and
585 font-setting functions don't affect menus and the menu bar, since they
586 are displayed by their own widget classes.  To change the appearance of
587 the menus and menu bar, you must use X resources (@pxref{Resources X}).
588 @xref{Colors X}, regarding colors.  @xref{Font X}, regarding choice of
589 font.
591   For information on frame parameters and customization, see @ref{Frame
592 Parameters,,, elisp, The Emacs Lisp Reference Manual}.
594 @node Scroll Bars
595 @section Scroll Bars
596 @cindex Scroll Bar mode
597 @cindex mode, Scroll Bar
599   When using X, Emacs normally makes a @dfn{scroll bar} at the left of
600 each Emacs window.  The scroll bar runs the height of the window, and
601 shows a moving rectangular inner box which represents the portion of the
602 buffer currently displayed.  The entire height of the scroll bar
603 represents the entire length of the buffer.
605   You can use @kbd{Mouse-2} (normally, the middle button) in the scroll
606 bar to move or drag the inner box up and down.  If you move it to the
607 top of the scroll bar, you see the top of the buffer.  If you move it to
608 the bottom of the scroll bar, you see the bottom of the buffer.
610   The left and right buttons in the scroll bar scroll by controlled
611 increments.  @kbd{Mouse-1} (normally, the left button) moves the line at
612 the level where you click up to the top of the window.  @kbd{Mouse-3}
613 (normally, the right button) moves the line at the top of the window
614 down to the level where you click.  By clicking repeatedly in the same
615 place, you can scroll by the same distance over and over.
617   Aside from scrolling, you can also click @kbd{C-Mouse-2} in the scroll
618 bar to split a window vertically.  The split occurs on the line where
619 you click.
621 @findex scroll-bar-mode
622   You can enable or disable Scroll Bar mode with the command @kbd{M-x
623 scroll-bar-mode}.  With no argument, it toggles the use of scroll bars.
624 With an argument, it turns use of scroll bars on if and only if the
625 argument is positive.  This command applies to all frames, including
626 frames yet to be created.  You can use the X resource
627 @samp{verticalScrollBars} to control the initial setting of Scroll Bar
628 mode.  @xref{Resources X}.
630 @findex toggle-scroll-bar
631   To enable or disable scroll bars for just the selected frame, use the
632 @kbd{M-x toggle-scroll-bar} command.
634 @node Menu Bars
635 @section Menu Bars
636 @cindex Menu Bar mode
637 @cindex mode, Menu Bar
639   You can turn display of menu bars on or off with @kbd{M-x
640 menu-bar-mode}.  With no argument, this command toggles Menu Bar mode, a
641 minor mode.  With an argument, the command turns Menu Bar mode on if the
642 argument is positive, off if the argument is not positive.  You can use
643 the X resource @samp{menuBarLines} to control the initial setting of
644 Menu Bar mode.  @xref{Resources X}.  Expert users often turn off the
645 menu bar, especially on text-only terminals, where this makes one
646 additional line available for text.
648   @xref{Menu Bar}, for information on how to invoke commands with the
649 menu bar.
651 @node Faces
652 @section Using Multiple Typefaces
653 @cindex faces
655   When using Emacs with X, you can set up multiple styles of displaying
656 characters.  The aspects of style that you can control are the type
657 font, the foreground color, the background color, and whether to
658 underline.  Emacs on MS-DOS supports faces partially by letting you
659 control the foreground and background colors of each face
660 (@pxref{MS-DOS}).
662   The way you control display style is by defining named @dfn{faces}.
663 Each face can specify a type font, a foreground color, a background
664 color, and an underline flag; but it does not have to specify all of
665 them.  Then by specifying the face or faces to use for a given part
666 of the text in the buffer, you control how that text appears.
668   The style of display used for a given character in the text is
669 determined by combining several faces.  Any aspect of the display style
670 that isn't specified by overlays or text properties comes from the frame
671 itself.
673   Enriched mode, the mode for editing formatted text, includes several
674 commands and menus for specifying faces.  @xref{Format Faces}, for how
675 to specify the font for text in the buffer.  @xref{Format Colors}, for
676 how to specify the foreground and background color.
678   To alter the appearance of a face, use the customization buffer.
679 @xref{Face Customization}.  You can also use X resources to specify
680 attributes of particular faces (@pxref{Resources X}).
682 @findex list-faces-display
683   To see what faces are currently defined, and what they look like, type
684 @kbd{M-x list-faces-display}.  It's possible for a given face to look
685 different in different frames; this command shows the appearance in the
686 frame in which you type it.  Here's a list of the standardly defined
687 faces:
689 @table @code
690 @item default
691 This face is used for ordinary text that doesn't specify any other face.
692 @item modeline
693 This face is used for mode lines.  By default, it's set up as the
694 inverse of the default face.  @xref{Display Vars}.
695 @item highlight
696 This face is used for highlighting portions of text, in various modes.
697 @item region
698 This face is used for displaying a selected region (when Transient Mark
699 mode is enabled---see below).
700 @item secondary-selection
701 This face is used for displaying a secondary selection (@pxref{Secondary
702 Selection}).
703 @item bold
704 This face uses a bold variant of the default font, if it has one.
705 @item italic
706 This face uses an italic variant of the default font, if it has one.
707 @item bold-italic
708 This face uses a bold italic variant of the default font, if it has one.
709 @item underline
710 This face underlines text.
711 @end table
713 @cindex @code{region} face
714   When Transient Mark mode is enabled, the text of the region is
715 highlighted when the mark is active.  This uses the face named
716 @code{region}; you can control the style of highlighting by changing the
717 style of this face (@pxref{Face Customization}).  @xref{Transient Mark},
718 for more information about Transient Mark mode and activation and
719 deactivation of the mark.
721   One easy way to use faces is to turn on Font Lock mode.  This minor
722 mode, which is always local to a particular buffer, arranges to
723 choose faces according to the syntax of the text you are editing.  It
724 can recognize comments and strings in most languages; in several
725 languages, it can also recognize and properly highlight various other
726 important constructs.  @xref{Font Lock}, for more information about
727 Font Lock mode and syntactic highlighting.
729   You can print out the buffer with the highlighting that appears
730 on your screen using the command @code{ps-print-buffer-with-faces}.
731 @xref{Postscript}.
733 @node Font Lock
734 @section Font Lock mode
735 @cindex Font Lock mode
736 @cindex mode, Font Lock
737 @cindex syntax highlighting
739   Font Lock mode is a minor mode, always local to a particular
740 buffer, which highlights (or ``fontifies'') using various faces
741 according to the syntax of the text you are editing.  It can
742 recognize comments and strings in most languages; in several
743 languages, it can also recognize and properly highlight various other
744 important constructs---for example, names of functions being defined
745 or reserved keywords.
747 @findex font-lock-mode
748 @findex turn-on-font-lock
749   The command @kbd{M-x font-lock-mode} turns Font Lock mode on or off
750 according to the argument, and toggles the mode when it has no argument.
751 The function @code{turn-on-font-lock} unconditionally enables Font Lock
752 mode.  This is useful in mode-hook functions.  For example, to enable
753 Font Lock mode whenever you edit a C file, you can do this:
755 @example
756 (add-hook 'c-mode-hook 'turn-on-font-lock)
757 @end example
759 @findex global-font-lock-mode
760   To turn on Font Lock mode automatically in all modes which support it,
761 use the function @code{global-font-lock-mode}, like this:
763 @example
764 (global-font-lock-mode 1)
765 @end example
767 @kindex M-g M-g
768 @findex font-lock-fontify-block
769   In Font Lock mode, when you edit the text, the highlighting updates
770 automatically in the line that you changed.  Most changes don't affect
771 the highlighting of subsequent lines, but occasionally they do.  To
772 rehighlight a range of lines, use the command @kbd{M-g M-g}
773 (@code{font-lock-fontify-block}).
775 @vindex font-lock-mark-block-function
776   In certain major modes, @kbd{M-g M-g} refontifies the entire current
777 function.  (The variable @code{font-lock-mark-block-function} controls
778 how to find the current function.)  In other major modes, @kbd{M-g M-g}
779 refontifies 16 lines above and below point.
781   With a prefix argument @var{n}, @kbd{M-g M-g} refontifies @var{n}
782 lines above and below point, regardless of the mode.
784   To get the full benefit of Font Lock mode, you need to choose a
785 default font which has bold, italic, and bold-italic variants; or else
786 you need to have a color or gray-scale screen.
788 @vindex font-lock-maximum-decoration
789   The variable @code{font-lock-maximum-decoration} specifies the
790 preferred level of fontification, for modes that provide multiple
791 levels.  Level 1 is the least amount of fontification; some modes
792 support levels as high as 3.  The normal default is ``as high as
793 possible.''  You can specify an integer, which applies to all modes, or
794 you can specify different numbers for particular major modes; for
795 example, to use level 1 for C/C++ modes, and the default level
796 otherwise, use this:
798 @example
799 (setq font-lock-maximum-decoration
800       '((c-mode . 1) (c++-mode . 1)))
801 @end example
803 @vindex font-lock-maximum-size
804   Fontification can be too slow for large buffers, so you can suppress
805 it.  The variable @code{font-lock-maximum-size} specifies a buffer size,
806 beyond which buffer fontification is suppressed.
808 @c @w is used below to prevent a bad page-break.
809 @vindex font-lock-beginning-of-syntax-function
810   Comment and string fontification (or ``syntactic'' fontification)
811 relies on analysis of the syntactic structure of the buffer text.  For
812 the purposes of speed, some modes including C mode and Lisp mode rely on
813 a special convention: an open-parenthesis in the leftmost column always
814 defines the @w{beginning} of a defun, and is thus always outside any string
815 or comment.  (@xref{Defuns}.)  If you don't follow this convention,
816 then Font Lock mode can misfontify the text after an open-parenthesis in
817 the leftmost column that is inside a string or comment.
819   The variable @code{font-lock-beginning-of-syntax-function} (always
820 buffer-local) specifies how Font Lock mode can find a position
821 guaranteed to be outside any comment or string.  In modes which use the
822 leftmost column parenthesis convention, the default value of the variable
823 is @code{beginning-of-defun}---that tells Font Lock mode to use the
824 convention.  If you set this variable to @code{nil}, Font Lock no longer
825 relies on the convention.  This avoids incorrect results, but the price
826 is that, in some cases, fontification for a changed text must rescan
827 buffer text from the beginning of the buffer.
829 @findex font-lock-add-keywords
830   Font Lock highlighting patterns already exist for many modes, but you
831 may want to fontify additional patterns.  You can use the function
832 @code{font-lock-add-keywords}, to add your own highlighting patterns for
833 a particular mode.  For example, to highlight @samp{FIXME:} words in C
834 comments, use this:
836 @example
837 (font-lock-add-keywords
838  'c-mode
839  '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t)))
840 @end example
842 @node Support Modes
843 @section Font Lock Support Modes
845   Font Lock support modes make Font Lock mode faster for large buffers.
846 There are two support modes: Fast Lock mode and Lazy Lock mode.  They
847 use two different methods of speeding up Font Lock mode.
849 @menu
850 * Fast Lock Mode::      Saving font information in files.
851 * Lazy Lock Mode::      Fontifying only text that is actually displayed.
852 * Fast or Lazy::        Which support mode is best for you?
853 @end menu
855 @node Fast Lock Mode
856 @subsection Fast Lock Mode
858 @cindex Fast Lock mode
859 @cindex mode, Fast Lock
860   To make Font Lock mode faster for buffers visiting large files, you
861 can use Fast Lock mode.  Fast Lock mode saves the font information for
862 each file in a separate cache file; each time you visit the file, it
863 rereads the font information from the cache file instead of refontifying
864 the text from scratch.
866 @findex fast-lock-mode
867   The command @kbd{M-x fast-lock-mode} turns Fast Lock mode on or off,
868 according to the argument (with no argument, it toggles).  You can also
869 arrange to enable Fast Lock mode whenever you use Font Lock mode, like
870 this:
872 @example
873 (setq font-lock-support-mode 'fast-lock-mode)
874 @end example
876 @vindex fast-lock-minimum-size
877   It is not worth writing a cache file for small buffers.  Therefore,
878 the variable @code{fast-lock-minimum-size} specifies a minimum file size
879 for caching font information.
881 @vindex fast-lock-cache-directories
882   The variable @code{fast-lock-cache-directories} specifies where to put
883 the cache files.  Its value is a list of directories to try; @code{"."}
884 means the same directory as the file being edited.  The default value is
885 @w{@code{("." "~/.emacs-flc")}}, which means to use the same directory if
886 possible, and otherwise the directory @file{~/.emacs-flc}.
888 @vindex fast-lock-save-others
889   The variable @code{fast-lock-save-others} specifies whether Fast Lock
890 mode should save cache files for files that you do not own.  A
891 non-@code{nil} value means yes (and that is the default).
893 @node Lazy Lock Mode
894 @subsection Lazy Lock Mode
895 @cindex Lazy Lock mode
896 @cindex mode, Lazy Lock
898   To make Font Lock mode faster for large buffers, you can use Lazy Lock
899 mode to reduce the amount of text that is fontified.  In Lazy Lock mode,
900 buffer fontification is demand-driven; it happens to portions of the
901 buffer that are about to be displayed.  And fontification of your
902 changes is deferred; it happens only when Emacs has been idle for a
903 certain short period of time.
905 @findex lazy-lock-mode
906   The command @kbd{M-x lazy-lock-mode} turns Lazy Lock mode on or off,
907 according to the argument (with no argument, it toggles).  You can also
908 arrange to enable Lazy Lock mode whenever you use Font Lock mode, like
909 this:
911 @example
912 (setq font-lock-support-mode 'lazy-lock-mode)
913 @end example
915 @vindex lazy-lock-minimum-size
916   It is not worth avoiding buffer fontification for small buffers.
917 Therefore, the variable @code{lazy-lock-minimum-size} specifies a
918 minimum buffer size for demand-driven buffer fontification.  Buffers
919 smaller than that are fontified all at once, as in plain Font Lock mode.
921 @vindex lazy-lock-defer-time
922   When you alter the buffer, Lazy Lock mode defers fontification of the
923 text you changed.  The variable @code{lazy-lock-defer-time} specifies
924 how many seconds Emacs must be idle before it starts fontifying your
925 changes.  If the value is 0, then changes are fontified immediately, as
926 in plain Font Lock mode.
928 @vindex lazy-lock-defer-on-scrolling
929   Lazy Lock mode normally fontifies newly visible portions of the buffer
930 before they are first displayed.  However, if the value of
931 @code{lazy-lock-defer-on-scrolling} is non-@code{nil}, newly visible
932 text is fontified only when Emacs is idle for
933 @code{lazy-lock-defer-time} seconds.
935 @vindex lazy-lock-defer-contextually
936   In some modes, including C mode and Emacs Lisp mode, changes in one
937 line's contents can alter the context for subsequent lines, and thus
938 change how they ought to be fontified.  Ordinarily, you must type
939 @kbd{M-g M-g} to refontify the subsequent lines.  However, if you set
940 the variable @code{lazy-lock-defer-contextually} to non-@code{nil}, Lazy
941 Lock mode does this automatically, after @code{lazy-lock-defer-time}
942 seconds.
944 @cindex stealth fontification
945   When Emacs is idle for a long time, Lazy Lock fontifies additional
946 portions of the buffer, not yet displayed, in case you will display them
947 later.  This is called @dfn{stealth fontification}.
949 @vindex lazy-lock-stealth-time
950 @vindex lazy-lock-stealth-lines
951 @vindex lazy-lock-stealth-verbose
952   The variable @code{lazy-lock-stealth-time} specifies how many seconds
953 Emacs has to be idle before stealth fontification starts.  A value of
954 @code{nil} means no stealth fontification.  The variables
955 @code{lazy-lock-stealth-lines} and @code{lazy-lock-stealth-verbose}
956 specify the granularity and verbosity of stealth fontification.
958 @node Fast or Lazy
959 @subsection Fast Lock or Lazy Lock?
961   Here is a simple guide to help you choose one of the Font Lock support
962 modes.
964 @itemize @bullet
965 @item
966 Fast Lock mode intervenes only during file visiting and buffer
967 killing (and related events); therefore buffer editing and window
968 scrolling are no faster or slower than in plain Font Lock mode.
970 @item
971 Fast Lock mode is slower at reading a cache file than Lazy Lock
972 mode is at fontifying a window; therefore Fast Lock mode is slower at
973 visiting a file than Lazy Lock mode.
975 @item
976 Lazy Lock mode intervenes during window scrolling to fontify text that
977 scrolls onto the screen; therefore, scrolling is slower than in plain
978 Font Lock mode.
980 @item
981 Lazy Lock mode doesn't fontify during buffer editing (it defers
982 fontification of changes); therefore, editing is faster than in plain
983 Font Lock mode.
985 @item
986 Fast Lock mode can be fooled by a file that is kept under version
987 control software; therefore buffer fontification may occur even when
988 a cache file exists for the file.
990 @item
991 Fast Lock mode only works with a buffer visiting a file; Lazy Lock
992 mode works with any buffer.
994 @item
995 Fast Lock mode generates cache files; Lazy Lock mode does not.
996 @end itemize
998 @vindex font-lock-support-mode
999   The variable @code{font-lock-support-mode} specifies which of these
1000 support modes to use; for example, to specify that Fast Lock mode is
1001 used for C/C++ modes, and Lazy Lock mode otherwise, set the variable
1002 like this:
1004 @example
1005 (setq font-lock-support-mode
1006       '((c-mode . fast-lock-mode) (c++-mode . fast-lock-mode)
1007         (t . lazy-lock-mode)))
1008 @end example
1010 @node Highlight Changes
1011 @section Highlight Changes Mode
1013 @findex highlight-changes-mode
1014   Use @kbd{M-x highlight-changes-mode} to enable a minor mode
1015 that uses faces (colors, typically) to indicate which parts of
1016 the buffer were changed most recently.
1018 @node Misc X
1019 @section Miscellaneous X Window Features
1021   The following commands let you create, delete and operate on frames:
1023 @table @kbd
1024 @item C-z
1025 @kindex C-z @r{(X windows)}
1026 @findex iconify-or-deiconify-frame
1027 Iconify the selected Emacs frame (@code{iconify-or-deiconify-frame}).
1028 The normal meaning of @kbd{C-z}, to suspend Emacs, is not useful under a
1029 window system, so it has a different binding in that case.
1031 If you type this command on an Emacs frame's icon, it deiconifies the frame.
1033 @item C-x 5 0
1034 @kindex C-x 5 0
1035 @findex delete-frame
1036 Delete the selected frame (@code{delete-frame}).  This is not allowed if
1037 there is only one frame.
1039 @item C-x 5 o
1040 @kindex C-x 5 o
1041 @findex other-frame
1042 Select another frame, raise it, and warp the mouse to it so that it
1043 stays selected.  If you repeat this command, it cycles through all the
1044 frames on your terminal.
1045 @end table
1047 @node Non-Window Terminals
1048 @section Non-Window Terminals
1049 @cindex non-window terminals
1050 @cindex single-frame terminals
1052   If your terminal does not have a window system that Emacs supports,
1053 then it can display only one Emacs frame at a time.  However, you can
1054 still create multiple Emacs frames, and switch between them.  Switching
1055 frames on these terminals is much like switching between different
1056 window configurations.
1058   Use @kbd{C-x 5 2} to create a new frame and switch to it; use @kbd{C-x
1059 5 o} to cycle through the existing frames; use @kbd{C-x 5 0} to delete
1060 the current frame.
1062   Each frame has a number to distinguish it.  If your terminal can
1063 display only one frame at a time, the selected frame's number @var{n}
1064 appears near the beginning of the mode line, in the form
1065 @samp{F@var{n}}.
1067 @findex set-frame-name
1068 @findex select-frame-by-name
1069   @samp{F@var{n}} is actually the frame's name.  You can also specify a
1070 different name if you wish, and you can select a frame by its name.  Use
1071 the command @kbd{M-x set-frame-name @key{RET} @var{name} @key{RET}} to
1072 specify a new name for the selected frame, and use @kbd{M-x
1073 select-frame-by-name @key{RET} @var{name} @key{RET}} to select a frame
1074 according to its name.  The name you specify appears in the mode line
1075 when the frame is selected.