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