Manual fixes for frame-background-mode.
[emacs.git] / doc / emacs / display.texi
blob2238570eaa92dc22abf7f30dfa09a502e9c7ecda
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2012
3 @c   Free Software Foundation, Inc.
5 @c See file emacs.texi for copying conditions.
6 @node Display
7 @chapter Controlling the Display
9   Since only part of a large buffer fits in the window, Emacs has to
10 show only a part of it.  This chapter describes commands and variables
11 that let you specify which part of the text you want to see, and how
12 the text is displayed.
14 @menu
15 * Scrolling::              Commands to move text up and down in a window.
16 * Recentering::            A scroll command that centers the current line.
17 * Auto Scrolling::         Redisplay scrolls text automatically when needed.
18 * Horizontal Scrolling::   Moving text left and right in a window.
19 * Narrowing::              Restricting display and editing to a portion
20                              of the buffer.
21 * View Mode::              Viewing read-only buffers.
22 * Follow Mode::            Follow mode lets two windows scroll as one.
23 * Faces::                  How to change the display style using faces.
24 * Colors::                 Specifying colors for faces.
25 * Standard Faces::         The main predefined faces.
26 * Text Scale::             Increasing or decreasing text size in a buffer.
27 * Font Lock::              Minor mode for syntactic highlighting using faces.
28 * Highlight Interactively:: Tell Emacs what text to highlight.
29 * Fringes::                Enabling or disabling window fringes.
30 * Displaying Boundaries::  Displaying top and bottom of the buffer.
31 * Useless Whitespace::     Showing possibly spurious trailing whitespace.
32 * Selective Display::      Hiding lines with lots of indentation.
33 * Optional Mode Line::     Optional mode line display features.
34 * Text Display::           How text characters are normally displayed.
35 * Cursor Display::         Features for displaying the cursor.
36 * Line Truncation::        Truncating lines to fit the screen width instead
37                              of continuing them to multiple screen lines.
38 * Visual Line Mode::       Word wrap and screen line-based editing.
39 * Display Custom::         Information on variables for customizing display.
40 @end menu
42 @node Scrolling
43 @section Scrolling
44 @cindex scrolling
46   If a window is too small to display all the text in its buffer, it
47 displays only a portion of it.  @dfn{Scrolling} commands change which
48 portion of the buffer is displayed.
50   Scrolling ``forward'' or ``up'' advances the portion of the buffer
51 displayed in the window; equivalently, it moves the buffer text
52 upwards relative to the window.  Scrolling ``backward'' or ``down''
53 displays an earlier portion of the buffer, and moves the text
54 downwards relative to the window.
56   In Emacs, scrolling ``up'' or ``down'' refers to the direction that
57 the text moves in the window, @emph{not} the direction that the window
58 moves relative to the text.  This terminology was adopted by Emacs
59 before the modern meaning of ``scrolling up'' and ``scrolling down''
60 became widespread.  Hence, the strange result that @key{PageDown}
61 scrolls ``up'' in the Emacs sense.
63   The portion of a buffer displayed in a window always contains point.
64 If you move point past the bottom or top of the window, scrolling
65 occurs automatically to bring it back onscreen (@pxref{Auto
66 Scrolling}).  You can also scroll explicitly with these commands:
68 @table @kbd
69 @item C-v
70 @itemx @key{next}
71 @itemx @key{PageDown}
72 Scroll forward by nearly a full window (@code{scroll-up-command}).
73 @item M-v
74 @itemx @key{prior}
75 @itemx @key{PageUp}
76 Scroll backward (@code{scroll-down-command}).
77 @end table
79 @kindex C-v
80 @kindex M-v
81 @kindex next
82 @kindex prior
83 @kindex PageDown
84 @kindex PageUp
85 @findex scroll-up-command
86 @findex scroll-down-command
87   @kbd{C-v} (@code{scroll-up-command}) scrolls forward by nearly the
88 whole window height.  The effect is to take the two lines at the
89 bottom of the window and put them at the top, followed by lines that
90 were not previously visible.  If point was in the text that scrolled
91 off the top, it ends up on the window's new topmost line.  The
92 @key{next} (or @key{PageDown}) key is equivalent to @kbd{C-v}.
94   @kbd{M-v} (@code{scroll-down-command}) scrolls backward in a similar
95 way.  The @key{prior} (or @key{PageUp}) key is equivalent to
96 @kbd{M-v}.
98 @vindex next-screen-context-lines
99   The number of lines of overlap left by these scroll commands is
100 controlled by the variable @code{next-screen-context-lines}, whose
101 default value is 2.  You can supply the commands with a numeric prefix
102 argument, @var{n}, to scroll by @var{n} lines; Emacs attempts to leave
103 point unchanged, so that the text and point move up or down together.
104 @kbd{C-v} with a negative argument is like @kbd{M-v} and vice versa.
106 @vindex scroll-error-top-bottom
107   By default, these commands signal an error (by beeping or flashing
108 the screen) if no more scrolling is possible, because the window has
109 reached the beginning or end of the buffer.  If you change the
110 variable @code{scroll-error-top-bottom} to @code{t}, the command moves
111 point to the farthest possible position.  If point is already there,
112 the command signals an error.
114 @vindex scroll-preserve-screen-position
115 @cindex @code{scroll-command} property
116   Some users like scroll commands to keep point at the same screen
117 position, so that scrolling back to the same screen conveniently
118 returns point to its original position.  You can enable this behavior
119 via the variable @code{scroll-preserve-screen-position}.  If the value
120 is @code{t}, Emacs adjusts point to keep the cursor at the same screen
121 position whenever a scroll command moves it off-window, rather than
122 moving it to the topmost or bottommost line.  With any other
123 non-@code{nil} value, Emacs adjusts point this way even if the scroll
124 command leaves point in the window.  This variable affects all the
125 scroll commands documented in this section, as well as scrolling with
126 the mouse wheel (@pxref{Mouse Commands}); in general, it affects any
127 command that has a non-@code{nil} @code{scroll-command} property.
128 @xref{Property Lists,,, elisp, The Emacs Lisp Reference Manual}.
130 @vindex scroll-up
131 @vindex scroll-down
132 @findex scroll-up-line
133 @findex scroll-down-line
134   The commands @kbd{M-x scroll-up} and @kbd{M-x scroll-down} behave
135 similarly to @code{scroll-up-command} and @code{scroll-down-command},
136 except they do not obey @code{scroll-error-top-bottom}.  Prior to
137 Emacs 24, these were the default commands for scrolling up and down.
138 The commands @kbd{M-x scroll-up-line} and @kbd{M-x scroll-down-line}
139 scroll the current window by one line at a time.  If you intend to use
140 any of these commands, you might want to give them key bindings
141 (@pxref{Init Rebinding}).
143 @node Recentering
144 @section Recentering
146 @table @kbd
147 @item C-l
148 Scroll the selected window so the current line is the center-most text
149 line; on subsequent consecutive invocations, make the current line the
150 top line, the bottom line, and so on in cyclic order.  Possibly
151 redisplay the screen too (@code{recenter-top-bottom}).
153 @item M-x recenter
154 Scroll the selected window so the current line is the center-most text
155 line.  Possibly redisplay the screen too.
157 @item C-M-l
158 Scroll heuristically to bring useful information onto the screen
159 (@code{reposition-window}).
160 @end table
162 @kindex C-l
163 @findex recenter-top-bottom
164   The @kbd{C-l} (@code{recenter-top-bottom}) command @dfn{recenters}
165 the selected window, scrolling it so that the current screen line is
166 exactly in the center of the window, or as close to the center as
167 possible.
169   Typing @kbd{C-l} twice in a row (@kbd{C-l C-l}) scrolls the window
170 so that point is on the topmost screen line.  Typing a third @kbd{C-l}
171 scrolls the window so that point is on the bottom-most screen line.
172 Each successive @kbd{C-l} cycles through these three positions.
174 @vindex recenter-positions
175   You can change the cycling order by customizing the list variable
176 @code{recenter-positions}.  Each list element should be the symbol
177 @code{top}, @code{middle}, or @code{bottom}, or a number; an integer
178 means to move the line to the specified screen line, while a
179 floating-point number between 0.0 and 1.0 specifies a percentage of
180 the screen space from the top of the window.  The default,
181 @code{(middle top bottom)}, is the cycling order described above.
182 Furthermore, if you change the variable @code{scroll-margin} to a
183 non-zero value @var{n}, @kbd{C-l} always leaves at least @var{n}
184 screen lines between point and the top or bottom of the window
185 (@pxref{Auto Scrolling}).
187   You can also give @kbd{C-l} a prefix argument.  A plain prefix
188 argument, @kbd{C-u C-l}, simply recenters point.  A positive argument
189 @var{n} puts point @var{n} lines down from the top of the window.  An
190 argument of zero puts point on the topmost line.  A negative argument
191 @var{-n} puts point @var{n} lines from the bottom of the window.  When
192 given an argument, @kbd{C-l} does not clear the screen or cycle
193 through different screen positions.
195 @vindex recenter-redisplay
196   If the variable @code{recenter-redisplay} has a non-@code{nil}
197 value, each invocation of @kbd{C-l} also clears and redisplays the
198 screen; the special value @code{tty} (the default) says to do this on
199 text-terminal frames only.  Redisplaying is useful in case the screen
200 becomes garbled for any reason (@pxref{Screen Garbled}).
202 @findex recenter
203   The more primitive command @kbd{M-x recenter} behaves like
204 @code{recenter-top-bottom}, but does not cycle among screen positions.
206 @kindex C-M-l
207 @findex reposition-window
208   @kbd{C-M-l} (@code{reposition-window}) scrolls the current window
209 heuristically in a way designed to get useful information onto the
210 screen.  For example, in a Lisp file, this command tries to get the
211 entire current defun onto the screen if possible.
213 @node Auto Scrolling
214 @section Automatic Scrolling
216   Emacs performs @dfn{automatic scrolling} when point moves out of the
217 visible portion of the text.
219 @vindex scroll-conservatively
220   Normally, this centers point vertically within the window.  However,
221 if you set @code{scroll-conservatively} to a small number @var{n},
222 then if you move point just a little off the screen (less than @var{n}
223 lines), Emacs scrolls the text just far enough to bring point back on
224 screen.  By default, @code{scroll-conservatively} is@tie{}0.  If you
225 set @code{scroll-conservatively} to a large number (larger than 100),
226 Emacs will never center point as result of scrolling, even if point
227 moves far away from the text previously displayed in the window.  With
228 such a large value, Emacs will always scroll text just enough for
229 bringing point into view, so point will end up at the top or bottom of
230 the window, depending on the scroll direction.
232 @vindex scroll-step
233   The variable @code{scroll-step} determines how many lines to scroll
234 the window when point moves off the screen.  If moving by that number
235 of lines fails to bring point back into view, point is centered
236 instead.  The default value is zero, which causes point to always be
237 centered after scrolling.
239 @cindex aggressive scrolling
240 @vindex scroll-up-aggressively
241 @vindex scroll-down-aggressively
242   When the window does scroll by a distance longer than
243 @code{scroll-step}, you can control how aggressively it scrolls by
244 setting the variables @code{scroll-up-aggressively} and
245 @code{scroll-down-aggressively}.  The value of
246 @code{scroll-up-aggressively} should be either @code{nil}, or a
247 fraction @var{f} between 0 and 1.  A fraction specifies where on the
248 screen to put point when scrolling upward, i.e.@: forward.  When point
249 goes off the window end, the new start position is chosen to put point
250 @var{f} parts of the window height from the bottom margin.  Thus,
251 larger @var{f} means more aggressive scrolling: more new text is
252 brought into view.  The default value, @code{nil}, is equivalent to
253 0.5.
255   Likewise, @code{scroll-down-aggressively} is used for scrolling
256 down, i.e.@: backward.  The value specifies how far point should be
257 placed from the top margin of the window; thus, as with
258 @code{scroll-up-aggressively}, a larger value is more aggressive.
260   These two variables are ignored if either @code{scroll-step} or
261 @code{scroll-conservatively} are set to a non-zero value.
263 @vindex scroll-margin
264   The variable @code{scroll-margin} restricts how close point can come
265 to the top or bottom of a window (even if aggressive scrolling
266 specifies a fraction @var{f} that is larger than the window portion
267 between the top and the bottom margins).  Its value is a number of screen
268 lines; if point comes within that many lines of the top or bottom of
269 the window, Emacs performs automatic scrolling.  By default,
270 @code{scroll-margin} is 0.
272 @node Horizontal Scrolling
273 @section Horizontal Scrolling
274 @cindex horizontal scrolling
276 @vindex auto-hscroll-mode
277   @dfn{Horizontal scrolling} means shifting all the lines sideways
278 within a window, so that some of the text near the left margin is not
279 displayed.  When the text in a window is scrolled horizontally, text
280 lines are truncated rather than continued (@pxref{Line Truncation}).
281 If a window shows truncated lines, Emacs performs automatic horizontal
282 scrolling whenever point moves off the left or right edge of the
283 screen.  To disable automatic horizontal scrolling, set the variable
284 @code{auto-hscroll-mode} to @code{nil}.  Note that when the automatic
285 horizontal scrolling is turned off, if point moves off the edge of the
286 screen, the cursor disappears to indicate that.  (On text terminals,
287 the cursor is left at the edge instead.)
289 @vindex hscroll-margin
290   The variable @code{hscroll-margin} controls how close point can get
291 to the window's edges before automatic scrolling occurs.  It is
292 measured in columns.  For example, if the value is 5, then moving
293 point within 5 columns of an edge causes horizontal scrolling away
294 from that edge.
296 @vindex hscroll-step
297   The variable @code{hscroll-step} determines how many columns to
298 scroll the window when point gets too close to the edge.  Zero, the
299 default value, means to center point horizontally within the window.
300 A positive integer value specifies the number of columns to scroll by.
301 A floating-point number specifies the fraction of the window's width
302 to scroll by.
304   You can also perform explicit horizontal scrolling with the
305 following commands:
307 @table @kbd
308 @item C-x <
309 Scroll text in current window to the left (@code{scroll-left}).
310 @item C-x >
311 Scroll to the right (@code{scroll-right}).
312 @end table
314 @kindex C-x <
315 @kindex C-x >
316 @findex scroll-left
317 @findex scroll-right
318   @kbd{C-x <} (@code{scroll-left}) scrolls text in the selected window
319 to the left by the full width of the window, less two columns.  (In
320 other words, the text in the window moves left relative to the
321 window.)  With a numeric argument @var{n}, it scrolls by @var{n}
322 columns.
324   If the text is scrolled to the left, and point moves off the left
325 edge of the window, the cursor will freeze at the left edge of the
326 window, until point moves back to the displayed portion of the text.
327 This is independent of the current setting of
328 @code{auto-hscroll-mode}, which, for text scrolled to the left, only
329 affects the behavior at the right edge of the window.
331   @kbd{C-x >} (@code{scroll-right}) scrolls similarly to the right.
332 The window cannot be scrolled any farther to the right once it is
333 displayed normally, with each line starting at the window's left
334 margin; attempting to do so has no effect.  This means that you don't
335 have to calculate the argument precisely for @w{@kbd{C-x >}}; any
336 sufficiently large argument will restore the normal display.
338   If you use those commands to scroll a window horizontally, that sets
339 a lower bound for automatic horizontal scrolling.  Automatic scrolling
340 will continue to scroll the window, but never farther to the right
341 than the amount you previously set by @code{scroll-left}.
343 @node Narrowing
344 @section Narrowing
345 @cindex widening
346 @cindex restriction
347 @cindex narrowing
348 @cindex accessible portion
350   @dfn{Narrowing} means focusing in on some portion of the buffer,
351 making the rest temporarily inaccessible.  The portion which you can
352 still get to is called the @dfn{accessible portion}.  Canceling the
353 narrowing, which makes the entire buffer once again accessible, is
354 called @dfn{widening}.  The bounds of narrowing in effect in a buffer
355 are called the buffer's @dfn{restriction}.
357   Narrowing can make it easier to concentrate on a single subroutine or
358 paragraph by eliminating clutter.  It can also be used to limit the
359 range of operation of a replace command or repeating keyboard macro.
361 @table @kbd
362 @item C-x n n
363 Narrow down to between point and mark (@code{narrow-to-region}).
364 @item C-x n w
365 Widen to make the entire buffer accessible again (@code{widen}).
366 @item C-x n p
367 Narrow down to the current page (@code{narrow-to-page}).
368 @item C-x n d
369 Narrow down to the current defun (@code{narrow-to-defun}).
370 @end table
372   When you have narrowed down to a part of the buffer, that part appears
373 to be all there is.  You can't see the rest, you can't move into it
374 (motion commands won't go outside the accessible part), you can't change
375 it in any way.  However, it is not gone, and if you save the file all
376 the inaccessible text will be saved.  The word @samp{Narrow} appears in
377 the mode line whenever narrowing is in effect.
379 @kindex C-x n n
380 @findex narrow-to-region
381   The primary narrowing command is @kbd{C-x n n} (@code{narrow-to-region}).
382 It sets the current buffer's restrictions so that the text in the current
383 region remains accessible, but all text before the region or after the
384 region is inaccessible.  Point and mark do not change.
386 @kindex C-x n p
387 @findex narrow-to-page
388 @kindex C-x n d
389 @findex narrow-to-defun
390   Alternatively, use @kbd{C-x n p} (@code{narrow-to-page}) to narrow
391 down to the current page.  @xref{Pages}, for the definition of a page.
392 @kbd{C-x n d} (@code{narrow-to-defun}) narrows down to the defun
393 containing point (@pxref{Defuns}).
395 @kindex C-x n w
396 @findex widen
397   The way to cancel narrowing is to widen with @kbd{C-x n w}
398 (@code{widen}).  This makes all text in the buffer accessible again.
400   You can get information on what part of the buffer you are narrowed down
401 to using the @kbd{C-x =} command.  @xref{Position Info}.
403   Because narrowing can easily confuse users who do not understand it,
404 @code{narrow-to-region} is normally a disabled command.  Attempting to use
405 this command asks for confirmation and gives you the option of enabling it;
406 if you enable the command, confirmation will no longer be required for
407 it.  @xref{Disabling}.
409 @node View Mode
410 @section View Mode
411 @cindex View mode
412 @cindex mode, View
414 @kindex s @r{(View mode)}
415 @kindex SPC @r{(View mode)}
416 @kindex DEL @r{(View mode)}
417   View mode is a minor mode that lets you scan a buffer by sequential
418 screenfuls.  It provides commands for scrolling through the buffer
419 conveniently but not for changing it.  Apart from the usual Emacs
420 cursor motion commands, you can type @key{SPC} to scroll forward one
421 windowful, @key{DEL} to scroll backward, and @kbd{s} to start an
422 incremental search.
424 @kindex q @r{(View mode)}
425 @kindex e @r{(View mode)}
426 @findex View-quit
427 @findex View-exit
428   Typing @kbd{q} (@code{View-quit}) disables View mode, and switches
429 back to the buffer and position before View mode was enabled.  Typing
430 @kbd{e} (@code{View-exit}) disables View mode, keeping the current
431 buffer and position.
433 @findex view-buffer
434 @findex view-file
435   @kbd{M-x view-buffer} prompts for an existing Emacs buffer, switches
436 to it, and enables View mode.  @kbd{M-x view-file} prompts for a file
437 and visits it with View mode enabled.
439 @node Follow Mode
440 @section Follow Mode
441 @cindex Follow mode
442 @cindex mode, Follow
443 @findex follow-mode
444 @cindex windows, synchronizing
445 @cindex synchronizing windows
447   @dfn{Follow mode} is a minor mode that makes two windows, both
448 showing the same buffer, scroll as a single tall ``virtual window''.
449 To use Follow mode, go to a frame with just one window, split it into
450 two side-by-side windows using @kbd{C-x 3}, and then type @kbd{M-x
451 follow-mode}.  From then on, you can edit the buffer in either of the
452 two windows, or scroll either one; the other window follows it.
454   In Follow mode, if you move point outside the portion visible in one
455 window and into the portion visible in the other window, that selects
456 the other window---again, treating the two as if they were parts of
457 one large window.
459   To turn off Follow mode, type @kbd{M-x follow-mode} a second time.
461 @node Faces
462 @section Text Faces
463 @cindex faces
465   Emacs can display text in several different styles, called
466 @dfn{faces}.  Each face can specify various @dfn{face attributes},
467 such as the font, height, weight, slant, foreground and background
468 color, and underlining or overlining.  Most major modes assign faces
469 to the text automatically, via Font Lock mode.  @xref{Font Lock}, for
470 more information about how these faces are assigned.
472 @findex list-faces-display
473   To see what faces are currently defined, and what they look like,
474 type @kbd{M-x list-faces-display}.  With a prefix argument, this
475 prompts for a regular expression, and displays only faces with names
476 matching that regular expression (@pxref{Regexps}).
478 @vindex frame-background-mode
479   It's possible for a given face to look different in different
480 frames.  For instance, some text terminals do not support all face
481 attributes, particularly font, height, and width, and some support a
482 limited range of colors.  In addition, most Emacs faces are defined so
483 that their attributes are different on light and dark frame
484 backgrounds, for reasons of legibility.  By default, Emacs
485 automatically chooses which set of face attributes to display on each
486 frame, based on the frame's current background color.  However, you
487 can override this by giving the variable @code{frame-background-mode}
488 a non-@code{nil} value.  A value of @code{dark} makes Emacs treat all
489 frames as if they have a dark background, whereas a value of
490 @code{light} makes it treat all frames as if they have a light
491 background.
493 @cindex background color
494 @cindex default face
495   You can customize a face to alter its attributes, and save those
496 customizations for future Emacs sessions.  @xref{Face Customization},
497 for details.
499   The @code{default} face is the default for displaying text, and all
500 of its attributes are specified.  Its background color is also used as
501 the frame's background color.  @xref{Colors}.
503 @cindex cursor face
504   Another special face is the @code{cursor} face.  On graphical
505 displays, the background color of this face is used to draw the text
506 cursor.  None of the other attributes of this face have any effect;
507 the foreground color for text under the cursor is taken from the
508 background color of the underlying text.  On text terminals, the
509 appearance of the text cursor is determined by the terminal, not by
510 the @code{cursor} face.
512   You can also use X resources to specify attributes of any particular
513 face.  @xref{Resources}.
515   Emacs can display variable-width fonts, but some Emacs commands,
516 particularly indentation commands, do not account for variable
517 character display widths.  Therefore, we recommend not using
518 variable-width fonts for most faces, particularly those assigned by
519 Font Lock mode.
521 @node Colors
522 @section Colors for Faces
523 @cindex color name
524 @cindex RGB triplet
526   Faces can have various foreground and background colors.  When you
527 specify a color for a face---for instance, when customizing the face
528 (@pxref{Face Customization})---you can use either a @dfn{color name}
529 or an @dfn{RGB triplet}.
531 @findex list-colors-display
532 @vindex list-colors-sort
533   A color name is a pre-defined name, such as @samp{dark orange} or
534 @samp{medium sea green}.  To view a list of color names, type @kbd{M-x
535 list-colors-display}.  To control the order in which colors are shown,
536 customize @code{list-colors-sort}.  If you run this command on a
537 graphical display, it shows the full range of color names known to
538 Emacs (these are the standard X11 color names, defined in X's
539 @file{rgb.txt} file).  If you run the command on a text terminal, it
540 shows only a small subset of colors that can be safely displayed on
541 such terminals.  However, Emacs understands X11 color names even on
542 text terminals; if a face is given a color specified by an X11 color
543 name, it is displayed using the closest-matching terminal color.
545   An RGB triplet is a string of the form @samp{#RRGGBB}.  Each of the
546 R, G, and B components is a hexadecimal number specifying the
547 component's relative intensity, one to four digits long (usually two
548 digits are used).  The components must have the same number of digits.
549 For hexadecimal values A to F, either upper or lower case are
550 acceptable.
552   The @kbd{M-x list-colors-display} command also shows the equivalent
553 RGB triplet for each named color.  For instance, @samp{medium sea
554 green} is equivalent to @samp{#3CB371}.
556 @cindex face colors, setting
557 @findex set-face-foreground
558 @findex set-face-background
559   You can change the foreground and background colors of a face with
560 @kbd{M-x set-face-foreground} and @kbd{M-x set-face-background}.
561 These commands prompt in the minibuffer for a face name and a color,
562 with completion, and then set that face to use the specified color.
563 They affect the face colors on all frames, but their effects do not
564 persist for future Emacs sessions, unlike using the customization
565 buffer or X resources.  You can also use frame parameters to set
566 foreground and background colors for a specific frame; @xref{Frame
567 Parameters}.
569 @node Standard Faces
570 @section Standard Faces
572   Here are the standard faces for specifying text appearance.  You can
573 apply them to specific text when you want the effects they produce.
575 @table @code
576 @item default
577 This face is used for ordinary text that doesn't specify any face.
578 Its background color is used as the frame's background color.
579 @item bold
580 This face uses a bold variant of the default font.
581 @item italic
582 This face uses an italic variant of the default font.
583 @item bold-italic
584 This face uses a bold italic variant of the default font.
585 @item underline
586 This face underlines text.
587 @item fixed-pitch
588 This face forces use of a fixed-width font.  It's reasonable to
589 customize this face to use a different fixed-width font, if you like,
590 but you should not make it a variable-width font.
591 @item variable-pitch
592 This face forces use of a variable-width font.
593 @item shadow
594 This face is used for making the text less noticeable than the surrounding
595 ordinary text.  Usually this can be achieved by using shades of gray in
596 contrast with either black or white default foreground color.
597 @end table
599   Here's an incomplete list of faces used to highlight parts of the
600 text temporarily for specific purposes.  (Many other modes define
601 their own faces for this purpose.)
603 @table @code
604 @item highlight
605 This face is used for text highlighting in various contexts, such as
606 when the mouse cursor is moved over a hyperlink.
607 @item isearch
608 This face is used to highlight the current Isearch match
609 (@pxref{Incremental Search}).
610 @item query-replace
611 This face is used to highlight the current Query Replace match
612 (@pxref{Replace}).
613 @item lazy-highlight
614 This face is used to highlight ``lazy matches'' for Isearch and Query
615 Replace (matches other than the current one).
616 @item region
617 This face is used for displaying an active region (@pxref{Mark}).
618 When Emacs is built with GTK support, its colors are taken from the
619 current GTK theme.
620 @item secondary-selection
621 This face is used for displaying a secondary X selection (@pxref{Secondary
622 Selection}).
623 @item trailing-whitespace
624 The face for highlighting excess spaces and tabs at the end of a line
625 when @code{show-trailing-whitespace} is non-@code{nil} (@pxref{Useless
626 Whitespace}).
627 @item escape-glyph
628 The face for displaying control characters and escape sequences
629 (@pxref{Text Display}).
630 @item nobreak-space
631 The face for displaying ``no-break'' space characters (@pxref{Text
632 Display}).
633 @end table
635   The following faces control the appearance of parts of the Emacs
636 frame:
638 @table @code
639 @item mode-line
640 This face is used for the mode line of the currently selected window,
641 and for menu bars when toolkit menus are not used.  By default, it's
642 drawn with shadows for a ``raised'' effect on graphical displays, and
643 drawn as the inverse of the default face on non-windowed terminals.
644 @item mode-line-inactive
645 Like @code{mode-line}, but used for mode lines of the windows other
646 than the selected one (if @code{mode-line-in-non-selected-windows} is
647 non-@code{nil}).  This face inherits from @code{mode-line}, so changes
648 in that face affect mode lines in all windows.
649 @item mode-line-highlight
650 Like @code{highlight}, but used for portions of text on mode lines.
651 @item mode-line-buffer-id
652 This face is used for buffer identification parts in the mode line.
653 @item header-line
654 Similar to @code{mode-line} for a window's header line, which appears
655 at the top of a window just as the mode line appears at the bottom.
656 Most windows do not have a header line---only some special modes, such
657 Info mode, create one.
658 @item vertical-border
659 This face is used for the vertical divider between windows on text
660 terminals.
661 @item minibuffer-prompt
662 @cindex @code{minibuffer-prompt} face
663 @vindex minibuffer-prompt-properties
664 This face is used for the prompt strings displayed in the minibuffer.
665 By default, Emacs automatically adds this face to the value of
666 @code{minibuffer-prompt-properties}, which is a list of text
667 properties used to display the prompt text.  (This variable takes
668 effect when you enter the minibuffer.)
669 @item fringe
670 @cindex @code{fringe} face
671 The face for the fringes to the left and right of windows on graphic
672 displays.  (The fringes are the narrow portions of the Emacs frame
673 between the text area and the window's right and left borders.)
674 @xref{Fringes}.
675 @item cursor
676 The @code{:background} attribute of this face specifies the color of
677 the text cursor.  @xref{Cursor Display}.
678 @item tooltip
679 This face is used for tooltip text.  By default, if Emacs is built
680 with GTK support, tooltips are drawn via GTK and this face has no
681 effect.  @xref{Tooltips}.
682 @item mouse
683 This face determines the color of the mouse pointer.
684 @end table
686   The following faces likewise control the appearance of parts of the
687 Emacs frame, but only on text terminals, or when Emacs is built on X
688 with no toolkit support.  (For all other cases, the appearance of the
689 respective frame elements is determined by system-wide settings.)
691 @table @code
692 @item scroll-bar
693 This face determines the visual appearance of the scroll bar.
694 @xref{Scroll Bars}.
695 @item tool-bar
696 This face determines the color of tool bar icons.  @xref{Tool Bars}.
697 @item menu
698 @cindex menu bar appearance
699 @cindex @code{menu} face, no effect if customized
700 @cindex customization of @code{menu} face
701 This face determines the colors and font of Emacs's menus.  @xref{Menu
702 Bars}.
703 @end table
705 @node Text Scale
706 @section Text Scale
708 @cindex adjust buffer face height
709 @findex text-scale-adjust
710 @kindex C-x C-+
711 @kindex C-x C--
712 @kindex C-x C-=
713 @kindex C-x C-0
714   To increase the height of the default face in the current buffer,
715 type @kbd{C-x C-+} or @kbd{C-x C-=}.  To decrease it, type @kbd{C-x
716 C--}.  To restore the default (global) face height, type @kbd{C-x
717 C-0}.  These keys are all bound to the same command,
718 @code{text-scale-adjust}, which looks at the last key typed to
719 determine which action to take.
721   The final key of these commands may be repeated without the leading
722 @kbd{C-x}.  For instance, @kbd{C-x C-= C-= C-=} increases the face
723 height by three steps.  Each step scales the text height by a factor
724 of 1.2; to change this factor, customize the variable
725 @code{text-scale-mode-step}.  As an exception, a numeric argument of 0
726 to the @code{text-scale-adjust} command restores the default height,
727 similar to typing @kbd{C-x C-0}.
729 @cindex increase buffer face height
730 @findex text-scale-increase
731 @cindex decrease buffer face height
732 @findex text-scale-decrease
733   The commands @code{text-scale-increase} and
734 @code{text-scale-decrease} increase or decrease the height of the
735 default face, just like @kbd{C-x C-+} and @kbd{C-x C--} respectively.
736 You may find it convenient to bind to these commands, rather than
737 @code{text-scale-adjust}.
739 @cindex set buffer face height
740 @findex text-scale-set
741   The command @code{text-scale-set} scales the height of the default
742 face in the current buffer to an absolute level specified by its
743 prefix argument.
745 @findex text-scale-mode
746   The above commands automatically enable the minor mode
747 @code{text-scale-mode} if the current font scaling is other than 1,
748 and disable it otherwise.
750 @node Font Lock
751 @section Font Lock mode
752 @cindex Font Lock mode
753 @cindex mode, Font Lock
754 @cindex syntax highlighting and coloring
756   Font Lock mode is a minor mode, always local to a particular buffer,
757 which assigns faces to (or @dfn{fontifies}) the text in the buffer.
758 Each buffer's major mode tells Font Lock mode which text to fontify;
759 for instance, programming language modes fontify syntactically
760 relevant constructs like comments, strings, and function names.
762 @findex font-lock-mode
763   Font Lock mode is enabled by default.  To toggle it in the current
764 buffer, type @kbd{M-x font-lock-mode}.  A positive numeric argument
765 unconditionally enables Font Lock mode, and a negative or zero
766 argument disables it.
768 @findex global-font-lock-mode
769 @vindex global-font-lock-mode
770   Type @kbd{M-x global-font-lock-mode} to toggle Font Lock mode in all
771 buffers.  To impose this setting for future Emacs sessions, customize
772 the variable @code{global-font-lock-mode} (@pxref{Easy
773 Customization}), or add the following line to your init file:
775 @example
776 (global-font-lock-mode 0)
777 @end example
779 @noindent
780 If you have disabled Global Font Lock mode, you can still enable Font
781 Lock for specific major modes by adding the function
782 @code{font-lock-mode} to the mode hooks (@pxref{Hooks}).  For example,
783 to enable Font Lock mode for editing C files, you can do this:
785 @example
786 (add-hook 'c-mode-hook 'font-lock-mode)
787 @end example
789   Font Lock mode uses several specifically named faces to do its job,
790 including @code{font-lock-string-face}, @code{font-lock-comment-face},
791 and others.  The easiest way to find them all is to use @kbd{M-x
792 customize-group @key{RET} font-lock-faces @key{RET}}.  You can then
793 use that customization buffer to customize the appearance of these
794 faces.  @xref{Face Customization}.
796 @vindex font-lock-maximum-decoration
797   You can customize the variable @code{font-lock-maximum-decoration}
798 to alter the amount of fontification applied by Font Lock mode, for
799 major modes that support this feature.  The value should be a number
800 (with 1 representing a minimal amount of fontification; some modes
801 support levels as high as 3); or @code{t}, meaning ``as high as
802 possible'' (the default).  You can also specify different numbers for
803 particular major modes; for example, to use level 1 for C/C++ modes,
804 and the default level otherwise, use the value
806 @example
807 '((c-mode . 1) (c++-mode . 1)))
808 @end example
810 @vindex font-lock-beginning-of-syntax-function
811 @cindex incorrect fontification
812 @cindex parenthesis in column zero and fontification
813 @cindex brace in column zero and fontification
814   Comment and string fontification (or ``syntactic'' fontification)
815 relies on analysis of the syntactic structure of the buffer text.  For
816 the sake of speed, some modes, including Lisp mode, rely on a special
817 convention: an open-parenthesis or open-brace in the leftmost column
818 always defines the beginning of a defun, and is thus always outside
819 any string or comment.  Therefore, you should avoid placing an
820 open-parenthesis or open-brace in the leftmost column, if it is inside
821 a string or comment.  @xref{Left Margin Paren}, for details.
823 @cindex slow display during scrolling
824   The variable @code{font-lock-beginning-of-syntax-function}, which is
825 always buffer-local, specifies how Font Lock mode can find a position
826 guaranteed to be outside any comment or string.  In modes which use
827 the leftmost column parenthesis convention, the default value of the
828 variable is @code{beginning-of-defun}---that tells Font Lock mode to
829 use the convention.  If you set this variable to @code{nil}, Font Lock
830 no longer relies on the convention.  This avoids incorrect results,
831 but the price is that, in some cases, fontification for a changed text
832 must rescan buffer text from the beginning of the buffer.  This can
833 considerably slow down redisplay while scrolling, particularly if you
834 are close to the end of a large buffer.
836 @findex font-lock-add-keywords
837   Font Lock highlighting patterns already exist for most modes, but
838 you may want to fontify additional patterns.  You can use the function
839 @code{font-lock-add-keywords}, to add your own highlighting patterns
840 for a particular mode.  For example, to highlight @samp{FIXME:} words
841 in C comments, use this:
843 @example
844 (add-hook 'c-mode-hook
845           (lambda ()
846            (font-lock-add-keywords nil
847             '(("\\<\\(FIXME\\):" 1
848                font-lock-warning-face t)))))
849 @end example
851 @findex font-lock-remove-keywords
852 @noindent
853 To remove keywords from the font-lock highlighting patterns, use the
854 function @code{font-lock-remove-keywords}.  @xref{Search-based
855 Fontification,,, elisp, The Emacs Lisp Reference Manual}.
857 @cindex just-in-time (JIT) font-lock
858 @cindex background syntax highlighting
859   Fontifying large buffers can take a long time.  To avoid large
860 delays when a file is visited, Emacs initially fontifies only the
861 visible portion of a buffer.  As you scroll through the buffer, each
862 portion that becomes visible is fontified as soon as it is displayed;
863 this type of Font Lock is called @dfn{Just-In-Time} (or @dfn{JIT})
864 Lock.  You can control how JIT Lock behaves, including telling it to
865 perform fontification while idle, by customizing variables in the
866 customization group @samp{jit-lock}.  @xref{Specific Customization}.
868 @node Highlight Interactively
869 @section Interactive Highlighting
870 @cindex highlighting by matching
871 @cindex interactive highlighting
872 @cindex Highlight Changes mode
874 @findex highlight-changes-mode
875 Highlight Changes mode is a minor mode that @dfn{highlights} the parts
876 of the buffer that were changed most recently, by giving that text a
877 different face.  To enable or disable Highlight Changes mode, use
878 @kbd{M-x highlight-changes-mode}.
880 @cindex Hi Lock mode
881 @findex hi-lock-mode
882   Hi Lock mode is a minor mode that highlights text that matches
883 regular expressions you specify.  For example, you can use it to
884 highlight all the references to a certain variable in a program source
885 file, highlight certain parts in a voluminous output of some program,
886 or highlight certain names in an article.  To enable or disable Hi
887 Lock mode, use the command @kbd{M-x hi-lock-mode}.  To enable Hi Lock
888 mode for all buffers, use @kbd{M-x global-hi-lock-mode} or place
889 @code{(global-hi-lock-mode 1)} in your @file{.emacs} file.
891   Hi Lock mode works like Font Lock mode (@pxref{Font Lock}), except
892 that you specify explicitly the regular expressions to highlight.  You
893 control them with these commands:
895 @table @kbd
896 @item C-x w h @var{regexp} @key{RET} @var{face} @key{RET}
897 @kindex C-x w h
898 @findex highlight-regexp
899 Highlight text that matches @var{regexp} using face @var{face}
900 (@code{highlight-regexp}).  The highlighting will remain as long as
901 the buffer is loaded.  For example, to highlight all occurrences of
902 the word ``whim'' using the default face (a yellow background)
903 @kbd{C-x w h whim @key{RET} @key{RET}}.  Any face can be used for
904 highlighting, Hi Lock provides several of its own and these are
905 pre-loaded into a list of default values.  While being prompted
906 for a face use @kbd{M-n} and @kbd{M-p} to cycle through them.
908 You can use this command multiple times, specifying various regular
909 expressions to highlight in different ways.
911 @item C-x w r @var{regexp} @key{RET}
912 @kindex C-x w r
913 @findex unhighlight-regexp
914 Unhighlight @var{regexp} (@code{unhighlight-regexp}).
916 If you invoke this from the menu, you select the expression to
917 unhighlight from a list.  If you invoke this from the keyboard, you
918 use the minibuffer.  It will show the most recently added regular
919 expression; use @kbd{M-p} to show the next older expression and
920 @kbd{M-n} to select the next newer expression.  (You can also type the
921 expression by hand, with completion.)  When the expression you want to
922 unhighlight appears in the minibuffer, press @kbd{@key{RET}} to exit
923 the minibuffer and unhighlight it.
925 @item C-x w l @var{regexp} @key{RET} @var{face} @key{RET}
926 @kindex C-x w l
927 @findex highlight-lines-matching-regexp
928 @cindex lines, highlighting
929 @cindex highlighting lines of text
930 Highlight entire lines containing a match for @var{regexp}, using face
931 @var{face} (@code{highlight-lines-matching-regexp}).
933 @item C-x w b
934 @kindex C-x w b
935 @findex hi-lock-write-interactive-patterns
936 Insert all the current highlighting regexp/face pairs into the buffer
937 at point, with comment delimiters to prevent them from changing your
938 program.  (This key binding runs the
939 @code{hi-lock-write-interactive-patterns} command.)
941 These patterns are extracted from the comments, if appropriate, if you
942 invoke @kbd{M-x hi-lock-find-patterns}, or if you visit the file while
943 Hi Lock mode is enabled (since that runs @code{hi-lock-find-patterns}).
945 @item C-x w i
946 @kindex C-x w i
947 @findex hi-lock-find-patterns
948 Extract regexp/face pairs from comments in the current buffer
949 (@code{hi-lock-find-patterns}).  Thus, you can enter patterns
950 interactively with @code{highlight-regexp}, store them into the file
951 with @code{hi-lock-write-interactive-patterns}, edit them (perhaps
952 including different faces for different parenthesized parts of the
953 match), and finally use this command (@code{hi-lock-find-patterns}) to
954 have Hi Lock highlight the edited patterns.
956 @vindex hi-lock-file-patterns-policy
957 The variable @code{hi-lock-file-patterns-policy} controls whether Hi
958 Lock mode should automatically extract and highlight patterns found in a
959 file when it is visited.  Its value can be @code{nil} (never highlight),
960 @code{ask} (query the user), or a function.  If it is a function,
961 @code{hi-lock-find-patterns} calls it with the patterns as argument; if
962 the function returns non-@code{nil}, the patterns are used.  The default
963 is @code{ask}.  Note that patterns are always highlighted if you call
964 @code{hi-lock-find-patterns} directly, regardless of the value of this
965 variable.
967 @vindex hi-lock-exclude-modes
968 Also, @code{hi-lock-find-patterns} does nothing if the current major
969 mode's symbol is a member of the list @code{hi-lock-exclude-modes}.
970 @end table
972 @node Fringes
973 @section Window Fringes
974 @cindex fringes
976 @findex set-fringe-style
977 @findex fringe-mode
978   On graphical displays, each Emacs window normally has narrow
979 @dfn{fringes} on the left and right edges.  The fringes are used to
980 display symbols that provide information about the text in the window.
981 You can type @kbd{M-x fringe-mode} to disable the fringes, or modify
982 their width.  This command affects fringes in all frames; to modify
983 fringes on the selected frame only, use @kbd{M-x set-fringe-style}.
985   The most common use of the fringes is to indicate a continuation
986 line (@pxref{Continuation Lines}).  When one line of text is split
987 into multiple screen lines, the left fringe shows a curving arrow for
988 each screen line except the first, indicating that ``this is not the
989 real beginning''.  The right fringe shows a curving arrow for each
990 screen line except the last, indicating that ``this is not the real
991 end''.  If the line's direction is right-to-left (@pxref{Bidirectional
992 Editing}), the meanings of the curving arrows in the fringes are
993 swapped.
995   The fringes indicate line truncation with short horizontal arrows
996 meaning ``there's more text on this line which is scrolled
997 horizontally out of view''.  Clicking the mouse on one of the arrows
998 scrolls the display horizontally in the direction of the arrow.
1000   The fringes can also indicate other things, such as buffer
1001 boundaries (@pxref{Displaying Boundaries}), and where a program you
1002 are debugging is executing (@pxref{Debuggers}).
1004 @vindex overflow-newline-into-fringe
1005   The fringe is also used for drawing the cursor, if the current line
1006 is exactly as wide as the window and point is at the end of the line.
1007 To disable this, change the variable
1008 @code{overflow-newline-into-fringe} to @code{nil}; this causes Emacs
1009 to continue or truncate lines that are exactly as wide as the window.
1011 @node Displaying Boundaries
1012 @section Displaying Boundaries
1014 @vindex indicate-buffer-boundaries
1015   On graphical displays, Emacs can indicate the buffer boundaries in
1016 the fringes.  If you enable this feature, the first line and the last
1017 line are marked with angle images in the fringes.  This can be
1018 combined with up and down arrow images which say whether it is
1019 possible to scroll the window.
1021   The buffer-local variable @code{indicate-buffer-boundaries} controls
1022 how the buffer boundaries and window scrolling is indicated in the
1023 fringes.  If the value is @code{left} or @code{right}, both angle and
1024 arrow bitmaps are displayed in the left or right fringe, respectively.
1026   If value is an alist, each element @code{(@var{indicator} .
1027 @var{position})} specifies the position of one of the indicators.
1028 The @var{indicator} must be one of @code{top}, @code{bottom},
1029 @code{up}, @code{down}, or @code{t} which specifies the default
1030 position for the indicators not present in the alist.
1031 The @var{position} is one of @code{left}, @code{right}, or @code{nil}
1032 which specifies not to show this indicator.
1034   For example, @code{((top . left) (t . right))} places the top angle
1035 bitmap in left fringe, the bottom angle bitmap in right fringe, and
1036 both arrow bitmaps in right fringe.  To show just the angle bitmaps in
1037 the left fringe, but no arrow bitmaps, use @code{((top .  left)
1038 (bottom . left))}.
1040 @node Useless Whitespace
1041 @section Useless Whitespace
1043 @cindex trailing whitespace
1044 @cindex whitespace, trailing
1045 @vindex show-trailing-whitespace
1046   It is easy to leave unnecessary spaces at the end of a line, or
1047 empty lines at the end of a file, without realizing it.  In most
1048 cases, this @dfn{trailing whitespace} has no effect, but there are
1049 special circumstances where it matters, and it can be a nuisance.
1051   You can make trailing whitespace at the end of a line visible by
1052 setting the buffer-local variable @code{show-trailing-whitespace} to
1053 @code{t}.  Then Emacs displays trailing whitespace, using the face
1054 @code{trailing-whitespace}.
1056   This feature does not apply when point is at the end of the line
1057 containing the whitespace.  Strictly speaking, that is ``trailing
1058 whitespace'' nonetheless, but displaying it specially in that case
1059 looks ugly while you are typing in new text.  In this special case,
1060 the location of point is enough to show you that the spaces are
1061 present.
1063 @findex delete-trailing-whitespace
1064   Type @kbd{M-x delete-trailing-whitespace} to delete all trailing
1065 whitespace within the buffer.  If the region is active, it deletes all
1066 trailing whitespace in the region instead.
1068 @vindex indicate-empty-lines
1069 @cindex unused lines
1070 @cindex fringes, and unused line indication
1071   On graphical displays, Emacs can indicate unused lines at the end of
1072 the window with a small image in the left fringe (@pxref{Fringes}).
1073 The image appears for screen lines that do not correspond to any
1074 buffer text, so blank lines at the end of the buffer stand out because
1075 they lack this image.  To enable this feature, set the buffer-local
1076 variable @code{indicate-empty-lines} to a non-@code{nil} value.  You
1077 can enable or disable this feature for all new buffers by setting the
1078 default value of this variable, e.g.@: @code{(setq-default
1079 indicate-empty-lines t)}.
1081 @cindex Whitespace mode
1082 @cindex mode, Whitespace
1083 @findex whitespace-mode
1084 @vindex whitespace-style
1085   Whitespace mode is a buffer-local minor mode that lets you
1086 ``visualize'' many kinds of whitespace in the buffer, by either
1087 drawing the whitespace characters with a special face or displaying
1088 them as special glyphs.  To toggle this mode, type @kbd{M-x
1089 whitespace-mode}.  The kinds of whitespace visualized are determined
1090 by the list variable @code{whitespace-style}.  Here is a partial list
1091 of possible elements (see the variable's documentation for the full
1092 list):
1094 @table @code
1095 @item face
1096 Enable all visualizations which use special faces.  This element has a
1097 special meaning: if it is absent from the list, none of the other
1098 visualizations take effect except @code{space-mark}, @code{tab-mark},
1099 and @code{newline-mark}.
1101 @item trailing
1102 Highlight trailing whitespace.
1104 @item tabs
1105 Highlight tab characters.
1107 @item spaces
1108 Highlight space and non-breaking space characters.
1110 @item lines
1111 @vindex whitespace-line-column
1112 Highlight lines longer than 80 lines.  To change the column limit,
1113 customize the variable @code{whitespace-line-column}.
1115 @item newline
1116 Highlight newlines.
1118 @item empty
1119 Highlight empty lines.
1121 @item space-mark
1122 Draw space and non-breaking characters with a special glyph.
1124 @item tab-mark
1125 Draw tab characters with a special glyph.
1127 @item newline-mark
1128 Draw newline characters with a special glyph.
1129 @end table
1131 @node Selective Display
1132 @section Selective Display
1133 @cindex selective display
1134 @findex set-selective-display
1135 @kindex C-x $
1137   Emacs has the ability to hide lines indented more than a given
1138 number of columns.  You can use this to get an overview of a part of a
1139 program.
1141   To hide lines in the current buffer, type @kbd{C-x $}
1142 (@code{set-selective-display}) with a numeric argument @var{n}.  Then
1143 lines with at least @var{n} columns of indentation disappear from the
1144 screen.  The only indication of their presence is that three dots
1145 (@samp{@dots{}}) appear at the end of each visible line that is
1146 followed by one or more hidden ones.
1148   The commands @kbd{C-n} and @kbd{C-p} move across the hidden lines as
1149 if they were not there.
1151   The hidden lines are still present in the buffer, and most editing
1152 commands see them as usual, so you may find point in the middle of the
1153 hidden text.  When this happens, the cursor appears at the end of the
1154 previous line, after the three dots.  If point is at the end of the
1155 visible line, before the newline that ends it, the cursor appears before
1156 the three dots.
1158   To make all lines visible again, type @kbd{C-x $} with no argument.
1160 @vindex selective-display-ellipses
1161   If you set the variable @code{selective-display-ellipses} to
1162 @code{nil}, the three dots do not appear at the end of a line that
1163 precedes hidden lines.  Then there is no visible indication of the
1164 hidden lines.  This variable becomes local automatically when set.
1166   See also @ref{Outline Mode} for another way to hide part of
1167 the text in a buffer.
1169 @node Optional Mode Line
1170 @section Optional Mode Line Features
1172 @cindex buffer size display
1173 @cindex display of buffer size
1174 @findex size-indication-mode
1175   The buffer percentage @var{pos} indicates the percentage of the
1176 buffer above the top of the window.  You can additionally display the
1177 size of the buffer by typing @kbd{M-x size-indication-mode} to turn on
1178 Size Indication mode.  The size will be displayed immediately
1179 following the buffer percentage like this:
1181 @example
1182 @var{POS} of @var{SIZE}
1183 @end example
1185 @noindent
1186 Here @var{SIZE} is the human readable representation of the number of
1187 characters in the buffer, which means that @samp{k} for 10^3, @samp{M}
1188 for 10^6, @samp{G} for 10^9, etc., are used to abbreviate.
1190 @cindex line number display
1191 @cindex display of line number
1192 @findex line-number-mode
1193   The current line number of point appears in the mode line when Line
1194 Number mode is enabled.  Use the command @kbd{M-x line-number-mode} to
1195 turn this mode on and off; normally it is on.  The line number appears
1196 after the buffer percentage @var{pos}, with the letter @samp{L} to
1197 indicate what it is.
1199 @cindex Column Number mode
1200 @cindex mode, Column Number
1201 @findex column-number-mode
1202   Similarly, you can display the current column number by turning on
1203 Column number mode with @kbd{M-x column-number-mode}.  The column
1204 number is indicated by the letter @samp{C}.  However, when both of
1205 these modes are enabled, the line and column numbers are displayed in
1206 parentheses, the line number first, rather than with @samp{L} and
1207 @samp{C}.  For example: @samp{(561,2)}.  @xref{Minor Modes}, for more
1208 information about minor modes and about how to use these commands.
1210 @cindex narrowing, and line number display
1211   If you have narrowed the buffer (@pxref{Narrowing}), the displayed
1212 line number is relative to the accessible portion of the buffer.
1213 Thus, it isn't suitable as an argument to @code{goto-line}.  (Use
1214 @code{what-line} command to see the line number relative to the whole
1215 file.)
1217 @vindex line-number-display-limit
1218   If the buffer is very large (larger than the value of
1219 @code{line-number-display-limit}), Emacs won't compute the line
1220 number, because that would be too slow; therefore, the line number
1221 won't appear on the mode-line.  To remove this limit, set
1222 @code{line-number-display-limit} to @code{nil}.
1224 @vindex line-number-display-limit-width
1225   Line-number computation can also be slow if the lines in the buffer
1226 are too long.  For this reason, Emacs doesn't display line numbers if
1227 the average width, in characters, of lines near point is larger than
1228 the value of @code{line-number-display-limit-width}.  The default
1229 value is 200 characters.
1231 @findex display-time
1232 @cindex time (on mode line)
1233   Emacs can optionally display the time and system load in all mode
1234 lines.  To enable this feature, type @kbd{M-x display-time} or customize
1235 the option @code{display-time-mode}.  The information added to the mode
1236 line looks like this:
1238 @example
1239 @var{hh}:@var{mm}pm @var{l.ll}
1240 @end example
1242 @noindent
1243 @vindex display-time-24hr-format
1244 Here @var{hh} and @var{mm} are the hour and minute, followed always by
1245 @samp{am} or @samp{pm}.  @var{l.ll} is the average number, collected
1246 for the last few minutes, of processes in the whole system that were
1247 either running or ready to run (i.e.@: were waiting for an available
1248 processor).  (Some fields may be missing if your operating system
1249 cannot support them.)  If you prefer time display in 24-hour format,
1250 set the variable @code{display-time-24hr-format} to @code{t}.
1252 @cindex mail (on mode line)
1253 @vindex display-time-use-mail-icon
1254 @vindex display-time-mail-face
1255 @vindex display-time-mail-file
1256 @vindex display-time-mail-directory
1257   The word @samp{Mail} appears after the load level if there is mail
1258 for you that you have not read yet.  On graphical displays, you can
1259 use an icon instead of @samp{Mail} by customizing
1260 @code{display-time-use-mail-icon}; this may save some space on the
1261 mode line.  You can customize @code{display-time-mail-face} to make
1262 the mail indicator prominent.  Use @code{display-time-mail-file} to
1263 specify the mail file to check, or set
1264 @code{display-time-mail-directory} to specify the directory to check
1265 for incoming mail (any nonempty regular file in the directory is
1266 considered as ``newly arrived mail'').
1268 @cindex mail (on mode line)
1269 @findex display-battery-mode
1270 @vindex display-battery-mode
1271 @vindex battery-mode-line-format
1272   When running Emacs on a laptop computer, you can display the battery
1273 charge on the mode-line, by using the command
1274 @code{display-battery-mode} or customizing the variable
1275 @code{display-battery-mode}.  The variable
1276 @code{battery-mode-line-format} determines the way the battery charge
1277 is displayed; the exact mode-line message depends on the operating
1278 system, and it usually shows the current battery charge as a
1279 percentage of the total charge.
1281 @cindex mode line, 3D appearance
1282 @cindex attributes of mode line, changing
1283 @cindex non-integral number of lines in a window
1284   On graphical displays, the mode line is drawn as a 3D box.  If you
1285 don't like this effect, you can disable it by customizing the
1286 @code{mode-line} face and setting its @code{box} attribute to
1287 @code{nil}.  @xref{Face Customization}.
1289 @cindex non-selected windows, mode line appearance
1290   By default, the mode line of nonselected windows is displayed in a
1291 different face, called @code{mode-line-inactive}.  Only the selected
1292 window is displayed in the @code{mode-line} face.  This helps show
1293 which window is selected.  When the minibuffer is selected, since
1294 it has no mode line, the window from which you activated the minibuffer
1295 has its mode line displayed using @code{mode-line}; as a result,
1296 ordinary entry to the minibuffer does not change any mode lines.
1298 @vindex mode-line-in-non-selected-windows
1299   You can disable use of @code{mode-line-inactive} by setting variable
1300 @code{mode-line-in-non-selected-windows} to @code{nil}; then all mode
1301 lines are displayed in the @code{mode-line} face.
1303 @vindex eol-mnemonic-unix
1304 @vindex eol-mnemonic-dos
1305 @vindex eol-mnemonic-mac
1306 @vindex eol-mnemonic-undecided
1307   You can customize the mode line display for each of the end-of-line
1308 formats by setting each of the variables @code{eol-mnemonic-unix},
1309 @code{eol-mnemonic-dos}, @code{eol-mnemonic-mac}, and
1310 @code{eol-mnemonic-undecided} to the strings you prefer.
1312 @node Text Display
1313 @section How Text Is Displayed
1314 @cindex characters (in text)
1315 @cindex printing character
1317   Most characters are @dfn{printing characters}: when they appear in a
1318 buffer, they are displayed literally on the screen.  Printing
1319 characters include @acronym{ASCII} numbers, letters, and punctuation
1320 characters, as well as many non-@acronym{ASCII} characters.
1322 @vindex tab-width
1323 @cindex control characters on display
1324   The @acronym{ASCII} character set contains non-printing @dfn{control
1325 characters}.  Two of these are displayed specially: the newline
1326 character (Unicode code point @code{U+000A}) is displayed by starting
1327 a new line, while the tab character (@code{U+0009}) is displayed as a
1328 space that extends to the next tab stop column (normally every 8
1329 columns).  The number of spaces per tab is controlled by the
1330 buffer-local variable @code{tab-width}, which must have an integer
1331 value between 1 and 1000, inclusive.  Note that how the tab character
1332 in the buffer is displayed has nothing to do with the definition of
1333 @key{TAB} as a command.
1335   Other @acronym{ASCII} control characters, whose codes are below
1336 @code{U+0020} (octal 40, decimal 32), are displayed as a caret
1337 (@samp{^}) followed by the non-control version of the character, with
1338 the @code{escape-glyph} face.  For instance, the @samp{control-A}
1339 character, @code{U+0001}, is displayed as @samp{^A}.
1341 @cindex octal escapes
1342 @vindex ctl-arrow
1343   The raw bytes with codes @code{U+0080} (octal 200) through
1344 @code{U+009F} (octal 237) are displayed as @dfn{octal escape
1345 sequences}, with the @code{escape-glyph} face.  For instance,
1346 character code @code{U+0098} (octal 230) is displayed as @samp{\230}.
1347 If you change the buffer-local variable @code{ctl-arrow} to
1348 @code{nil}, the @acronym{ASCII} control characters are also displayed
1349 as octal escape sequences instead of caret escape sequences.
1351 @vindex nobreak-char-display
1352 @cindex non-breaking space
1353 @cindex non-breaking hyphen
1354 @cindex soft hyphen
1355   Some non-@acronym{ASCII} characters have the same appearance as an
1356 @acronym{ASCII} space or hyphen (minus) character.  Such characters
1357 can cause problems if they are entered into a buffer without your
1358 realization, e.g.@: by yanking; for instance, source code compilers
1359 typically do not treat non-@acronym{ASCII} spaces as whitespace
1360 characters.  To deal with this problem, Emacs displays such characters
1361 specially: it displays @code{U+00A0} (no-break space) with the
1362 @code{nobreak-space} face, and it displays @code{U+00AD} (soft
1363 hyphen), @code{U+2010} (hyphen), and @code{U+2011} (non-breaking
1364 hyphen) with the @code{escape-glyph} face.  To disable this, change
1365 the variable @code{nobreak-char-display} to @code{nil}.  If you give
1366 this variable a non-@code{nil} and non-@code{t} value, Emacs instead
1367 displays such characters as a highlighted backslash followed by a
1368 space or hyphen.
1370   You can customize the way any particular character code is displayed
1371 by means of a display table.  @xref{Display Tables,, Display Tables,
1372 elisp, The Emacs Lisp Reference Manual}.
1374 @cindex glyphless characters
1375 @cindex characters with no font glyphs
1376   On graphical displays, some characters may have no glyphs in any of
1377 the fonts available to Emacs.  These @dfn{glyphless characters} are
1378 normally displayed as boxes containing the hexadecimal character code.
1379 Similarly, on text terminals, characters that cannot be displayed
1380 using the terminal encoding (@pxref{Terminal Coding}) are normally
1381 displayed as question signs.  You can control the display method by
1382 customizing the variable @code{glyphless-char-display-control}.
1383 @xref{Glyphless Chars,, Glyphless Character Display, elisp, The Emacs
1384 Lisp Reference Manual}, for details.
1386 @node Cursor Display
1387 @section Displaying the Cursor
1388 @cindex text cursor
1390 @vindex visible-cursor
1391   On a text terminal, the cursor's appearance is controlled by the
1392 terminal, largely out of the control of Emacs.  Some terminals offer
1393 two different cursors: a ``visible'' static cursor, and a ``very
1394 visible'' blinking cursor.  By default, Emacs uses the very visible
1395 cursor, and switches to it when you start or resume Emacs.  If the
1396 variable @code{visible-cursor} is @code{nil} when Emacs starts or
1397 resumes, it uses the normal cursor.
1399 @cindex cursor face
1400 @vindex cursor-type
1401   On a graphical display, many more properties of the text cursor can
1402 be altered.  To customize its color, change the @code{:background}
1403 attribute of the face named @code{cursor} (@pxref{Face
1404 Customization}).  (The other attributes of this face have no effect;
1405 the text shown under the cursor is drawn using the frame's background
1406 color.)  To change its shape, customize the buffer-local variable
1407 @code{cursor-type}; possible values are @code{box} (the default),
1408 @code{hollow} (a hollow box), @code{bar} (a vertical bar), @code{(bar
1409 . @var{n})} (a vertical bar @var{n} pixels wide), @code{hbar} (a
1410 horizontal bar), @code{(hbar . @var{n})} (a horizontal bar @var{n}
1411 pixels tall), or @code{nil} (no cursor at all).
1413 @findex blink-cursor-mode
1414 @cindex cursor, blinking
1415 @cindex blinking cursor
1416 @vindex blink-cursor-alist
1417   To disable cursor blinking, change the variable
1418 @code{blink-cursor-mode} to @code{nil} (@pxref{Easy Customization}),
1419 or add the line @code{(blink-cursor-mode 0)} to your init file.
1420 Alternatively, you can change how the cursor looks when it ``blinks
1421 off'' by customizing the list variable @code{blink-cursor-alist}.
1422 Each element in the list should have the form @code{(@var{on-type}
1423 . @var{off-type})}; this means that if the cursor is displayed as
1424 @var{on-type} when it blinks on (where @var{on-type} is one of the
1425 cursor types described above), then it is displayed as @var{off-type}
1426 when it blinks off.
1428 @vindex x-stretch-cursor
1429 @cindex wide block cursor
1430   Some characters, such as tab characters, are ``extra wide''.  When
1431 the cursor is positioned over such a character, it is normally drawn
1432 with the default character width.  You can make the cursor stretch to
1433 cover wide characters, by changing the variable
1434 @code{x-stretch-cursor} to a non-@code{nil} value.
1436 @cindex cursor in non-selected windows
1437 @vindex cursor-in-non-selected-windows
1438   The cursor normally appears in non-selected windows as a
1439 non-blinking hollow box.  (For a bar cursor, it instead appears as a
1440 thinner bar.)  To turn off cursors in non-selected windows, change the
1441 variable @code{cursor-in-non-selected-windows} to @code{nil}.
1443 @findex hl-line-mode
1444 @findex global-hl-line-mode
1445 @cindex highlight current line
1446   To make the cursor even more visible, you can use HL Line mode, a
1447 minor mode that highlights the line containing point.  Use @kbd{M-x
1448 hl-line-mode} to enable or disable it in the current buffer.  @kbd{M-x
1449 global-hl-line-mode} enables or disables the same mode globally.
1451 @node Line Truncation
1452 @section Line Truncation
1454 @cindex truncation
1455 @cindex line truncation, and fringes
1456   As an alternative to continuation (@pxref{Continuation Lines}),
1457 Emacs can display long lines by @dfn{truncation}.  This means that all
1458 the characters that do not fit in the width of the screen or window do
1459 not appear at all.  On graphical displays, a small straight arrow in
1460 the fringe indicates truncation at either end of the line.  On text
1461 terminals, this is indicated with @samp{$} signs in the leftmost
1462 and/or rightmost columns.
1464 @vindex truncate-lines
1465 @findex toggle-truncate-lines
1466   Horizontal scrolling automatically causes line truncation
1467 (@pxref{Horizontal Scrolling}).  You can explicitly enable line
1468 truncation for a particular buffer with the command @kbd{M-x
1469 toggle-truncate-lines}.  This works by locally changing the variable
1470 @code{truncate-lines}.  If that variable is non-@code{nil}, long lines
1471 are truncated; if it is @code{nil}, they are continued onto multiple
1472 screen lines.  Setting the variable @code{truncate-lines} in any way
1473 makes it local to the current buffer; until that time, the default
1474 value, which is normally @code{nil}, is in effect.
1476 @vindex truncate-partial-width-windows
1477   If a split window becomes too narrow, Emacs may automatically enable
1478 line truncation.  @xref{Split Window}, for the variable
1479 @code{truncate-partial-width-windows} which controls this.
1481 @node Visual Line Mode
1482 @section Visual Line Mode
1484 @cindex word wrap
1485   Another alternative to ordinary line continuation is to use
1486 @dfn{word wrap}.  Here, each long logical line is divided into two or
1487 more screen lines, like in ordinary line continuation.  However, Emacs
1488 attempts to wrap the line at word boundaries near the right window
1489 edge.  This makes the text easier to read, as wrapping does not occur
1490 in the middle of words.
1492 @cindex Visual Line mode
1493 @findex visual-line-mode
1494 @findex global-visual-line-mode
1495   Word wrap is enabled by Visual Line mode, an optional minor mode.
1496 To turn on Visual Line mode in the current buffer, type @kbd{M-x
1497 visual-line-mode}; repeating this command turns it off.  You can also
1498 turn on Visual Line mode using the menu bar: in the Options menu,
1499 select the @samp{Line Wrapping in this Buffer} submenu, followed by
1500 the @samp{Word Wrap (Visual Line Mode)} menu item.  While Visual Line
1501 mode is enabled, the mode-line shows the string @samp{wrap} in the
1502 mode display.  The command @kbd{M-x global-visual-line-mode} toggles
1503 Visual Line mode in all buffers.
1505 @findex beginning-of-visual-line
1506 @findex end-of-visual-line
1507 @findex next-logical-line
1508 @findex previous-logical-line
1509   In Visual Line mode, some editing commands work on screen lines
1510 instead of logical lines: @kbd{C-a} (@code{beginning-of-visual-line})
1511 moves to the beginning of the screen line, @kbd{C-e}
1512 (@code{end-of-visual-line}) moves to the end of the screen line, and
1513 @kbd{C-k} (@code{kill-visual-line}) kills text to the end of the
1514 screen line.
1516   To move by logical lines, use the commands @kbd{M-x
1517 next-logical-line} and @kbd{M-x previous-logical-line}.  These move
1518 point to the next logical line and the previous logical line
1519 respectively, regardless of whether Visual Line mode is enabled.  If
1520 you use these commands frequently, it may be convenient to assign key
1521 bindings to them.  @xref{Init Rebinding}.
1523   By default, word-wrapped lines do not display fringe indicators.
1524 Visual Line mode is often used to edit files that contain many long
1525 logical lines, so having a fringe indicator for each wrapped line
1526 would be visually distracting.  You can change this by customizing the
1527 variable @code{visual-line-fringe-indicators}.
1529 @node Display Custom
1530 @section Customization of Display
1532   This section describes variables that control miscellaneous aspects
1533 of the appearance of the Emacs screen.  Beginning users can skip it.
1535 @vindex visible-bell
1536   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
1537 to make the whole screen blink when it would normally make an audible bell
1538 sound.  This variable has no effect if your terminal does not have a way
1539 to make the screen blink.
1541 @vindex echo-keystrokes
1542   The variable @code{echo-keystrokes} controls the echoing of multi-character
1543 keys; its value is the number of seconds of pause required to cause echoing
1544 to start, or zero, meaning don't echo at all.  The value takes effect when
1545 there is something to echo.  @xref{Echo Area}.
1547 @cindex mouse pointer
1548 @cindex hourglass pointer display
1549 @vindex display-hourglass
1550 @vindex hourglass-delay
1551   On graphical displays, Emacs displays the mouse pointer as an
1552 hourglass if Emacs is busy.  To disable this feature, set the variable
1553 @code{display-hourglass} to @code{nil}.  The variable
1554 @code{hourglass-delay} determines the number of seconds of ``busy
1555 time'' before the hourglass is shown; the default is 1.
1557 @vindex make-pointer-invisible
1558   If the mouse pointer lies inside an Emacs frame, Emacs makes it
1559 invisible each time you type a character to insert text, to prevent it
1560 from obscuring the text.  (To be precise, the hiding occurs when you
1561 type a ``self-inserting'' character.  @xref{Inserting Text}.)  Moving
1562 the mouse pointer makes it visible again.  To disable this feature,
1563 set the variable @code{make-pointer-invisible} to @code{nil}.
1565 @vindex underline-minimum-offset
1566 @vindex x-underline-at-descent-line
1567   On graphical displays, the variable @code{underline-minimum-offset}
1568 determines the minimum distance between the baseline and underline, in
1569 pixels, for underlined text.  By default, the value is 1; increasing
1570 it may improve the legibility of underlined text for certain fonts.
1571 (However, Emacs will never draw the underline below the current line
1572 area.)  The variable @code{x-underline-at-descent-line} determines how
1573 to draw underlined text.  The default is @code{nil}, which means to
1574 draw it at the baseline level of the font; if you change it to
1575 @code{nil}, Emacs draws the underline at the same height as the font's
1576 descent line.
1578 @vindex overline-margin
1579   The variable @code{overline-margin} specifies the vertical position
1580 of an overline above the text, including the height of the overline
1581 itself, in pixels; the default is 2.
1583 @findex tty-suppress-bold-inverse-default-colors
1584   On some text terminals, bold face and inverse video together result
1585 in text that is hard to read.  Call the function
1586 @code{tty-suppress-bold-inverse-default-colors} with a non-@code{nil}
1587 argument to suppress the effect of bold-face in this case.