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