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