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