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