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