Backport the :end-of-capability fix
[emacs.git] / doc / emacs / display.texi
blob34f84e7664a54f6139e9d6a3abeacd07f9102a16
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2015 Free Software
3 @c 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 @cindex automatic scrolling
217   Emacs performs @dfn{automatic scrolling} when point moves out of the
218 visible portion of the text.  Normally, automatic scrolling centers
219 point vertically in the window, but there are several ways to alter
220 this behavior.
222 @vindex scroll-conservatively
223   If you set @code{scroll-conservatively} to a small number @var{n},
224 then moving point just a little off the screen (no more than @var{n}
225 lines) causes Emacs to scroll just enough to bring point back on
226 screen; if doing so fails to make point visible, Emacs scrolls just
227 far enough to center point in the window.  If you set
228 @code{scroll-conservatively} to a large number (larger than 100),
229 automatic scrolling never centers point, no matter how far point
230 moves; Emacs always scrolls text just enough to bring point into view,
231 either at the top or bottom of the window depending on the scroll
232 direction.  By default, @code{scroll-conservatively} is@tie{}0, which
233 means to always center point in the window.
235 @vindex scroll-step
236   Another way to control automatic scrolling is to customize the
237 variable @code{scroll-step}.  Its value determines the number of lines
238 by which to automatically scroll, when point moves off the screen.  If
239 scrolling by that number of lines fails to bring point back into view,
240 point is centered instead.  The default value is zero, which (by
241 default) causes point to always be centered after scrolling.
243 @cindex aggressive scrolling
244 @vindex scroll-up-aggressively
245 @vindex scroll-down-aggressively
246   A third way to control automatic scrolling is to customize the
247 variables @code{scroll-up-aggressively} and
248 @code{scroll-down-aggressively}, which directly specify the vertical
249 position of point after scrolling.  The value of
250 @code{scroll-up-aggressively} should be either @code{nil} (the
251 default), or a floating point number @var{f} between 0 and 1.  The
252 latter means that when point goes below the bottom window edge (i.e.,
253 scrolling forward), Emacs scrolls the window so that point is @var{f}
254 parts of the window height from the bottom window edge.  Thus, larger
255 @var{f} means more aggressive scrolling: more new text is brought into
256 view.  The default value, @code{nil}, is equivalent to 0.5.
258   Likewise, @code{scroll-down-aggressively} is used when point goes
259 above the bottom window edge (i.e., scrolling backward).  The value
260 specifies how far point should be from the top margin of the window
261 after scrolling.  Thus, as with @code{scroll-up-aggressively}, a
262 larger value is more aggressive.
264   Note that the variables @code{scroll-conservatively},
265 @code{scroll-step}, and @code{scroll-up-aggressively} /
266 @code{scroll-down-aggressively} control automatic scrolling in
267 contradictory ways.  Therefore, you should pick no more than one of
268 these methods to customize automatic scrolling.  In case you customize
269 multiple variables, the order of priority is:
270 @code{scroll-conservatively}, then @code{scroll-step}, and finally
271 @code{scroll-up-aggressively} / @code{scroll-down-aggressively}.
273 @vindex scroll-margin
274   The variable @code{scroll-margin} restricts how close point can come
275 to the top or bottom of a window (even if aggressive scrolling
276 specifies a fraction @var{f} that is larger than the window portion
277 between the top and the bottom margins).  Its value is a number of screen
278 lines; if point comes within that many lines of the top or bottom of
279 the window, Emacs performs automatic scrolling.  By default,
280 @code{scroll-margin} is 0.
282 @node Horizontal Scrolling
283 @section Horizontal Scrolling
284 @cindex horizontal scrolling
286 @vindex auto-hscroll-mode
287   @dfn{Horizontal scrolling} means shifting all the lines sideways
288 within a window, so that some of the text near the left margin is not
289 displayed.  When the text in a window is scrolled horizontally, text
290 lines are truncated rather than continued (@pxref{Line Truncation}).
291 If a window shows truncated lines, Emacs performs automatic horizontal
292 scrolling whenever point moves off the left or right edge of the
293 screen.  To disable automatic horizontal scrolling, set the variable
294 @code{auto-hscroll-mode} to @code{nil}.  Note that when the automatic
295 horizontal scrolling is turned off, if point moves off the edge of the
296 screen, the cursor disappears to indicate that.  (On text terminals,
297 the cursor is left at the edge instead.)
299 @vindex hscroll-margin
300   The variable @code{hscroll-margin} controls how close point can get
301 to the window's left and right edges before automatic scrolling
302 occurs.  It is measured in columns.  For example, if the value is 5,
303 then moving point within 5 columns of an edge causes horizontal
304 scrolling away from that edge.
306 @vindex hscroll-step
307   The variable @code{hscroll-step} determines how many columns to
308 scroll the window when point gets too close to the edge.  Zero, the
309 default value, means to center point horizontally within the window.
310 A positive integer value specifies the number of columns to scroll by.
311 A floating-point number specifies the fraction of the window's width
312 to scroll by.
314   You can also perform explicit horizontal scrolling with the
315 following commands:
317 @table @kbd
318 @item C-x <
319 Scroll text in current window to the left (@code{scroll-left}).
320 @item C-x >
321 Scroll to the right (@code{scroll-right}).
322 @end table
324 @kindex C-x <
325 @kindex C-x >
326 @findex scroll-left
327 @findex scroll-right
328   @kbd{C-x <} (@code{scroll-left}) scrolls text in the selected window
329 to the left by the full width of the window, less two columns.  (In
330 other words, the text in the window moves left relative to the
331 window.)  With a numeric argument @var{n}, it scrolls by @var{n}
332 columns.
334   If the text is scrolled to the left, and point moves off the left
335 edge of the window, the cursor will freeze at the left edge of the
336 window, until point moves back to the displayed portion of the text.
337 This is independent of the current setting of
338 @code{auto-hscroll-mode}, which, for text scrolled to the left, only
339 affects the behavior at the right edge of the window.
341   @kbd{C-x >} (@code{scroll-right}) scrolls similarly to the right.
342 The window cannot be scrolled any farther to the right once it is
343 displayed normally, with each line starting at the window's left
344 margin; attempting to do so has no effect.  This means that you don't
345 have to calculate the argument precisely for @w{@kbd{C-x >}}; any
346 sufficiently large argument will restore the normal display.
348   If you use those commands to scroll a window horizontally, that sets
349 a lower bound for automatic horizontal scrolling.  Automatic scrolling
350 will continue to scroll the window, but never farther to the right
351 than the amount you previously set by @code{scroll-left}.
353 @node Narrowing
354 @section Narrowing
355 @cindex widening
356 @cindex restriction
357 @cindex narrowing
358 @cindex accessible portion
360   @dfn{Narrowing} means focusing in on some portion of the buffer,
361 making the rest temporarily inaccessible.  The portion which you can
362 still get to is called the @dfn{accessible portion}.  Canceling the
363 narrowing, which makes the entire buffer once again accessible, is
364 called @dfn{widening}.  The bounds of narrowing in effect in a buffer
365 are called the buffer's @dfn{restriction}.
367   Narrowing can make it easier to concentrate on a single subroutine or
368 paragraph by eliminating clutter.  It can also be used to limit the
369 range of operation of a replace command or repeating keyboard macro.
371 @table @kbd
372 @item C-x n n
373 Narrow down to between point and mark (@code{narrow-to-region}).
374 @item C-x n w
375 Widen to make the entire buffer accessible again (@code{widen}).
376 @item C-x n p
377 Narrow down to the current page (@code{narrow-to-page}).
378 @item C-x n d
379 Narrow down to the current defun (@code{narrow-to-defun}).
380 @end table
382   When you have narrowed down to a part of the buffer, that part appears
383 to be all there is.  You can't see the rest, you can't move into it
384 (motion commands won't go outside the accessible part), you can't change
385 it in any way.  However, it is not gone, and if you save the file all
386 the inaccessible text will be saved.  The word @samp{Narrow} appears in
387 the mode line whenever narrowing is in effect.
389 @kindex C-x n n
390 @findex narrow-to-region
391   The primary narrowing command is @kbd{C-x n n} (@code{narrow-to-region}).
392 It sets the current buffer's restrictions so that the text in the current
393 region remains accessible, but all text before the region or after the
394 region is inaccessible.  Point and mark do not change.
396 @kindex C-x n p
397 @findex narrow-to-page
398 @kindex C-x n d
399 @findex narrow-to-defun
400   Alternatively, use @kbd{C-x n p} (@code{narrow-to-page}) to narrow
401 down to the current page.  @xref{Pages}, for the definition of a page.
402 @kbd{C-x n d} (@code{narrow-to-defun}) narrows down to the defun
403 containing point (@pxref{Defuns}).
405 @kindex C-x n w
406 @findex widen
407   The way to cancel narrowing is to widen with @kbd{C-x n w}
408 (@code{widen}).  This makes all text in the buffer accessible again.
410   You can get information on what part of the buffer you are narrowed down
411 to using the @kbd{C-x =} command.  @xref{Position Info}.
413   Because narrowing can easily confuse users who do not understand it,
414 @code{narrow-to-region} is normally a disabled command.  Attempting to use
415 this command asks for confirmation and gives you the option of enabling it;
416 if you enable the command, confirmation will no longer be required for
417 it.  @xref{Disabling}.
419 @node View Mode
420 @section View Mode
421 @cindex View mode
422 @cindex mode, View
424 @kindex s @r{(View mode)}
425 @kindex SPC @r{(View mode)}
426 @kindex DEL @r{(View mode)}
427   View mode is a minor mode that lets you scan a buffer by sequential
428 screenfuls.  It provides commands for scrolling through the buffer
429 conveniently but not for changing it.  Apart from the usual Emacs
430 cursor motion commands, you can type @key{SPC} to scroll forward one
431 windowful, @key{S-@key{SPC}} or @key{DEL} to scroll backward, and @kbd{s} to
432 start an incremental search.
434 @kindex q @r{(View mode)}
435 @kindex e @r{(View mode)}
436 @findex View-quit
437 @findex View-exit
438   Typing @kbd{q} (@code{View-quit}) disables View mode, and switches
439 back to the buffer and position before View mode was enabled.  Typing
440 @kbd{e} (@code{View-exit}) disables View mode, keeping the current
441 buffer and position.
443 @findex view-buffer
444 @findex view-file
445   @kbd{M-x view-buffer} prompts for an existing Emacs buffer, switches
446 to it, and enables View mode.  @kbd{M-x view-file} prompts for a file
447 and visits it with View mode enabled.
449 @node Follow Mode
450 @section Follow Mode
451 @cindex Follow mode
452 @cindex mode, Follow
453 @findex follow-mode
454 @cindex windows, synchronizing
455 @cindex synchronizing windows
457   @dfn{Follow mode} is a minor mode that makes two windows, both
458 showing the same buffer, scroll as a single tall ``virtual window''.
459 To use Follow mode, go to a frame with just one window, split it into
460 two side-by-side windows using @kbd{C-x 3}, and then type @kbd{M-x
461 follow-mode}.  From then on, you can edit the buffer in either of the
462 two windows, or scroll either one; the other window follows it.
464   In Follow mode, if you move point outside the portion visible in one
465 window and into the portion visible in the other window, that selects
466 the other window---again, treating the two as if they were parts of
467 one large window.
469   To turn off Follow mode, type @kbd{M-x follow-mode} a second time.
471 @node Faces
472 @section Text Faces
473 @cindex faces
475   Emacs can display text in several different styles, called
476 @dfn{faces}.  Each face can specify various @dfn{face attributes},
477 such as the font, height, weight, slant, foreground and background
478 color, and underlining or overlining.  Most major modes assign faces
479 to the text automatically, via Font Lock mode.  @xref{Font Lock}, for
480 more information about how these faces are assigned.
482 @findex list-faces-display
483   To see what faces are currently defined, and what they look like,
484 type @kbd{M-x list-faces-display}.  With a prefix argument, this
485 prompts for a regular expression, and displays only faces with names
486 matching that regular expression (@pxref{Regexps}).
488 @vindex frame-background-mode
489   It's possible for a given face to look different in different
490 frames.  For instance, some text terminals do not support all face
491 attributes, particularly font, height, and width, and some support a
492 limited range of colors.  In addition, most Emacs faces are defined so
493 that their attributes are different on light and dark frame
494 backgrounds, for reasons of legibility.  By default, Emacs
495 automatically chooses which set of face attributes to display on each
496 frame, based on the frame's current background color.  However, you
497 can override this by giving the variable @code{frame-background-mode}
498 a non-@code{nil} value.  A value of @code{dark} makes Emacs treat all
499 frames as if they have a dark background, whereas a value of
500 @code{light} makes it treat all frames as if they have a light
501 background.
503 @cindex background color
504 @cindex default face
505   You can customize a face to alter its attributes, and save those
506 customizations for future Emacs sessions.  @xref{Face Customization},
507 for details.
509   The @code{default} face is the default for displaying text, and all
510 of its attributes are specified.  Its background color is also used as
511 the frame's background color.  @xref{Colors}.
513 @cindex cursor face
514   Another special face is the @code{cursor} face.  On graphical
515 displays, the background color of this face is used to draw the text
516 cursor.  None of the other attributes of this face have any effect;
517 the foreground color for text under the cursor is taken from the
518 background color of the underlying text.  On text terminals, the
519 appearance of the text cursor is determined by the terminal, not by
520 the @code{cursor} face.
522   You can also use X resources to specify attributes of any particular
523 face.  @xref{Resources}.
525   Emacs can display variable-width fonts, but some Emacs commands,
526 particularly indentation commands, do not account for variable
527 character display widths.  Therefore, we recommend not using
528 variable-width fonts for most faces, particularly those assigned by
529 Font Lock mode.
531 @node Colors
532 @section Colors for Faces
533 @cindex color name
534 @cindex RGB triplet
536   Faces can have various foreground and background colors.  When you
537 specify a color for a face---for instance, when customizing the face
538 (@pxref{Face Customization})---you can use either a @dfn{color name}
539 or an @dfn{RGB triplet}.
541 @findex list-colors-display
542 @vindex list-colors-sort
543   A color name is a pre-defined name, such as @samp{dark orange} or
544 @samp{medium sea green}.  To view a list of color names, type @kbd{M-x
545 list-colors-display}.  To control the order in which colors are shown,
546 customize @code{list-colors-sort}.  If you run this command on a
547 graphical display, it shows the full range of color names known to
548 Emacs (these are the standard X11 color names, defined in X's
549 @file{rgb.txt} file).  If you run the command on a text terminal, it
550 shows only a small subset of colors that can be safely displayed on
551 such terminals.  However, Emacs understands X11 color names even on
552 text terminals; if a face is given a color specified by an X11 color
553 name, it is displayed using the closest-matching terminal color.
555   An RGB triplet is a string of the form @samp{#RRGGBB}.  Each of the
556 R, G, and B components is a hexadecimal number specifying the
557 component's relative intensity, one to four digits long (usually two
558 digits are used).  The components must have the same number of digits.
559 For hexadecimal values A to F, either upper or lower case are
560 acceptable.
562   The @kbd{M-x list-colors-display} command also shows the equivalent
563 RGB triplet for each named color.  For instance, @samp{medium sea
564 green} is equivalent to @samp{#3CB371}.
566 @cindex face colors, setting
567 @findex set-face-foreground
568 @findex set-face-background
569   You can change the foreground and background colors of a face with
570 @kbd{M-x set-face-foreground} and @kbd{M-x set-face-background}.
571 These commands prompt in the minibuffer for a face name and a color,
572 with completion, and then set that face to use the specified color.
573 They affect the face colors on all frames, but their effects do not
574 persist for future Emacs sessions, unlike using the customization
575 buffer or X resources.  You can also use frame parameters to set
576 foreground and background colors for a specific frame; @xref{Frame
577 Parameters}.
579 @node Standard Faces
580 @section Standard Faces
581 @cindex standard faces
583   Here are the standard faces for specifying text appearance.  You can
584 apply them to specific text when you want the effects they produce.
586 @table @code
587 @item default
588 This face is used for ordinary text that doesn't specify any face.
589 Its background color is used as the frame's background color.
590 @item bold
591 This face uses a bold variant of the default font.
592 @item italic
593 This face uses an italic variant of the default font.
594 @item bold-italic
595 This face uses a bold italic variant of the default font.
596 @item underline
597 This face underlines text.
598 @item fixed-pitch
599 This face forces use of a fixed-width font.  It's reasonable to
600 customize this face to use a different fixed-width font, if you like,
601 but you should not make it a variable-width font.
602 @cindex variable-pitch face
603 @item variable-pitch
604 This face forces use of a variable-width font.
605 @cindex shadow face
606 @item shadow
607 This face is used for making the text less noticeable than the surrounding
608 ordinary text.  Usually this can be achieved by using shades of gray in
609 contrast with either black or white default foreground color.
610 @end table
612   Here's an incomplete list of faces used to highlight parts of the
613 text temporarily for specific purposes.  (Many other modes define
614 their own faces for this purpose.)
616 @table @code
617 @item highlight
618 This face is used for text highlighting in various contexts, such as
619 when the mouse cursor is moved over a hyperlink.
620 @item isearch
621 This face is used to highlight the current Isearch match
622 (@pxref{Incremental Search}).
623 @item query-replace
624 This face is used to highlight the current Query Replace match
625 (@pxref{Replace}).
626 @item lazy-highlight
627 This face is used to highlight ``lazy matches'' for Isearch and Query
628 Replace (matches other than the current one).
629 @item region
630 This face is used for displaying an active region (@pxref{Mark}).
631 When Emacs is built with GTK support, its colors are taken from the
632 current GTK theme.
633 @item secondary-selection
634 This face is used for displaying a secondary X selection (@pxref{Secondary
635 Selection}).
636 @item trailing-whitespace
637 The face for highlighting excess spaces and tabs at the end of a line
638 when @code{show-trailing-whitespace} is non-@code{nil} (@pxref{Useless
639 Whitespace}).
640 @item escape-glyph
641 The face for displaying control characters and escape sequences
642 (@pxref{Text Display}).
643 @item nobreak-space
644 The face for displaying ``no-break'' space characters (@pxref{Text
645 Display}).
646 @end table
648   The following faces control the appearance of parts of the Emacs
649 frame:
651 @table @code
652 @item mode-line
653 @cindex mode-line face
654 @cindex faces for mode lines
655 This face is used for the mode line of the currently selected window,
656 and for menu bars when toolkit menus are not used.  By default, it's
657 drawn with shadows for a ``raised'' effect on graphical displays, and
658 drawn as the inverse of the default face on non-windowed terminals.
659 @item mode-line-inactive
660 @cindex mode-line-inactive face
661 Like @code{mode-line}, but used for mode lines of the windows other
662 than the selected one (if @code{mode-line-in-non-selected-windows} is
663 non-@code{nil}).  This face inherits from @code{mode-line}, so changes
664 in that face affect mode lines in all windows.
665 @item mode-line-highlight
666 @cindex mode-line-highlight face
667 Like @code{highlight}, but used for mouse-sensitive portions of text
668 on mode lines.  Such portions of text typically pop up tooltips
669 (@pxref{Tooltips}) when the mouse pointer hovers above them.
670 @item mode-line-buffer-id
671 @cindex mode-line-buffer-id face
672 This face is used for buffer identification parts in the mode line.
673 @item header-line
674 @cindex header-line face
675 Similar to @code{mode-line} for a window's header line, which appears
676 at the top of a window just as the mode line appears at the bottom.
677 Most windows do not have a header line---only some special modes, such
678 Info mode, create one.
679 @item vertical-border
680 @cindex vertical-border face
681 This face is used for the vertical divider between windows on text
682 terminals.
683 @item minibuffer-prompt
684 @cindex @code{minibuffer-prompt} face
685 @vindex minibuffer-prompt-properties
686 This face is used for the prompt strings displayed in the minibuffer.
687 By default, Emacs automatically adds this face to the value of
688 @code{minibuffer-prompt-properties}, which is a list of text
689 properties used to display the prompt text.  (This variable takes
690 effect when you enter the minibuffer.)
691 @item fringe
692 @cindex @code{fringe} face
693 The face for the fringes to the left and right of windows on graphic
694 displays.  (The fringes are the narrow portions of the Emacs frame
695 between the text area and the window's right and left borders.)
696 @xref{Fringes}.
697 @item cursor
698 The @code{:background} attribute of this face specifies the color of
699 the text cursor.  @xref{Cursor Display}.
700 @item tooltip
701 This face is used for tooltip text.  By default, if Emacs is built
702 with GTK support, tooltips are drawn via GTK and this face has no
703 effect.  @xref{Tooltips}.
704 @item mouse
705 This face determines the color of the mouse pointer.
706 @end table
708   The following faces likewise control the appearance of parts of the
709 Emacs frame, but only on text terminals, or when Emacs is built on X
710 with no toolkit support.  (For all other cases, the appearance of the
711 respective frame elements is determined by system-wide settings.)
713 @table @code
714 @item scroll-bar
715 This face determines the visual appearance of the scroll bar.
716 @xref{Scroll Bars}.
717 @item tool-bar
718 This face determines the color of tool bar icons.  @xref{Tool Bars}.
719 @item menu
720 @cindex menu bar appearance
721 @cindex @code{menu} face, no effect if customized
722 @cindex customization of @code{menu} face
723 This face determines the colors and font of Emacs's menus.  @xref{Menu
724 Bars}.
725 @item tty-menu-enabled-face
726 @cindex faces for text-mode menus
727 @cindex TTY menu faces
728 This face is used to display enabled menu items on text-mode
729 terminals.
730 @item tty-menu-disabled-face
731 This face is used to display disabled menu items on text-mode
732 terminals.
733 @item tty-menu-selected-face
734 This face is used to display on text-mode terminals the menu item that
735 would be selected if you click a mouse or press @key{RET}.
736 @end table
738 @node Text Scale
739 @section Text Scale
741 @cindex adjust buffer face height
742 @findex text-scale-adjust
743 @kindex C-x C-+
744 @kindex C-x C--
745 @kindex C-x C-=
746 @kindex C-x C-0
747   To increase the height of the default face in the current buffer,
748 type @kbd{C-x C-+} or @kbd{C-x C-=}.  To decrease it, type @kbd{C-x
749 C--}.  To restore the default (global) face height, type @kbd{C-x
750 C-0}.  These keys are all bound to the same command,
751 @code{text-scale-adjust}, which looks at the last key typed to
752 determine which action to take.
754   The final key of these commands may be repeated without the leading
755 @kbd{C-x}.  For instance, @kbd{C-x C-= C-= C-=} increases the face
756 height by three steps.  Each step scales the text height by a factor
757 of 1.2; to change this factor, customize the variable
758 @code{text-scale-mode-step}.  A numeric argument of 0
759 to the @code{text-scale-adjust} command restores the default height,
760 the same as typing @kbd{C-x C-0}.
762 @cindex increase buffer face height
763 @findex text-scale-increase
764 @cindex decrease buffer face height
765 @findex text-scale-decrease
766   The commands @code{text-scale-increase} and
767 @code{text-scale-decrease} increase or decrease the height of the
768 default face, just like @kbd{C-x C-+} and @kbd{C-x C--} respectively.
769 You may find it convenient to bind to these commands, rather than
770 @code{text-scale-adjust}.
772 @cindex set buffer face height
773 @findex text-scale-set
774   The command @code{text-scale-set} scales the height of the default
775 face in the current buffer to an absolute level specified by its
776 prefix argument.
778 @findex text-scale-mode
779   The above commands automatically enable the minor mode
780 @code{text-scale-mode} if the current font scaling is other than 1,
781 and disable it otherwise.
783 @node Font Lock
784 @section Font Lock mode
785 @cindex Font Lock mode
786 @cindex mode, Font Lock
787 @cindex syntax highlighting and coloring
789   Font Lock mode is a minor mode, always local to a particular buffer,
790 which assigns faces to (or @dfn{fontifies}) the text in the buffer.
791 Each buffer's major mode tells Font Lock mode which text to fontify;
792 for instance, programming language modes fontify syntactically
793 relevant constructs like comments, strings, and function names.
795 @findex font-lock-mode
796   Font Lock mode is enabled by default.  To toggle it in the current
797 buffer, type @kbd{M-x font-lock-mode}.  A positive numeric argument
798 unconditionally enables Font Lock mode, and a negative or zero
799 argument disables it.
801 @findex global-font-lock-mode
802 @vindex global-font-lock-mode
803   Type @kbd{M-x global-font-lock-mode} to toggle Font Lock mode in all
804 buffers.  To impose this setting for future Emacs sessions, customize
805 the variable @code{global-font-lock-mode} (@pxref{Easy
806 Customization}), or add the following line to your init file:
808 @example
809 (global-font-lock-mode 0)
810 @end example
812 @noindent
813 If you have disabled Global Font Lock mode, you can still enable Font
814 Lock for specific major modes by adding the function
815 @code{font-lock-mode} to the mode hooks (@pxref{Hooks}).  For example,
816 to enable Font Lock mode for editing C files, you can do this:
818 @example
819 (add-hook 'c-mode-hook 'font-lock-mode)
820 @end example
822   Font Lock mode uses several specifically named faces to do its job,
823 including @code{font-lock-string-face}, @code{font-lock-comment-face},
824 and others.  The easiest way to find them all is to use @kbd{M-x
825 customize-group @key{RET} font-lock-faces @key{RET}}.  You can then
826 use that customization buffer to customize the appearance of these
827 faces.  @xref{Face Customization}.
829 @vindex font-lock-maximum-decoration
830   You can customize the variable @code{font-lock-maximum-decoration}
831 to alter the amount of fontification applied by Font Lock mode, for
832 major modes that support this feature.  The value should be a number
833 (with 1 representing a minimal amount of fontification; some modes
834 support levels as high as 3); or @code{t}, meaning ``as high as
835 possible'' (the default).  You can also specify different numbers for
836 particular major modes; for example, to use level 1 for C/C++ modes,
837 and the default level otherwise, use the value
839 @example
840 '((c-mode . 1) (c++-mode . 1)))
841 @end example
843 @vindex font-lock-beginning-of-syntax-function
844 @cindex incorrect fontification
845 @cindex parenthesis in column zero and fontification
846 @cindex brace in column zero and fontification
847   Comment and string fontification (or ``syntactic'' fontification)
848 relies on analysis of the syntactic structure of the buffer text.  For
849 the sake of speed, some modes, including Lisp mode, rely on a special
850 convention: an open-parenthesis or open-brace in the leftmost column
851 always defines the beginning of a defun, and is thus always outside
852 any string or comment.  Therefore, you should avoid placing an
853 open-parenthesis or open-brace in the leftmost column, if it is inside
854 a string or comment.  @xref{Left Margin Paren}, for details.
856 @cindex slow display during scrolling
857   The variable @code{font-lock-beginning-of-syntax-function}, which is
858 always buffer-local, specifies how Font Lock mode can find a position
859 guaranteed to be outside any comment or string.  In modes which use
860 the leftmost column parenthesis convention, the default value of the
861 variable is @code{beginning-of-defun}---that tells Font Lock mode to
862 use the convention.  If you set this variable to @code{nil}, Font Lock
863 no longer relies on the convention.  This avoids incorrect results,
864 but the price is that, in some cases, fontification for a changed text
865 must rescan buffer text from the beginning of the buffer.  This can
866 considerably slow down redisplay while scrolling, particularly if you
867 are close to the end of a large buffer.
869 @findex font-lock-add-keywords
870   Font Lock highlighting patterns already exist for most modes, but
871 you may want to fontify additional patterns.  You can use the function
872 @code{font-lock-add-keywords}, to add your own highlighting patterns
873 for a particular mode.  For example, to highlight @samp{FIXME:} words
874 in C comments, use this:
876 @example
877 (add-hook 'c-mode-hook
878           (lambda ()
879            (font-lock-add-keywords nil
880             '(("\\<\\(FIXME\\):" 1
881                font-lock-warning-face t)))))
882 @end example
884 @findex font-lock-remove-keywords
885 @noindent
886 To remove keywords from the font-lock highlighting patterns, use the
887 function @code{font-lock-remove-keywords}.  @xref{Search-based
888 Fontification,,, elisp, The Emacs Lisp Reference Manual}.
890 @cindex just-in-time (JIT) font-lock
891 @cindex background syntax highlighting
892   Fontifying large buffers can take a long time.  To avoid large
893 delays when a file is visited, Emacs initially fontifies only the
894 visible portion of a buffer.  As you scroll through the buffer, each
895 portion that becomes visible is fontified as soon as it is displayed;
896 this type of Font Lock is called @dfn{Just-In-Time} (or @dfn{JIT})
897 Lock.  You can control how JIT Lock behaves, including telling it to
898 perform fontification while idle, by customizing variables in the
899 customization group @samp{jit-lock}.  @xref{Specific Customization}.
901 @node Highlight Interactively
902 @section Interactive Highlighting
903 @cindex highlighting by matching
904 @cindex interactive highlighting
905 @cindex Highlight Changes mode
907 @findex highlight-changes-mode
908 Highlight Changes mode is a minor mode that @dfn{highlights} the parts
909 of the buffer that were changed most recently, by giving that text a
910 different face.  To enable or disable Highlight Changes mode, use
911 @kbd{M-x highlight-changes-mode}.
913 @cindex Hi Lock mode
914 @findex hi-lock-mode
915   Hi Lock mode is a minor mode that highlights text that matches
916 regular expressions you specify.  For example, you can use it to
917 highlight all the references to a certain variable in a program source
918 file, highlight certain parts in a voluminous output of some program,
919 or highlight certain names in an article.  To enable or disable Hi
920 Lock mode, use the command @kbd{M-x hi-lock-mode}.  To enable Hi Lock
921 mode for all buffers, use @kbd{M-x global-hi-lock-mode} or place
922 @code{(global-hi-lock-mode 1)} in your @file{.emacs} file.
924   Hi Lock mode works like Font Lock mode (@pxref{Font Lock}), except
925 that you specify explicitly the regular expressions to highlight.  You
926 control them with these commands:
928 @table @kbd
929 @item M-s h r @var{regexp} @key{RET} @var{face} @key{RET}
930 @itemx C-x w h @var{regexp} @key{RET} @var{face} @key{RET}
931 @kindex M-s h r
932 @kindex C-x w h
933 @findex highlight-regexp
934 Highlight text that matches @var{regexp} using face @var{face}
935 (@code{highlight-regexp}).  The highlighting will remain as long as
936 the buffer is loaded.  For example, to highlight all occurrences of
937 the word ``whim'' using the default face (a yellow background)
938 @kbd{M-s h r whim @key{RET} @key{RET}}.  Any face can be used for
939 highlighting, Hi Lock provides several of its own and these are
940 pre-loaded into a list of default values.  While being prompted
941 for a face use @kbd{M-n} and @kbd{M-p} to cycle through them.
943 @vindex hi-lock-auto-select-face
944 Setting the option @code{hi-lock-auto-select-face} to a non-@code{nil}
945 value causes this command (and other Hi Lock commands that read faces)
946 to automatically choose the next face from the default list without
947 prompting.
949 You can use this command multiple times, specifying various regular
950 expressions to highlight in different ways.
952 @item M-s h u @var{regexp} @key{RET}
953 @itemx C-x w r @var{regexp} @key{RET}
954 @kindex M-s h u
955 @kindex C-x w r
956 @findex unhighlight-regexp
957 Unhighlight @var{regexp} (@code{unhighlight-regexp}).
959 If you invoke this from the menu, you select the expression to
960 unhighlight from a list.  If you invoke this from the keyboard, you
961 use the minibuffer.  It will show the most recently added regular
962 expression; use @kbd{M-n} to show the next older expression and
963 @kbd{M-p} to select the next newer expression.  (You can also type the
964 expression by hand, with completion.)  When the expression you want to
965 unhighlight appears in the minibuffer, press @kbd{@key{RET}} to exit
966 the minibuffer and unhighlight it.
968 @item M-s h l @var{regexp} @key{RET} @var{face} @key{RET}
969 @itemx C-x w l @var{regexp} @key{RET} @var{face} @key{RET}
970 @kindex M-s h l
971 @kindex C-x w l
972 @findex highlight-lines-matching-regexp
973 @cindex lines, highlighting
974 @cindex highlighting lines of text
975 Highlight entire lines containing a match for @var{regexp}, using face
976 @var{face} (@code{highlight-lines-matching-regexp}).
978 @item M-s h p @var{phrase} @key{RET} @var{face} @key{RET}
979 @itemx C-x w p @var{phrase} @key{RET} @var{face} @key{RET}
980 @kindex M-s h p
981 @kindex C-x w p
982 @findex highlight-phrase
983 @cindex phrase, highlighting
984 @cindex highlighting phrase
985 Highlight matches of @var{phrase}, using face @var{face}
986 (@code{highlight-phrase}).  @var{phrase} can be any regexp,
987 but spaces will be replaced by matches to whitespace and
988 initial lower-case letters will become case insensitive.
990 @item M-s h .
991 @itemx C-x w .
992 @kindex M-s h .
993 @kindex C-x w .
994 @findex highlight-symbol-at-point
995 @cindex symbol, highlighting
996 @cindex highlighting symbol at point
997 Highlight the symbol found near point, using the next available face
998 (@code{highlight-symbol-at-point}).
1000 @item M-s h w
1001 @itemx C-x w b
1002 @kindex M-s h w
1003 @kindex C-x w b
1004 @findex hi-lock-write-interactive-patterns
1005 Insert all the current highlighting regexp/face pairs into the buffer
1006 at point, with comment delimiters to prevent them from changing your
1007 program.  (This key binding runs the
1008 @code{hi-lock-write-interactive-patterns} command.)
1010 These patterns are extracted from the comments, if appropriate, if you
1011 invoke @kbd{M-x hi-lock-find-patterns}, or if you visit the file while
1012 Hi Lock mode is enabled (since that runs @code{hi-lock-find-patterns}).
1014 @item M-s h f
1015 @itemx C-x w i
1016 @kindex M-s h f
1017 @kindex C-x w i
1018 @findex hi-lock-find-patterns
1019 Extract regexp/face pairs from comments in the current buffer
1020 (@code{hi-lock-find-patterns}).  Thus, you can enter patterns
1021 interactively with @code{highlight-regexp}, store them into the file
1022 with @code{hi-lock-write-interactive-patterns}, edit them (perhaps
1023 including different faces for different parenthesized parts of the
1024 match), and finally use this command (@code{hi-lock-find-patterns}) to
1025 have Hi Lock highlight the edited patterns.
1027 @vindex hi-lock-file-patterns-policy
1028 The variable @code{hi-lock-file-patterns-policy} controls whether Hi
1029 Lock mode should automatically extract and highlight patterns found in a
1030 file when it is visited.  Its value can be @code{nil} (never highlight),
1031 @code{ask} (query the user), or a function.  If it is a function,
1032 @code{hi-lock-find-patterns} calls it with the patterns as argument; if
1033 the function returns non-@code{nil}, the patterns are used.  The default
1034 is @code{ask}.  Note that patterns are always highlighted if you call
1035 @code{hi-lock-find-patterns} directly, regardless of the value of this
1036 variable.
1038 @vindex hi-lock-exclude-modes
1039 Also, @code{hi-lock-find-patterns} does nothing if the current major
1040 mode's symbol is a member of the list @code{hi-lock-exclude-modes}.
1041 @end table
1043 @node Fringes
1044 @section Window Fringes
1045 @cindex fringes
1047 @findex set-fringe-style
1048 @findex fringe-mode
1049 @vindex fringe-mode @r{(variable)}
1050   On graphical displays, each Emacs window normally has narrow
1051 @dfn{fringes} on the left and right edges.  The fringes are used to
1052 display symbols that provide information about the text in the window.
1053 You can type @kbd{M-x fringe-mode} to disable the fringes, or modify
1054 their width.  This command affects fringes in all frames; to modify
1055 fringes on the selected frame only, use @kbd{M-x set-fringe-style}.
1056 You can make your changes to the fringes permanent by customizing the
1057 variable @code{fringe-mode}.
1059   The most common use of the fringes is to indicate a continuation
1060 line (@pxref{Continuation Lines}).  When one line of text is split
1061 into multiple screen lines, the left fringe shows a curving arrow for
1062 each screen line except the first, indicating that ``this is not the
1063 real beginning''.  The right fringe shows a curving arrow for each
1064 screen line except the last, indicating that ``this is not the real
1065 end''.  If the line's direction is right-to-left (@pxref{Bidirectional
1066 Editing}), the meanings of the curving arrows in the fringes are
1067 swapped.
1069   The fringes indicate line truncation with short horizontal arrows
1070 meaning ``there's more text on this line which is scrolled
1071 horizontally out of view''.  Clicking the mouse on one of the arrows
1072 scrolls the display horizontally in the direction of the arrow.
1074   The fringes can also indicate other things, such as buffer
1075 boundaries (@pxref{Displaying Boundaries}), and where a program you
1076 are debugging is executing (@pxref{Debuggers}).
1078 @vindex overflow-newline-into-fringe
1079   The fringe is also used for drawing the cursor, if the current line
1080 is exactly as wide as the window and point is at the end of the line.
1081 To disable this, change the variable
1082 @code{overflow-newline-into-fringe} to @code{nil}; this causes Emacs
1083 to continue or truncate lines that are exactly as wide as the window.
1085 @node Displaying Boundaries
1086 @section Displaying Boundaries
1088 @vindex indicate-buffer-boundaries
1089   On graphical displays, Emacs can indicate the buffer boundaries in
1090 the fringes.  If you enable this feature, the first line and the last
1091 line are marked with angle images in the fringes.  This can be
1092 combined with up and down arrow images which say whether it is
1093 possible to scroll the window.
1095   The buffer-local variable @code{indicate-buffer-boundaries} controls
1096 how the buffer boundaries and window scrolling is indicated in the
1097 fringes.  If the value is @code{left} or @code{right}, both angle and
1098 arrow bitmaps are displayed in the left or right fringe, respectively.
1100   If value is an alist, each element @code{(@var{indicator} .
1101 @var{position})} specifies the position of one of the indicators.
1102 The @var{indicator} must be one of @code{top}, @code{bottom},
1103 @code{up}, @code{down}, or @code{t} which specifies the default
1104 position for the indicators not present in the alist.
1105 The @var{position} is one of @code{left}, @code{right}, or @code{nil}
1106 which specifies not to show this indicator.
1108   For example, @code{((top . left) (t . right))} places the top angle
1109 bitmap in left fringe, the bottom angle bitmap in right fringe, and
1110 both arrow bitmaps in right fringe.  To show just the angle bitmaps in
1111 the left fringe, but no arrow bitmaps, use @code{((top .  left)
1112 (bottom . left))}.
1114 @node Useless Whitespace
1115 @section Useless Whitespace
1117 @cindex trailing whitespace
1118 @cindex whitespace, trailing
1119 @vindex show-trailing-whitespace
1120   It is easy to leave unnecessary spaces at the end of a line, or
1121 empty lines at the end of a buffer, without realizing it.  In most
1122 cases, this @dfn{trailing whitespace} has no effect, but sometimes it
1123 can be a nuisance.
1125 @cindex trailing-whitespace face
1126   You can make trailing whitespace at the end of a line visible by
1127 setting the buffer-local variable @code{show-trailing-whitespace} to
1128 @code{t}.  Then Emacs displays trailing whitespace, using the face
1129 @code{trailing-whitespace}.
1131   This feature does not apply when point is at the end of the line
1132 containing the whitespace.  Strictly speaking, that is ``trailing
1133 whitespace'' nonetheless, but displaying it specially in that case
1134 looks ugly while you are typing in new text.  In this special case,
1135 the location of point is enough to show you that the spaces are
1136 present.
1138 @findex delete-trailing-whitespace
1139 @vindex delete-trailing-lines
1140   Type @kbd{M-x delete-trailing-whitespace} to delete all trailing
1141 whitespace.  This command deletes all extra spaces at the end of each
1142 line in the buffer, and all empty lines at the end of the buffer; to
1143 ignore the latter, change the variable @code{delete-trailing-lines} to
1144 @code{nil}.  If the region is active, the command instead deletes
1145 extra spaces at the end of each line in the region.
1147 @vindex indicate-empty-lines
1148 @cindex unused lines
1149 @cindex fringes, and unused line indication
1150   On graphical displays, Emacs can indicate unused lines at the end of
1151 the window with a small image in the left fringe (@pxref{Fringes}).
1152 The image appears for screen lines that do not correspond to any
1153 buffer text, so blank lines at the end of the buffer stand out because
1154 they lack this image.  To enable this feature, set the buffer-local
1155 variable @code{indicate-empty-lines} to a non-@code{nil} value.  You
1156 can enable or disable this feature for all new buffers by setting the
1157 default value of this variable, e.g., @code{(setq-default
1158 indicate-empty-lines t)}.
1160 @cindex Whitespace mode
1161 @cindex mode, Whitespace
1162 @findex whitespace-mode
1163 @vindex whitespace-style
1164   Whitespace mode is a buffer-local minor mode that lets you
1165 ``visualize'' many kinds of whitespace in the buffer, by either
1166 drawing the whitespace characters with a special face or displaying
1167 them as special glyphs.  To toggle this mode, type @kbd{M-x
1168 whitespace-mode}.  The kinds of whitespace visualized are determined
1169 by the list variable @code{whitespace-style}.  Here is a partial list
1170 of possible elements (see the variable's documentation for the full
1171 list):
1173 @table @code
1174 @item face
1175 Enable all visualizations which use special faces.  This element has a
1176 special meaning: if it is absent from the list, none of the other
1177 visualizations take effect except @code{space-mark}, @code{tab-mark},
1178 and @code{newline-mark}.
1180 @item trailing
1181 Highlight trailing whitespace.
1183 @item tabs
1184 Highlight tab characters.
1186 @item spaces
1187 Highlight space and non-breaking space characters.
1189 @item lines
1190 @vindex whitespace-line-column
1191 Highlight lines longer than 80 lines.  To change the column limit,
1192 customize the variable @code{whitespace-line-column}.
1194 @item newline
1195 Highlight newlines.
1197 @item empty
1198 Highlight empty lines.
1200 @item space-mark
1201 Draw space and non-breaking characters with a special glyph.
1203 @item tab-mark
1204 Draw tab characters with a special glyph.
1206 @item newline-mark
1207 Draw newline characters with a special glyph.
1208 @end table
1210 @node Selective Display
1211 @section Selective Display
1212 @cindex selective display
1213 @findex set-selective-display
1214 @kindex C-x $
1216   Emacs has the ability to hide lines indented more than a given
1217 number of columns.  You can use this to get an overview of a part of a
1218 program.
1220   To hide lines in the current buffer, type @kbd{C-x $}
1221 (@code{set-selective-display}) with a numeric argument @var{n}.  Then
1222 lines with at least @var{n} columns of indentation disappear from the
1223 screen.  The only indication of their presence is that three dots
1224 (@samp{@dots{}}) appear at the end of each visible line that is
1225 followed by one or more hidden ones.
1227   The commands @kbd{C-n} and @kbd{C-p} move across the hidden lines as
1228 if they were not there.
1230   The hidden lines are still present in the buffer, and most editing
1231 commands see them as usual, so you may find point in the middle of the
1232 hidden text.  When this happens, the cursor appears at the end of the
1233 previous line, after the three dots.  If point is at the end of the
1234 visible line, before the newline that ends it, the cursor appears before
1235 the three dots.
1237   To make all lines visible again, type @kbd{C-x $} with no argument.
1239 @vindex selective-display-ellipses
1240   If you set the variable @code{selective-display-ellipses} to
1241 @code{nil}, the three dots do not appear at the end of a line that
1242 precedes hidden lines.  Then there is no visible indication of the
1243 hidden lines.  This variable becomes local automatically when set.
1245   See also @ref{Outline Mode} for another way to hide part of
1246 the text in a buffer.
1248 @node Optional Mode Line
1249 @section Optional Mode Line Features
1251 @cindex buffer size display
1252 @cindex display of buffer size
1253 @findex size-indication-mode
1254   The buffer percentage @var{pos} indicates the percentage of the
1255 buffer above the top of the window.  You can additionally display the
1256 size of the buffer by typing @kbd{M-x size-indication-mode} to turn on
1257 Size Indication mode.  The size will be displayed immediately
1258 following the buffer percentage like this:
1260 @example
1261 @var{pos} of @var{size}
1262 @end example
1264 @noindent
1265 Here @var{size} is the human readable representation of the number of
1266 characters in the buffer, which means that @samp{k} for 10^3, @samp{M}
1267 for 10^6, @samp{G} for 10^9, etc., are used to abbreviate.
1269 @cindex line number display
1270 @cindex display of line number
1271 @findex line-number-mode
1272   The current line number of point appears in the mode line when Line
1273 Number mode is enabled.  Use the command @kbd{M-x line-number-mode} to
1274 turn this mode on and off; normally it is on.  The line number appears
1275 after the buffer percentage @var{pos}, with the letter @samp{L} to
1276 indicate what it is.
1278 @cindex Column Number mode
1279 @cindex mode, Column Number
1280 @findex column-number-mode
1281   Similarly, you can display the current column number by turning on
1282 Column number mode with @kbd{M-x column-number-mode}.  The column
1283 number is indicated by the letter @samp{C}.  However, when both of
1284 these modes are enabled, the line and column numbers are displayed in
1285 parentheses, the line number first, rather than with @samp{L} and
1286 @samp{C}.  For example: @samp{(561,2)}.  @xref{Minor Modes}, for more
1287 information about minor modes and about how to use these commands.
1289 @cindex narrowing, and line number display
1290   If you have narrowed the buffer (@pxref{Narrowing}), the displayed
1291 line number is relative to the accessible portion of the buffer.
1292 Thus, it isn't suitable as an argument to @code{goto-line}.  (Use
1293 @code{what-line} command to see the line number relative to the whole
1294 file.)
1296 @vindex line-number-display-limit
1297   If the buffer is very large (larger than the value of
1298 @code{line-number-display-limit}), Emacs won't compute the line
1299 number, because that would be too slow; therefore, the line number
1300 won't appear on the mode-line.  To remove this limit, set
1301 @code{line-number-display-limit} to @code{nil}.
1303 @vindex line-number-display-limit-width
1304   Line-number computation can also be slow if the lines in the buffer
1305 are too long.  For this reason, Emacs doesn't display line numbers if
1306 the average width, in characters, of lines near point is larger than
1307 the value of @code{line-number-display-limit-width}.  The default
1308 value is 200 characters.
1310 @findex display-time
1311 @cindex time (on mode line)
1312   Emacs can optionally display the time and system load in all mode
1313 lines.  To enable this feature, type @kbd{M-x display-time} or customize
1314 the option @code{display-time-mode}.  The information added to the mode
1315 line looks like this:
1317 @example
1318 @var{hh}:@var{mm}pm @var{l.ll}
1319 @end example
1321 @noindent
1322 @vindex display-time-24hr-format
1323 Here @var{hh} and @var{mm} are the hour and minute, followed always by
1324 @samp{am} or @samp{pm}.  @var{l.ll} is the average number, collected
1325 for the last few minutes, of processes in the whole system that were
1326 either running or ready to run (i.e., were waiting for an available
1327 processor).  (Some fields may be missing if your operating system
1328 cannot support them.)  If you prefer time display in 24-hour format,
1329 set the variable @code{display-time-24hr-format} to @code{t}.
1331 @cindex mail (on mode line)
1332 @vindex display-time-use-mail-icon
1333 @vindex display-time-mail-face
1334 @vindex display-time-mail-file
1335 @vindex display-time-mail-directory
1336   The word @samp{Mail} appears after the load level if there is mail
1337 for you that you have not read yet.  On graphical displays, you can
1338 use an icon instead of @samp{Mail} by customizing
1339 @code{display-time-use-mail-icon}; this may save some space on the
1340 mode line.  You can customize @code{display-time-mail-face} to make
1341 the mail indicator prominent.  Use @code{display-time-mail-file} to
1342 specify the mail file to check, or set
1343 @code{display-time-mail-directory} to specify the directory to check
1344 for incoming mail (any nonempty regular file in the directory is
1345 considered as ``newly arrived mail'').
1347 @cindex battery status (on mode line)
1348 @findex display-battery-mode
1349 @vindex display-battery-mode
1350 @vindex battery-mode-line-format
1351   When running Emacs on a laptop computer, you can display the battery
1352 charge on the mode-line, by using the command
1353 @code{display-battery-mode} or customizing the variable
1354 @code{display-battery-mode}.  The variable
1355 @code{battery-mode-line-format} determines the way the battery charge
1356 is displayed; the exact mode-line message depends on the operating
1357 system, and it usually shows the current battery charge as a
1358 percentage of the total charge.
1360 @cindex mode line, 3D appearance
1361 @cindex attributes of mode line, changing
1362 @cindex non-integral number of lines in a window
1363   On graphical displays, the mode line is drawn as a 3D box.  If you
1364 don't like this effect, you can disable it by customizing the
1365 @code{mode-line} face and setting its @code{box} attribute to
1366 @code{nil}.  @xref{Face Customization}.
1368 @cindex non-selected windows, mode line appearance
1369   By default, the mode line of nonselected windows is displayed in a
1370 different face, called @code{mode-line-inactive}.  Only the selected
1371 window is displayed in the @code{mode-line} face.  This helps show
1372 which window is selected.  When the minibuffer is selected, since
1373 it has no mode line, the window from which you activated the minibuffer
1374 has its mode line displayed using @code{mode-line}; as a result,
1375 ordinary entry to the minibuffer does not change any mode lines.
1377 @vindex mode-line-in-non-selected-windows
1378   You can disable use of @code{mode-line-inactive} by setting variable
1379 @code{mode-line-in-non-selected-windows} to @code{nil}; then all mode
1380 lines are displayed in the @code{mode-line} face.
1382 @vindex eol-mnemonic-unix
1383 @vindex eol-mnemonic-dos
1384 @vindex eol-mnemonic-mac
1385 @vindex eol-mnemonic-undecided
1386   You can customize the mode line display for each of the end-of-line
1387 formats by setting each of the variables @code{eol-mnemonic-unix},
1388 @code{eol-mnemonic-dos}, @code{eol-mnemonic-mac}, and
1389 @code{eol-mnemonic-undecided} to the strings you prefer.
1391 @node Text Display
1392 @section How Text Is Displayed
1393 @cindex characters (in text)
1394 @cindex printing character
1396   Most characters are @dfn{printing characters}: when they appear in a
1397 buffer, they are displayed literally on the screen.  Printing
1398 characters include @acronym{ASCII} numbers, letters, and punctuation
1399 characters, as well as many non-@acronym{ASCII} characters.
1401 @vindex tab-width
1402 @cindex control characters on display
1403   The @acronym{ASCII} character set contains non-printing @dfn{control
1404 characters}.  Two of these are displayed specially: the newline
1405 character (Unicode code point @code{U+000A}) is displayed by starting
1406 a new line, while the tab character (@code{U+0009}) is displayed as a
1407 space that extends to the next tab stop column (normally every 8
1408 columns).  The number of spaces per tab is controlled by the
1409 buffer-local variable @code{tab-width}, which must have an integer
1410 value between 1 and 1000, inclusive.  Note that how the tab character
1411 in the buffer is displayed has nothing to do with the definition of
1412 @key{TAB} as a command.
1414   Other @acronym{ASCII} control characters, whose codes are below
1415 @code{U+0020} (octal 40, decimal 32), are displayed as a caret
1416 (@samp{^}) followed by the non-control version of the character, with
1417 the @code{escape-glyph} face.  For instance, the @samp{control-A}
1418 character, @code{U+0001}, is displayed as @samp{^A}.
1420 @cindex octal escapes
1421 @vindex ctl-arrow
1422   The raw bytes with codes @code{U+0080} (octal 200) through
1423 @code{U+009F} (octal 237) are displayed as @dfn{octal escape
1424 sequences}, with the @code{escape-glyph} face.  For instance,
1425 character code @code{U+0098} (octal 230) is displayed as @samp{\230}.
1426 If you change the buffer-local variable @code{ctl-arrow} to
1427 @code{nil}, the @acronym{ASCII} control characters are also displayed
1428 as octal escape sequences instead of caret escape sequences.
1430 @vindex nobreak-char-display
1431 @cindex non-breaking space
1432 @cindex non-breaking hyphen
1433 @cindex soft hyphen
1434 @cindex escape-glyph face
1435 @cindex nobreak-space face
1436   Some non-@acronym{ASCII} characters have the same appearance as an
1437 @acronym{ASCII} space or hyphen (minus) character.  Such characters
1438 can cause problems if they are entered into a buffer without your
1439 realization, e.g., by yanking; for instance, source code compilers
1440 typically do not treat non-@acronym{ASCII} spaces as whitespace
1441 characters.  To deal with this problem, Emacs displays such characters
1442 specially: it displays @code{U+00A0} (no-break space) with the
1443 @code{nobreak-space} face, and it displays @code{U+00AD} (soft
1444 hyphen), @code{U+2010} (hyphen), and @code{U+2011} (non-breaking
1445 hyphen) with the @code{escape-glyph} face.  To disable this, change
1446 the variable @code{nobreak-char-display} to @code{nil}.  If you give
1447 this variable a non-@code{nil} and non-@code{t} value, Emacs instead
1448 displays such characters as a highlighted backslash followed by a
1449 space or hyphen.
1451   You can customize the way any particular character code is displayed
1452 by means of a display table.  @xref{Display Tables,, Display Tables,
1453 elisp, The Emacs Lisp Reference Manual}.
1455 @cindex glyphless characters
1456 @cindex characters with no font glyphs
1457   On graphical displays, some characters may have no glyphs in any of
1458 the fonts available to Emacs.  These @dfn{glyphless characters} are
1459 normally displayed as boxes containing the hexadecimal character code.
1460 Similarly, on text terminals, characters that cannot be displayed
1461 using the terminal encoding (@pxref{Terminal Coding}) are normally
1462 displayed as question signs.  You can control the display method by
1463 customizing the variable @code{glyphless-char-display-control}.
1464 @xref{Glyphless Chars,, Glyphless Character Display, elisp, The Emacs
1465 Lisp Reference Manual}, for details.
1467 @node Cursor Display
1468 @section Displaying the Cursor
1469 @cindex text cursor
1471 @vindex visible-cursor
1472   On a text terminal, the cursor's appearance is controlled by the
1473 terminal, largely out of the control of Emacs.  Some terminals offer
1474 two different cursors: a ``visible'' static cursor, and a ``very
1475 visible'' blinking cursor.  By default, Emacs uses the very visible
1476 cursor, and switches to it when you start or resume Emacs.  If the
1477 variable @code{visible-cursor} is @code{nil} when Emacs starts or
1478 resumes, it uses the normal cursor.
1480 @cindex cursor face
1481 @vindex cursor-type
1482   On a graphical display, many more properties of the text cursor can
1483 be altered.  To customize its color, change the @code{:background}
1484 attribute of the face named @code{cursor} (@pxref{Face
1485 Customization}).  (The other attributes of this face have no effect;
1486 the text shown under the cursor is drawn using the frame's background
1487 color.)  To change its shape, customize the buffer-local variable
1488 @code{cursor-type}; possible values are @code{box} (the default),
1489 @code{hollow} (a hollow box), @code{bar} (a vertical bar), @code{(bar
1490 . @var{n})} (a vertical bar @var{n} pixels wide), @code{hbar} (a
1491 horizontal bar), @code{(hbar . @var{n})} (a horizontal bar @var{n}
1492 pixels tall), or @code{nil} (no cursor at all).
1494 @findex blink-cursor-mode
1495 @cindex cursor, blinking
1496 @cindex blinking cursor
1497 @vindex blink-cursor-mode
1498 @vindex blink-cursor-blinks
1499 @vindex blink-cursor-alist
1500   By default, the cursor stops blinking after 10 blinks, if Emacs does
1501 not get any input during that time; any input event restarts the
1502 count.  You can customize the variable @code{blink-cursor-blinks} to
1503 control that: its value says how many times to blink without input
1504 before stopping.  Setting that variable to a zero or negative value
1505 will make the cursor blink forever.  To disable cursor blinking
1506 altogether, change the variable @code{blink-cursor-mode} to @code{nil}
1507 (@pxref{Easy Customization}), or add the line
1509 @lisp
1510   (blink-cursor-mode 0)
1511 @end lisp
1513 @noindent
1514 to your init file.  Alternatively, you can change how the cursor
1515 looks when it ``blinks off'' by customizing the list variable
1516 @code{blink-cursor-alist}.  Each element in the list should have the
1517 form @code{(@var{on-type} . @var{off-type})}; this means that if the
1518 cursor is displayed as @var{on-type} when it blinks on (where
1519 @var{on-type} is one of the cursor types described above), then it is
1520 displayed as @var{off-type} when it blinks off.
1522 @vindex x-stretch-cursor
1523 @cindex wide block cursor
1524   Some characters, such as tab characters, are ``extra wide''.  When
1525 the cursor is positioned over such a character, it is normally drawn
1526 with the default character width.  You can make the cursor stretch to
1527 cover wide characters, by changing the variable
1528 @code{x-stretch-cursor} to a non-@code{nil} value.
1530 @cindex cursor in non-selected windows
1531 @vindex cursor-in-non-selected-windows
1532   The cursor normally appears in non-selected windows as a
1533 non-blinking hollow box.  (For a bar cursor, it instead appears as a
1534 thinner bar.)  To turn off cursors in non-selected windows, change the
1535 variable @code{cursor-in-non-selected-windows} to @code{nil}.
1537 @findex hl-line-mode
1538 @findex global-hl-line-mode
1539 @cindex highlight current line
1540   To make the cursor even more visible, you can use HL Line mode, a
1541 minor mode that highlights the line containing point.  Use @kbd{M-x
1542 hl-line-mode} to enable or disable it in the current buffer.  @kbd{M-x
1543 global-hl-line-mode} enables or disables the same mode globally.
1545 @node Line Truncation
1546 @section Line Truncation
1548 @cindex truncation
1549 @cindex line truncation, and fringes
1550   As an alternative to continuation (@pxref{Continuation Lines}),
1551 Emacs can display long lines by @dfn{truncation}.  This means that all
1552 the characters that do not fit in the width of the screen or window do
1553 not appear at all.  On graphical displays, a small straight arrow in
1554 the fringe indicates truncation at either end of the line.  On text
1555 terminals, this is indicated with @samp{$} signs in the leftmost
1556 and/or rightmost columns.
1558 @vindex truncate-lines
1559 @findex toggle-truncate-lines
1560   Horizontal scrolling automatically causes line truncation
1561 (@pxref{Horizontal Scrolling}).  You can explicitly enable line
1562 truncation for a particular buffer with the command @kbd{M-x
1563 toggle-truncate-lines}.  This works by locally changing the variable
1564 @code{truncate-lines}.  If that variable is non-@code{nil}, long lines
1565 are truncated; if it is @code{nil}, they are continued onto multiple
1566 screen lines.  Setting the variable @code{truncate-lines} in any way
1567 makes it local to the current buffer; until that time, the default
1568 value, which is normally @code{nil}, is in effect.
1570 @vindex truncate-partial-width-windows
1571   If a split window becomes too narrow, Emacs may automatically enable
1572 line truncation.  @xref{Split Window}, for the variable
1573 @code{truncate-partial-width-windows} which controls this.
1575 @node Visual Line Mode
1576 @section Visual Line Mode
1578 @cindex word wrap
1579   Another alternative to ordinary line continuation is to use
1580 @dfn{word wrap}.  Here, each long logical line is divided into two or
1581 more screen lines, like in ordinary line continuation.  However, Emacs
1582 attempts to wrap the line at word boundaries near the right window
1583 edge.  This makes the text easier to read, as wrapping does not occur
1584 in the middle of words.
1586 @cindex mode, Visual Line
1587 @cindex Visual Line mode
1588 @findex visual-line-mode
1589 @findex global-visual-line-mode
1590   Word wrap is enabled by Visual Line mode, an optional minor mode.
1591 To turn on Visual Line mode in the current buffer, type @kbd{M-x
1592 visual-line-mode}; repeating this command turns it off.  You can also
1593 turn on Visual Line mode using the menu bar: in the Options menu,
1594 select the @samp{Line Wrapping in this Buffer} submenu, followed by
1595 the @samp{Word Wrap (Visual Line Mode)} menu item.  While Visual Line
1596 mode is enabled, the mode-line shows the string @samp{wrap} in the
1597 mode display.  The command @kbd{M-x global-visual-line-mode} toggles
1598 Visual Line mode in all buffers.
1600 @findex beginning-of-visual-line
1601 @findex end-of-visual-line
1602 @findex next-logical-line
1603 @findex previous-logical-line
1604   In Visual Line mode, some editing commands work on screen lines
1605 instead of logical lines: @kbd{C-a} (@code{beginning-of-visual-line})
1606 moves to the beginning of the screen line, @kbd{C-e}
1607 (@code{end-of-visual-line}) moves to the end of the screen line, and
1608 @kbd{C-k} (@code{kill-visual-line}) kills text to the end of the
1609 screen line.
1611   To move by logical lines, use the commands @kbd{M-x
1612 next-logical-line} and @kbd{M-x previous-logical-line}.  These move
1613 point to the next logical line and the previous logical line
1614 respectively, regardless of whether Visual Line mode is enabled.  If
1615 you use these commands frequently, it may be convenient to assign key
1616 bindings to them.  @xref{Init Rebinding}.
1618   By default, word-wrapped lines do not display fringe indicators.
1619 Visual Line mode is often used to edit files that contain many long
1620 logical lines, so having a fringe indicator for each wrapped line
1621 would be visually distracting.  You can change this by customizing the
1622 variable @code{visual-line-fringe-indicators}.
1624 @node Display Custom
1625 @section Customization of Display
1627   This section describes variables that control miscellaneous aspects
1628 of the appearance of the Emacs screen.  Beginning users can skip it.
1630 @vindex visible-bell
1631   If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
1632 to make the whole screen blink when it would normally make an audible bell
1633 sound.  This variable has no effect if your terminal does not have a way
1634 to make the screen blink.
1636 @vindex echo-keystrokes
1637   The variable @code{echo-keystrokes} controls the echoing of multi-character
1638 keys; its value is the number of seconds of pause required to cause echoing
1639 to start, or zero, meaning don't echo at all.  The value takes effect when
1640 there is something to echo.  @xref{Echo Area}.
1642 @cindex mouse pointer
1643 @cindex hourglass pointer display
1644 @vindex display-hourglass
1645 @vindex hourglass-delay
1646   On graphical displays, Emacs displays the mouse pointer as an
1647 hourglass if Emacs is busy.  To disable this feature, set the variable
1648 @code{display-hourglass} to @code{nil}.  The variable
1649 @code{hourglass-delay} determines the number of seconds of ``busy
1650 time'' before the hourglass is shown; the default is 1.
1652 @vindex make-pointer-invisible
1653   If the mouse pointer lies inside an Emacs frame, Emacs makes it
1654 invisible each time you type a character to insert text, to prevent it
1655 from obscuring the text.  (To be precise, the hiding occurs when you
1656 type a ``self-inserting'' character.  @xref{Inserting Text}.)  Moving
1657 the mouse pointer makes it visible again.  To disable this feature,
1658 set the variable @code{make-pointer-invisible} to @code{nil}.
1660 @vindex underline-minimum-offset
1661 @vindex x-underline-at-descent-line
1662   On graphical displays, the variable @code{underline-minimum-offset}
1663 determines the minimum distance between the baseline and underline, in
1664 pixels, for underlined text.  By default, the value is 1; increasing
1665 it may improve the legibility of underlined text for certain fonts.
1666 (However, Emacs will never draw the underline below the current line
1667 area.)  The variable @code{x-underline-at-descent-line} determines how
1668 to draw underlined text.  The default is @code{nil}, which means to
1669 draw it at the baseline level of the font; if you change it to
1670 @code{nil}, Emacs draws the underline at the same height as the font's
1671 descent line.
1673 @vindex overline-margin
1674   The variable @code{overline-margin} specifies the vertical position
1675 of an overline above the text, including the height of the overline
1676 itself, in pixels; the default is 2.
1678 @findex tty-suppress-bold-inverse-default-colors
1679   On some text terminals, bold face and inverse video together result
1680 in text that is hard to read.  Call the function
1681 @code{tty-suppress-bold-inverse-default-colors} with a non-@code{nil}
1682 argument to suppress the effect of bold-face in this case.