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