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