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