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