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