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