]> code.delx.au - gnu-emacs/blob - doc/emacs/display.texi
Edits to Display chapter of Emacs manual.
[gnu-emacs] / 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 ``non-breaking'' 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 This face determines the color of the text cursor.
603 @item tooltip
604 This face is used for tooltip text. By default, if Emacs is built
605 with GTK support, tooltips are drawn via GTK and this face has no
606 effect. @xref{Tooltips}.
607 @item mouse
608 This face determines the color of the mouse pointer.
609 @end table
610
611 The following faces likewise control the appearance of parts of the
612 Emacs frame, but only on text-only terminals, or when Emacs is built
613 on X with no toolkit support. (For all other cases, the appearance of
614 the respective frame elements is determined by system-wide settings.)
615
616 @table @code
617 @item scroll-bar
618 This face determines the visual appearance of the scroll bar.
619 @xref{Scroll Bars}.
620 @item tool-bar
621 This face determines the color of tool bar icons. @xref{Tool Bars}.
622 @item menu
623 @cindex menu bar appearance
624 @cindex @code{menu} face, no effect if customized
625 @cindex customization of @code{menu} face
626 This face determines the colors and font of Emacs's menus. @xref{Menu
627 Bars}.
628 @end table
629
630 @node Text Scale
631 @section Text Scale
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 text height by a factor
649 of 1.2; to change this factor, customize the variable
650 @code{text-scale-mode-step}. As an exception, a numeric argument of 0
651 to the @code{text-scale-adjust} command restores the default height,
652 similar to typing @kbd{C-x C-0}.
653
654 @cindex increase buffer face height
655 @findex text-scale-increase
656 @cindex decrease buffer face height
657 @findex text-scale-decrease
658 The commands @code{text-scale-increase} and
659 @code{text-scale-decrease} increase or decrease the height of the
660 default face, just like @kbd{C-x C-+} and @kbd{C-x C--} respectively.
661 You may find it convenient to bind to these commands, rather than
662 @code{text-scale-adjust}.
663
664 @cindex set buffer face height
665 @findex text-scale-set
666 The command @code{text-scale-set} scales the height of the default
667 face in the current buffer to an absolute level specified by its
668 prefix argument.
669
670 @findex text-scale-mode
671 The above commands automatically enable the minor mode
672 @code{text-scale-mode} if the current font scaling is other than 1,
673 and disable it otherwise.
674
675 @node Font Lock
676 @section Font Lock mode
677 @cindex Font Lock mode
678 @cindex mode, Font Lock
679 @cindex syntax highlighting and coloring
680
681 Font Lock mode is a minor mode, always local to a particular buffer,
682 which assigns faces to (or @dfn{fontifies}) the text in the buffer.
683 Each buffer's major mode tells Font Lock mode which text to fontify;
684 for instance, programming language modes fontify syntactically
685 relevant constructs like comments, strings, and function names.
686
687 @findex font-lock-mode
688 Font Lock mode is enabled by default. To toggle it in the current
689 buffer, type @kbd{M-x font-lock-mode}. A positive numeric argument
690 unconditionally enables Font Lock mode, and a negative or zero
691 argument disables it.
692
693 @findex global-font-lock-mode
694 @vindex global-font-lock-mode
695 To toggle Font Lock mode in all buffers, type @kbd{M-x
696 global-font-lock-mode}. To impose this setting for future Emacs
697 sessions, customize the variable @code{global-font-lock-mode}
698 (@pxref{Easy Customization}), or add the following line to your init
699 file:
700
701 @example
702 (global-font-lock-mode 0)
703 @end example
704
705 @findex turn-on-font-lock
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{turn-on-font-lock} to the mode hooks (@pxref{Hooks}). For
710 example, to enable Font Lock mode for editing C files, you can do
711 this:
712
713 @example
714 (add-hook 'c-mode-hook 'turn-on-font-lock)
715 @end example
716
717 Font Lock mode uses several specifically named faces to do its job,
718 including @code{font-lock-string-face}, @code{font-lock-comment-face},
719 and others. The easiest way to find them all is to use @kbd{M-x
720 customize-group @key{RET} font-lock-faces @key{RET}}. You can then
721 use that customization buffer to customize the appearance of these
722 faces. @xref{Face Customization}.
723
724 @vindex font-lock-maximum-decoration
725 You can customize the variable @code{font-lock-maximum-decoration}
726 to alter the amount of fontification applied by Font Lock mode, for
727 major modes that support this feature. The value should be a number
728 (with 1 representing a minimal amount of fontification; some modes
729 support levels as high as 3); or @code{t}, meaning ``as high as
730 possible'' (the default). You can also specify different numbers for
731 particular major modes; for example, to use level 1 for C/C++ modes,
732 and the default level otherwise, use the value
733
734 @example
735 '((c-mode . 1) (c++-mode . 1)))
736 @end example
737
738 @vindex font-lock-beginning-of-syntax-function
739 @cindex incorrect fontification
740 @cindex parenthesis in column zero and fontification
741 @cindex brace in column zero and fontification
742 Comment and string fontification (or ``syntactic'' fontification)
743 relies on analysis of the syntactic structure of the buffer text. For
744 the sake of speed, some modes, including Lisp mode, rely on a special
745 convention: an open-parenthesis or open-brace in the leftmost column
746 always defines the beginning of a defun, and is thus always outside
747 any string or comment. Therefore, you should avoid placing a an
748 open-parenthesis or open-brace in the leftmost column, if it is inside
749 a string or comment. @xref{Left Margin Paren}, for details.
750
751 @cindex slow display during scrolling
752 The variable @code{font-lock-beginning-of-syntax-function}, which is
753 always buffer-local, specifies how Font Lock mode can find a position
754 guaranteed to be outside any comment or string. In modes which use
755 the leftmost column parenthesis convention, the default value of the
756 variable is @code{beginning-of-defun}---that tells Font Lock mode to
757 use the convention. If you set this variable to @code{nil}, Font Lock
758 no longer relies on the convention. This avoids incorrect results,
759 but the price is that, in some cases, fontification for a changed text
760 must rescan buffer text from the beginning of the buffer. This can
761 considerably slow down redisplay while scrolling, particularly if you
762 are close to the end of a large buffer.
763
764 @findex font-lock-add-keywords
765 Font Lock highlighting patterns already exist for most modes, but
766 you may want to fontify additional patterns. You can use the function
767 @code{font-lock-add-keywords}, to add your own highlighting patterns
768 for a particular mode. For example, to highlight @samp{FIXME:} words
769 in C comments, use this:
770
771 @example
772 (add-hook 'c-mode-hook
773 (lambda ()
774 (font-lock-add-keywords nil
775 '(("\\<\\(FIXME\\):" 1
776 font-lock-warning-face t)))))
777 @end example
778
779 @findex font-lock-remove-keywords
780 @noindent
781 To remove keywords from the font-lock highlighting patterns, use the
782 function @code{font-lock-remove-keywords}. @xref{Search-based
783 Fontification,,, elisp, The Emacs Lisp Reference Manual}.
784
785 @cindex just-in-time (JIT) font-lock
786 @cindex background syntax highlighting
787 Fontifying large buffers can take a long time. To avoid large
788 delays when a file is visited, Emacs initially fontifies only the
789 visible portion of a buffer. As you scroll through the buffer, each
790 portion that becomes visible is fontified as soon as it is displayed;
791 this type of Font Lock is called @dfn{Just-In-Time} (or @dfn{JIT})
792 Lock. You can control how JIT Lock behaves, including telling it to
793 perform fontification while idle, by customizing variables in the
794 customization group @samp{jit-lock}. @xref{Specific Customization}.
795
796 @node Highlight Interactively
797 @section Interactive Highlighting
798 @cindex highlighting by matching
799 @cindex interactive highlighting
800 @cindex Highlight Changes mode
801
802 @findex highlight-changes-mode
803 Highlight Changes mode is a minor mode that @dfn{highlights} the parts
804 of the buffer that were changed most recently, by giving that text a
805 different face. To enable or disable Highlight Changes mode, use
806 @kbd{M-x highlight-changes-mode}.
807
808 @cindex Hi Lock mode
809 @findex hi-lock-mode
810 Hi Lock mode is a minor mode that highlights text that matches
811 regular expressions you specify. For example, you can use it to
812 highlight all the references to a certain variable in a program source
813 file, highlight certain parts in a voluminous output of some program,
814 or highlight certain names in an article. To enable or disable Hi
815 Lock mode, use the command @kbd{M-x hi-lock-mode}. To enable Hi Lock
816 mode for all buffers, use @kbd{M-x global-hi-lock-mode} or place
817 @code{(global-hi-lock-mode 1)} in your @file{.emacs} file.
818
819 Hi Lock mode works like Font Lock mode (@pxref{Font Lock}), except
820 that you specify explicitly the regular expressions to highlight. You
821 control them with these commands:
822
823 @table @kbd
824 @item C-x w h @var{regexp} @key{RET} @var{face} @key{RET}
825 @kindex C-x w h
826 @findex highlight-regexp
827 Highlight text that matches @var{regexp} using face @var{face}
828 (@code{highlight-regexp}). The highlighting will remain as long as
829 the buffer is loaded. For example, to highlight all occurrences of
830 the word ``whim'' using the default face (a yellow background)
831 @kbd{C-x w h whim @key{RET} @key{RET}}. Any face can be used for
832 highlighting, Hi Lock provides several of its own and these are
833 pre-loaded into a list of default values. While being prompted
834 for a face use @kbd{M-n} and @kbd{M-p} to cycle through them.
835
836 You can use this command multiple times, specifying various regular
837 expressions to highlight in different ways.
838
839 @item C-x w r @var{regexp} @key{RET}
840 @kindex C-x w r
841 @findex unhighlight-regexp
842 Unhighlight @var{regexp} (@code{unhighlight-regexp}).
843
844 If you invoke this from the menu, you select the expression to
845 unhighlight from a list. If you invoke this from the keyboard, you
846 use the minibuffer. It will show the most recently added regular
847 expression; use @kbd{M-p} to show the next older expression and
848 @kbd{M-n} to select the next newer expression. (You can also type the
849 expression by hand, with completion.) When the expression you want to
850 unhighlight appears in the minibuffer, press @kbd{@key{RET}} to exit
851 the minibuffer and unhighlight it.
852
853 @item C-x w l @var{regexp} @key{RET} @var{face} @key{RET}
854 @kindex C-x w l
855 @findex highlight-lines-matching-regexp
856 @cindex lines, highlighting
857 @cindex highlighting lines of text
858 Highlight entire lines containing a match for @var{regexp}, using face
859 @var{face} (@code{highlight-lines-matching-regexp}).
860
861 @item C-x w b
862 @kindex C-x w b
863 @findex hi-lock-write-interactive-patterns
864 Insert all the current highlighting regexp/face pairs into the buffer
865 at point, with comment delimiters to prevent them from changing your
866 program. (This key binding runs the
867 @code{hi-lock-write-interactive-patterns} command.)
868
869 These patterns are extracted from the comments, if appropriate, if you
870 invoke @kbd{M-x hi-lock-find-patterns}, or if you visit the file while
871 Hi Lock mode is enabled (since that runs @code{hi-lock-find-patterns}).
872
873 @item C-x w i
874 @kindex C-x w i
875 @findex hi-lock-find-patterns
876 Extract regexp/face pairs from comments in the current buffer
877 (@code{hi-lock-find-patterns}). Thus, you can enter patterns
878 interactively with @code{highlight-regexp}, store them into the file
879 with @code{hi-lock-write-interactive-patterns}, edit them (perhaps
880 including different faces for different parenthesized parts of the
881 match), and finally use this command (@code{hi-lock-find-patterns}) to
882 have Hi Lock highlight the edited patterns.
883
884 @vindex hi-lock-file-patterns-policy
885 The variable @code{hi-lock-file-patterns-policy} controls whether Hi
886 Lock mode should automatically extract and highlight patterns found in a
887 file when it is visited. Its value can be @code{nil} (never highlight),
888 @code{ask} (query the user), or a function. If it is a function,
889 @code{hi-lock-find-patterns} calls it with the patterns as argument; if
890 the function returns non-@code{nil}, the patterns are used. The default
891 is @code{ask}. Note that patterns are always highlighted if you call
892 @code{hi-lock-find-patterns} directly, regardless of the value of this
893 variable.
894
895 @vindex hi-lock-exclude-modes
896 Also, @code{hi-lock-find-patterns} does nothing if the current major
897 mode's symbol is a member of the list @code{hi-lock-exclude-modes}.
898 @end table
899
900 @node Fringes
901 @section Window Fringes
902 @cindex fringes
903
904 On a graphical display, each Emacs window normally has narrow
905 @dfn{fringes} on the left and right edges. The fringes are used to
906 display symbols that provide information about the text in the window.
907
908 The most common use of the fringes is to indicate a continuation
909 line (@pxref{Continuation Lines}). When one line of text is split
910 into multiple screen lines, the left fringe shows a curving arrow for
911 each screen line except the first, indicating that ``this is not the
912 real beginning.'' The right fringe shows a curving arrow for each
913 screen line except the last, indicating that ``this is not the real
914 end.'' If the line's direction is right-to-left (@pxref{Bidirectional
915 Editing}), the meanings of the curving arrows in the fringes are
916 swapped.
917
918 The fringes indicate line truncation with short horizontal arrows
919 meaning ``there's more text on this line which is scrolled
920 horizontally out of view.'' Clicking the mouse on one of the arrows
921 scrolls the display horizontally in the direction of the arrow.
922
923 The fringes can also indicate other things, such as buffer
924 boundaries (@pxref{Displaying Boundaries}), and where a program you
925 are debugging is executing (@pxref{Debuggers}).
926
927 @findex set-fringe-style
928 @findex fringe-mode
929 You can enable and disable the fringes for all frames using
930 @kbd{M-x fringe-mode}. To enable and disable the fringes
931 for the selected frame, use @kbd{M-x set-fringe-style}.
932
933 @node Displaying Boundaries
934 @section Displaying Boundaries
935
936 @vindex indicate-buffer-boundaries
937 On a graphical display, Emacs can indicate the buffer boundaries in
938 the fringes. If you enable this feature, the first line and the last
939 line are marked with angle images in the fringes. This can be
940 combined with up and down arrow images which say whether it is
941 possible to scroll the window.
942
943 The buffer-local variable @code{indicate-buffer-boundaries} controls
944 how the buffer boundaries and window scrolling is indicated in the
945 fringes. If the value is @code{left} or @code{right}, both angle and
946 arrow bitmaps are displayed in the left or right fringe, respectively.
947
948 If value is an alist, each element @code{(@var{indicator} .
949 @var{position})} specifies the position of one of the indicators.
950 The @var{indicator} must be one of @code{top}, @code{bottom},
951 @code{up}, @code{down}, or @code{t} which specifies the default
952 position for the indicators not present in the alist.
953 The @var{position} is one of @code{left}, @code{right}, or @code{nil}
954 which specifies not to show this indicator.
955
956 For example, @code{((top . left) (t . right))} places the top angle
957 bitmap in left fringe, the bottom angle bitmap in right fringe, and
958 both arrow bitmaps in right fringe. To show just the angle bitmaps in
959 the left fringe, but no arrow bitmaps, use @code{((top . left)
960 (bottom . left))}.
961
962 @node Useless Whitespace
963 @section Useless Whitespace
964
965 @cindex trailing whitespace
966 @cindex whitespace, trailing
967 @vindex show-trailing-whitespace
968 It is easy to leave unnecessary spaces at the end of a line, or
969 empty lines at the end of a file, without realizing it. In most
970 cases, this @dfn{trailing whitespace} has no effect, but there are
971 special circumstances where it matters, and it can be a nuisance.
972
973 You can make trailing whitespace at the end of a line visible by
974 setting the buffer-local variable @code{show-trailing-whitespace} to
975 @code{t}. Then Emacs displays trailing whitespace, using the face
976 @code{trailing-whitespace}.
977
978 This feature does not apply when point is at the end of the line
979 containing the whitespace. Strictly speaking, that is ``trailing
980 whitespace'' nonetheless, but displaying it specially in that case
981 looks ugly while you are typing in new text. In this special case,
982 the location of point is enough to show you that the spaces are
983 present.
984
985 @findex delete-trailing-whitespace
986 Type @kbd{M-x delete-trailing-whitespace} to delete all trailing
987 whitespace within the buffer. If the region is active, it deletes all
988 trailing whitespace in the region instead.
989
990 @vindex indicate-empty-lines
991 @cindex unused lines
992 @cindex fringes, and unused line indication
993 On graphical displays, Emacs can indicate unused lines at the end of
994 the window with a small image in the left fringe (@pxref{Fringes}).
995 The image appears for window lines that do not correspond to any
996 buffer text. Blank lines at the end of the buffer then stand out
997 because they do not have this image in the fringe. To enable this
998 feature, set the buffer-local variable @code{indicate-empty-lines} to
999 a non-@code{nil} value. You can enable or disable this feature for
1000 all new buffers by setting the default value of this variable,
1001 e.g.@:@code{(setq-default indicate-empty-lines t)}.
1002
1003 @node Selective Display
1004 @section Selective Display
1005 @cindex selective display
1006 @findex set-selective-display
1007 @kindex C-x $
1008
1009 Emacs has the ability to hide lines indented more than a given
1010 number of columns. You can use this to get an overview of a part of a
1011 program.
1012
1013 To hide lines in the current buffer, type @kbd{C-x $}
1014 (@code{set-selective-display}) with a numeric argument @var{n}. Then
1015 lines with at least @var{n} columns of indentation disappear from the
1016 screen. The only indication of their presence is that three dots
1017 (@samp{@dots{}}) appear at the end of each visible line that is
1018 followed by one or more hidden ones.
1019
1020 The commands @kbd{C-n} and @kbd{C-p} move across the hidden lines as
1021 if they were not there.
1022
1023 The hidden lines are still present in the buffer, and most editing
1024 commands see them as usual, so you may find point in the middle of the
1025 hidden text. When this happens, the cursor appears at the end of the
1026 previous line, after the three dots. If point is at the end of the
1027 visible line, before the newline that ends it, the cursor appears before
1028 the three dots.
1029
1030 To make all lines visible again, type @kbd{C-x $} with no argument.
1031
1032 @vindex selective-display-ellipses
1033 If you set the variable @code{selective-display-ellipses} to
1034 @code{nil}, the three dots do not appear at the end of a line that
1035 precedes hidden lines. Then there is no visible indication of the
1036 hidden lines. This variable becomes local automatically when set.
1037
1038 See also @ref{Outline Mode} for another way to hide part of
1039 the text in a buffer.
1040
1041 @node Optional Mode Line
1042 @section Optional Mode Line Features
1043
1044 @cindex buffer size display
1045 @cindex display of buffer size
1046 @findex size-indication-mode
1047 The buffer percentage @var{pos} indicates the percentage of the
1048 buffer above the top of the window. You can additionally display the
1049 size of the buffer by typing @kbd{M-x size-indication-mode} to turn on
1050 Size Indication mode. The size will be displayed immediately
1051 following the buffer percentage like this:
1052
1053 @example
1054 @var{POS} of @var{SIZE}
1055 @end example
1056
1057 @noindent
1058 Here @var{SIZE} is the human readable representation of the number of
1059 characters in the buffer, which means that @samp{k} for 10^3, @samp{M}
1060 for 10^6, @samp{G} for 10^9, etc., are used to abbreviate.
1061
1062 @cindex line number display
1063 @cindex display of line number
1064 @findex line-number-mode
1065 The current line number of point appears in the mode line when Line
1066 Number mode is enabled. Use the command @kbd{M-x line-number-mode} to
1067 turn this mode on and off; normally it is on. The line number appears
1068 after the buffer percentage @var{pos}, with the letter @samp{L} to
1069 indicate what it is.
1070
1071 @cindex Column Number mode
1072 @cindex mode, Column Number
1073 @findex column-number-mode
1074 Similarly, you can display the current column number by turning on
1075 Column number mode with @kbd{M-x column-number-mode}. The column
1076 number is indicated by the letter @samp{C}. However, when both of
1077 these modes are enabled, the line and column numbers are displayed in
1078 parentheses, the line number first, rather than with @samp{L} and
1079 @samp{C}. For example: @samp{(561,2)}. @xref{Minor Modes}, for more
1080 information about minor modes and about how to use these commands.
1081
1082 @cindex narrowing, and line number display
1083 If you have narrowed the buffer (@pxref{Narrowing}), the displayed
1084 line number is relative to the accessible portion of the buffer.
1085 Thus, it isn't suitable as an argument to @code{goto-line}. (Use
1086 @code{what-line} command to see the line number relative to the whole
1087 file.)
1088
1089 @vindex line-number-display-limit
1090 If the buffer is very large (larger than the value of
1091 @code{line-number-display-limit}), Emacs won't compute the line
1092 number, because that would be too slow; therefore, the line number
1093 won't appear on the mode-line. To remove this limit, set
1094 @code{line-number-display-limit} to @code{nil}.
1095
1096 @vindex line-number-display-limit-width
1097 Line-number computation can also be slow if the lines in the buffer
1098 are too long. For this reason, Emacs doesn't display line numbers if
1099 the average width, in characters, of lines near point is larger than
1100 the value of @code{line-number-display-limit-width}. The default
1101 value is 200 characters.
1102
1103 @findex display-time
1104 @cindex time (on mode line)
1105 Emacs can optionally display the time and system load in all mode
1106 lines. To enable this feature, type @kbd{M-x display-time} or customize
1107 the option @code{display-time-mode}. The information added to the mode
1108 line looks like this:
1109
1110 @example
1111 @var{hh}:@var{mm}pm @var{l.ll}
1112 @end example
1113
1114 @noindent
1115 @vindex display-time-24hr-format
1116 Here @var{hh} and @var{mm} are the hour and minute, followed always by
1117 @samp{am} or @samp{pm}. @var{l.ll} is the average number, collected
1118 for the last few minutes, of processes in the whole system that were
1119 either running or ready to run (i.e.@: were waiting for an available
1120 processor). (Some fields may be missing if your operating system
1121 cannot support them.) If you prefer time display in 24-hour format,
1122 set the variable @code{display-time-24hr-format} to @code{t}.
1123
1124 @cindex mail (on mode line)
1125 @vindex display-time-use-mail-icon
1126 @vindex display-time-mail-face
1127 @vindex display-time-mail-file
1128 @vindex display-time-mail-directory
1129 The word @samp{Mail} appears after the load level if there is mail
1130 for you that you have not read yet. On a graphical display you can use
1131 an icon instead of @samp{Mail} by customizing
1132 @code{display-time-use-mail-icon}; this may save some space on the mode
1133 line. You can customize @code{display-time-mail-face} to make the mail
1134 indicator prominent. Use @code{display-time-mail-file} to specify
1135 the mail file to check, or set @code{display-time-mail-directory}
1136 to specify the directory to check for incoming mail (any nonempty regular
1137 file in the directory is considered as ``newly arrived mail'').
1138
1139 @cindex mail (on mode line)
1140 @findex display-battery-mode
1141 @vindex display-battery-mode
1142 @vindex battery-mode-line-format
1143 When running Emacs on a laptop computer, you can display the battery
1144 charge on the mode-line, by using the command
1145 @code{display-battery-mode} or customizing the variable
1146 @code{display-battery-mode}. The variable
1147 @code{battery-mode-line-format} determines the way the battery charge
1148 is displayed; the exact mode-line message depends on the operating
1149 system, and it usually shows the current battery charge as a
1150 percentage of the total charge.
1151
1152 @cindex mode line, 3D appearance
1153 @cindex attributes of mode line, changing
1154 @cindex non-integral number of lines in a window
1155 On a graphical display, the mode line is drawn as a 3D box. If you
1156 don't like this effect, you can disable it by customizing the
1157 @code{mode-line} face and setting its @code{box} attribute to
1158 @code{nil}. @xref{Face Customization}.
1159
1160 @cindex non-selected windows, mode line appearance
1161 By default, the mode line of nonselected windows is displayed in a
1162 different face, called @code{mode-line-inactive}. Only the selected
1163 window is displayed in the @code{mode-line} face. This helps show
1164 which window is selected. When the minibuffer is selected, since
1165 it has no mode line, the window from which you activated the minibuffer
1166 has its mode line displayed using @code{mode-line}; as a result,
1167 ordinary entry to the minibuffer does not change any mode lines.
1168
1169 @vindex mode-line-in-non-selected-windows
1170 You can disable use of @code{mode-line-inactive} by setting variable
1171 @code{mode-line-in-non-selected-windows} to @code{nil}; then all mode
1172 lines are displayed in the @code{mode-line} face.
1173
1174 @vindex eol-mnemonic-unix
1175 @vindex eol-mnemonic-dos
1176 @vindex eol-mnemonic-mac
1177 @vindex eol-mnemonic-undecided
1178 You can customize the mode line display for each of the end-of-line
1179 formats by setting each of the variables @code{eol-mnemonic-unix},
1180 @code{eol-mnemonic-dos}, @code{eol-mnemonic-mac}, and
1181 @code{eol-mnemonic-undecided} to the strings you prefer.
1182
1183 @node Text Display
1184 @section How Text Is Displayed
1185 @cindex characters (in text)
1186 @cindex printing character
1187
1188 Most characters are @dfn{printing characters}: when they appear in a
1189 buffer, they are displayed literally on the screen. Printing
1190 characters include @acronym{ASCII} numbers, letters, and punctuation
1191 characters, as well as many non-@acronym{ASCII} characters.
1192
1193 @vindex tab-width
1194 @cindex control character
1195 The @acronym{ASCII} character set contains non-printing @dfn{control
1196 characters}. Two of these are displayed specially: the newline
1197 character (Unicode code point @code{U+000A}) is displayed by starting
1198 a new line, while the tab character (@code{U+0009}) is displayed as a
1199 space that extends to the next tab stop column (normally every 8
1200 columns). The number of spaces per tab is controlled by the
1201 buffer-local variable @code{tab-width}, which must have an integer
1202 value between 1 and 1000, inclusive. Note that how the tab character
1203 in the buffer is displayed has nothing to do with the definition of
1204 @key{TAB} as a command.
1205
1206 Other @acronym{ASCII} control characters are displayed as a caret
1207 (@samp{^}) followed by the non-control version of the character, with
1208 the @code{escape-glyph} face. For instance, the @samp{control-A}
1209 character, @code{U+0001}, is displayed as @samp{^A}.
1210
1211 @vindex ctl-arrow
1212 The non-@acronym{ASCII}, non-printing characters @code{U+0080}
1213 (octal 200) through @code{U+009F} (octal 237) are displayed as octal
1214 escape sequences, with the @code{escape-glyph} face. For instance,
1215 character code @code{U+0098} (octal 230) is displayed as @samp{\230}.
1216 If you change the buffer-local variable @code{ctl-arrow} to
1217 @code{nil}, @acronym{ASCII} control characters are also displayed as
1218 octal escape sequences instead of caret escape sequences.
1219
1220 @vindex nobreak-char-display
1221 @cindex non-breaking space, display
1222 @cindex non-breaking hyphen, display
1223 @cindex soft hyphen, display
1224 There are two special ``non-breaking'' versions of the space and
1225 hyphen characters, which are used where a line should not be broken.
1226 Emacs normally displays these characters with special faces
1227 (respectively, @code{nobreak-space} and @code{escape-glyph}) to
1228 distinguish them from ordinary spaces and hyphens. You can turn off
1229 this feature by setting the variable @code{nobreak-char-display} to
1230 @code{nil}. If you set the variable to any other value, that means to
1231 prefix these characters with an escape character.
1232
1233 You can customize the way any particular character code is displayed
1234 by means of a display table. @xref{Display Tables,, Display Tables,
1235 elisp, The Emacs Lisp Reference Manual}.
1236
1237 @cindex glyphless characters
1238 @cindex characters with no font glyphs
1239 On graphical displays, some characters may have no glyphs in any of
1240 the fonts available to Emacs. These @dfn{glyphless characters} are
1241 normally displayed as boxes containing the hexadecimal character code.
1242 You can control the display method by customizing the variable
1243 @code{glyphless-char-display-control}. @xref{Glyphless Chars,,
1244 Glyphless Character Display, elisp, The Emacs Lisp Reference Manual},
1245 for details.
1246
1247 @node Cursor Display
1248 @section Displaying the Cursor
1249
1250 @findex blink-cursor-mode
1251 @vindex blink-cursor-alist
1252 @cindex cursor, locating visually
1253 @cindex cursor, blinking
1254 You can customize the cursor's color, and whether it blinks, using
1255 the @code{cursor} Custom group (@pxref{Easy Customization}). On
1256 a graphical display, the command @kbd{M-x blink-cursor-mode} enables
1257 or disables the blinking of the cursor. (On text terminals, the
1258 terminal itself blinks the cursor, and Emacs has no control over it.)
1259 You can control how the cursor appears when it blinks off by setting
1260 the variable @code{blink-cursor-alist}.
1261
1262 @vindex cursor-type
1263 You can change the shape of the cursor from the default ``box'' look
1264 to a bar by altering the @code{cursor-type} variable.
1265
1266 @vindex visible-cursor
1267 Some text terminals offer two different cursors: the normal cursor
1268 and the very visible cursor, where the latter may be e.g. bigger or
1269 blinking. By default Emacs uses the very visible cursor, and switches
1270 to it when you start or resume Emacs. If the variable
1271 @code{visible-cursor} is @code{nil} when Emacs starts or resumes, it
1272 doesn't switch, so it uses the normal cursor.
1273
1274 @cindex cursor in non-selected windows
1275 @vindex cursor-in-non-selected-windows
1276 Normally, the cursor appears in non-selected windows without
1277 blinking, with the same appearance as when the blinking cursor blinks
1278 ``off.'' For a box cursor, this is a hollow box; for a bar cursor,
1279 this is a thinner bar. To turn off cursors in non-selected windows,
1280 customize the variable @code{cursor-in-non-selected-windows} and
1281 assign it a @code{nil} value.
1282
1283 @vindex x-stretch-cursor
1284 @cindex wide block cursor
1285 On graphical displays, Emacs can optionally draw the block cursor
1286 as wide as the character under the cursor---for example, if the cursor
1287 is on a tab character, it would cover the full width occupied by that
1288 tab character. To enable this feature, set the variable
1289 @code{x-stretch-cursor} to a non-@code{nil} value.
1290
1291 @findex hl-line-mode
1292 @findex global-hl-line-mode
1293 @cindex highlight current line
1294 To make the cursor even more visible, you can use HL Line mode, a
1295 minor mode that highlights the line containing point. Use @kbd{M-x
1296 hl-line-mode} to enable or disable it in the current buffer. @kbd{M-x
1297 global-hl-line-mode} enables or disables the same mode globally.
1298
1299 @node Line Truncation
1300 @section Truncation of Lines
1301
1302 @cindex truncation
1303 @cindex line truncation, and fringes
1304 As an alternative to continuation (@pxref{Continuation Lines}), Emacs
1305 can display long lines by @dfn{truncation}. This means that all the
1306 characters that do not fit in the width of the screen or window do not
1307 appear at all. On graphical displays, a small straight arrow in the
1308 fringe indicates truncation at either end of the line. On text-only
1309 terminals, @samp{$} appears in the leftmost column when there is text
1310 truncated to the left, and in the rightmost column when there is text
1311 truncated to the right.
1312
1313 @vindex truncate-lines
1314 @findex toggle-truncate-lines
1315 Horizontal scrolling automatically causes line truncation
1316 (@pxref{Horizontal Scrolling}). You can explicitly enable line
1317 truncation for a particular buffer with the command @kbd{M-x
1318 toggle-truncate-lines}. This works by locally changing the variable
1319 @code{truncate-lines}. If that variable is non-@code{nil}, long lines
1320 are truncated; if it is @code{nil}, they are continued onto multiple
1321 screen lines. Setting the variable @code{truncate-lines} in any way
1322 makes it local to the current buffer; until that time, the default
1323 value is in effect. The default value is normally @code{nil}.
1324
1325 @c @vindex truncate-partial-width-windows @c Idx entry is in Split Windows.
1326 If the variable @code{truncate-partial-width-windows} is
1327 non-@code{nil}, it forces truncation rather than continuation in any
1328 window less than the full width of the screen or frame, regardless of
1329 the value of @code{truncate-lines}. See also @ref{Display,, Display,
1330 elisp, The Emacs Lisp Reference Manual}.
1331
1332 @vindex overflow-newline-into-fringe
1333 If the variable @code{overflow-newline-into-fringe} is
1334 non-@code{nil} on a graphical display, then Emacs does not continue or
1335 truncate a line which is exactly as wide as the window. Instead, the
1336 newline overflows into the right fringe, and the cursor appears in the
1337 fringe when positioned on that newline.
1338
1339 @node Visual Line Mode
1340 @section Visual Line Mode
1341
1342 @cindex word wrap
1343 Another alternative to ordinary line continuation is to use
1344 @dfn{word wrap}. Here, each long logical line is divided into two or
1345 more screen lines, like in ordinary line continuation. However, Emacs
1346 attempts to wrap the line at word boundaries near the right window
1347 edge. This makes the text easier to read, as wrapping does not occur
1348 in the middle of words.
1349
1350 @cindex Visual Line mode
1351 @findex visual-line-mode
1352 @findex global-visual-line-mode
1353 Word wrap is enabled by Visual Line mode, an optional minor mode.
1354 To turn on Visual Line mode in the current buffer, type @kbd{M-x
1355 visual-line-mode}; repeating this command turns it off. You can also
1356 turn on Visual Line mode using the menu bar: in the Options menu,
1357 select the @samp{Line Wrapping in this Buffer} submenu, followed by
1358 the @samp{Word Wrap (Visual Line Mode)} menu item. While Visual Line
1359 mode is enabled, the mode-line shows the string @samp{wrap} in the
1360 mode display. The command @kbd{M-x global-visual-line-mode} toggles
1361 Visual Line mode in all buffers.
1362
1363 @findex beginning-of-visual-line
1364 @findex end-of-visual-line
1365 @findex next-logical-line
1366 @findex previous-logical-line
1367 In Visual Line mode, some editing commands work on screen lines
1368 instead of logical lines: @kbd{C-a} (@code{beginning-of-visual-line})
1369 moves to the beginning of the screen line, @kbd{C-e}
1370 (@code{end-of-visual-line}) moves to the end of the screen line, and
1371 @kbd{C-k} (@code{kill-visual-line}) kills text to the end of the
1372 screen line.
1373
1374 To move by logical lines, use the commands @kbd{M-x
1375 next-logical-line} and @kbd{M-x previous-logical-line}. These move
1376 point to the next logical line and the previous logical line
1377 respectively, regardless of whether Visual Line mode is enabled. If
1378 you use these commands frequently, it may be convenient to assign key
1379 bindings to them. @xref{Init Rebinding}.
1380
1381 By default, word-wrapped lines do not display fringe indicators.
1382 Visual Line mode is often used to edit files that contain many long
1383 logical lines, so having a fringe indicator for each wrapped line
1384 would be visually distracting. You can change this by customizing the
1385 variable @code{visual-line-fringe-indicators}.
1386
1387 @node Display Custom
1388 @section Customization of Display
1389
1390 This section describes variables (@pxref{Variables}) that you can
1391 change to customize how Emacs displays. Beginning users can skip
1392 it.
1393 @c the reason for that pxref is because an xref early in the
1394 @c ``echo area'' section leads here.
1395
1396 @vindex visible-bell
1397 If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts
1398 to make the whole screen blink when it would normally make an audible bell
1399 sound. This variable has no effect if your terminal does not have a way
1400 to make the screen blink.
1401
1402 @vindex echo-keystrokes
1403 The variable @code{echo-keystrokes} controls the echoing of multi-character
1404 keys; its value is the number of seconds of pause required to cause echoing
1405 to start, or zero, meaning don't echo at all. The value takes effect when
1406 there is someting to echo. @xref{Echo Area}.
1407
1408 @vindex baud-rate
1409 The variable @anchor{baud-rate}@code{baud-rate} holds the output
1410 speed of the terminal. Setting this variable does not change the
1411 speed of actual data transmission, but the value is used for
1412 calculations. On text-only terminals, it affects padding, and
1413 decisions about whether to scroll part of the screen or redraw it
1414 instead. It also affects the behavior of incremental search. On
1415 graphical displays, @code{baud-rate} is only used to determine how
1416 frequently to look for pending input during display updating. A
1417 higher value of @code{baud-rate} means that check for pending input
1418 will be done less frequently.
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.
1461
1462 @vindex no-redraw-on-reenter
1463 On a text-only terminal, when you reenter Emacs after suspending, Emacs
1464 normally clears the screen and redraws the entire display. On some
1465 terminals with more than one page of memory, it is possible to arrange
1466 the termcap entry so that the @samp{ti} and @samp{te} strings (output
1467 to the terminal when Emacs is entered and exited, respectively) switch
1468 between pages of memory so as to use one page for Emacs and another
1469 page for other output. On such terminals, you might want to set the variable
1470 @code{no-redraw-on-reenter} non-@code{nil}; this tells Emacs to
1471 assume, when resumed, that the screen page it is using still contains
1472 what Emacs last wrote there.