Commit | Line | Data |
---|---|---|
802b0ea7 | 1 | @c This is part of the Emacs manual. |
b8f3a9e3 GM |
2 | @c Copyright (C) 1985, 86, 87, 93, 94, 95, 1997, 2000, 2001 |
3 | @c Free Software Foundation, Inc. | |
6bf7aab6 DL |
4 | @c See file emacs.texi for copying conditions. |
5 | @node Display, Search, Registers, Top | |
6 | @chapter Controlling the Display | |
7 | ||
8 | Since only part of a large buffer fits in the window, Emacs tries to | |
9 | show a part that is likely to be interesting. Display-control commands | |
10 | allow you to specify which part of the text you want to see, and how to | |
11 | display it. | |
12 | ||
13 | @menu | |
b8f3a9e3 GM |
14 | * Faces:: How to change the display style using faces. |
15 | * Font Lock:: Minor mode for syntactic highlighting using faces. | |
16 | * Highlight Changes:: Using colors to show where you changed the buffer. | |
17 | * Highlight Interactively:: Tell Emacs what text to highlight. | |
18 | * Trailing Whitespace:: Showing possibly-spurious trailing whitespace. | |
6bf7aab6 DL |
19 | * Scrolling:: Moving text up and down in a window. |
20 | * Horizontal Scrolling:: Moving text left and right in a window. | |
21 | * Follow Mode:: Follow mode lets two windows scroll as one. | |
22 | * Selective Display:: Hiding lines with lots of indentation. | |
23 | * Optional Mode Line:: Optional mode line display features. | |
24 | * Text Display:: How text characters are normally displayed. | |
e598186c | 25 | * Display Custom:: Information on variables for customizing display. |
099bfef9 | 26 | * Cursor Display:: Features for displaying the cursor. |
6bf7aab6 DL |
27 | @end menu |
28 | ||
b8f3a9e3 GM |
29 | @node Faces |
30 | @section Using Multiple Typefaces | |
31 | @cindex faces | |
32 | ||
33 | When using Emacs with a window system, you can set up multiple | |
34 | styles of displaying characters. Some of the aspects of style that | |
35 | you can control are the type font, the foreground color, the | |
36 | background color, and whether or not to underline text, and in which | |
37 | color. | |
38 | ||
6bb2ed9b EZ |
39 | Features which rely on text in multiple faces (such as Font Lock mode) |
40 | will also work on non-windowed terminals that can display more than one | |
41 | face, whether by colors or underlining and emboldening. This includes | |
42 | the console on GNU/Linux, an @code{xterm} which supports colors, the | |
43 | MS-DOS display (@pxref{MS-DOS}), and the MS-Windows version invoked with | |
44 | the @option{-nw} option. Emacs determines automatically whether the | |
45 | terminal has this capability. | |
b8f3a9e3 GM |
46 | |
47 | The way you control display style is by defining named @dfn{faces}. | |
48 | Each face can specify various attributes, like the type font's height, | |
49 | weight and slant, foreground and background color, and underlining, | |
50 | but it does not have to specify all of them. By specifying the face | |
51 | or faces to use for a given part of the text in the buffer, you | |
52 | control how that text appears. | |
53 | ||
54 | The style of display used for a given character in the text is | |
55 | determined by combining several faces. Any aspect of the display | |
56 | style that isn't specified by overlays or text properties comes from a | |
57 | default face which inherits its settings from the frame itself. | |
58 | ||
59 | Enriched mode, the mode for editing formatted text, includes several | |
60 | commands and menus for specifying faces. @xref{Format Faces}, for how | |
61 | to specify the font for text in the buffer. @xref{Format Colors}, for | |
62 | how to specify the foreground and background color. | |
63 | ||
64 | To alter the appearance of a face, use the customization buffer. | |
65 | @xref{Face Customization}. You can also use X resources to specify | |
66 | attributes of particular faces (@pxref{Resources X}). | |
67 | ||
68 | @cindex face colors, setting | |
69 | @findex set-face-foreground | |
70 | @findex set-face-background | |
71 | Alternatively, you can change the foreground and background colors | |
72 | of a specific face with @kbd{M-x set-face-foreground} and @kbd{M-x | |
73 | set-face-background}. These commands prompt in the minibuffer for a | |
74 | face name and a color name, with completion, and then set that face to | |
75 | use the specified color. | |
76 | ||
77 | @findex list-faces-display | |
78 | To see what faces are currently defined, and what they look like, type | |
79 | @kbd{M-x list-faces-display}. It's possible for a given face to look | |
80 | different in different frames; this command shows the appearance in the | |
81 | frame in which you type it. Here's a list of the standardly defined | |
82 | faces: | |
83 | ||
84 | @table @code | |
85 | @item default | |
86 | This face is used for ordinary text that doesn't specify any other face. | |
87 | @item mode-line | |
88 | This face is used for mode lines. By default, it's drawn with shadows | |
89 | for a ``raised'' effect on window systems, and drawn as the inverse of | |
90 | the default face on non-windowed terminals. @xref{Display Custom}. | |
91 | @item header-line | |
92 | Similar to @code{mode-line} for a window's header line. Most modes | |
93 | don't use the header line, but the Info mode does. | |
94 | @item highlight | |
95 | This face is used for highlighting portions of text, in various modes. | |
96 | For example, mouse-sensitive text is highlighted using this face. | |
97 | @item isearch | |
98 | This face is used for highlighting Isearch matches. | |
99 | @item isearch-lazy-highlight-face | |
100 | This face is used for lazy highlighting of Isearch matches other than | |
101 | the current one. | |
102 | @item region | |
103 | This face is used for displaying a selected region (when Transient Mark | |
104 | mode is enabled---see below). | |
105 | @item secondary-selection | |
106 | This face is used for displaying a secondary X selection (@pxref{Secondary | |
107 | Selection}). | |
108 | @item bold | |
109 | This face uses a bold variant of the default font, if it has one. | |
110 | @item italic | |
111 | This face uses an italic variant of the default font, if it has one. | |
112 | @item bold-italic | |
113 | This face uses a bold italic variant of the default font, if it has one. | |
114 | @item underline | |
115 | This face underlines text. | |
116 | @item fixed-pitch | |
117 | The basic fixed-pitch face. | |
118 | @item fringe | |
119 | @cindex fringe | |
120 | The face for the fringes to the left and right of windows on graphic | |
121 | displays. (The fringes are the narrow portions of the Emacs frame | |
122 | between the text area and the frame's border.) | |
123 | @item scroll-bar | |
124 | This face determines the visual appearance of the scroll bar. | |
125 | @item border | |
126 | This face determines the color of the frame border. | |
127 | @item cursor | |
128 | This face determines the color of the cursor. | |
129 | @item mouse | |
130 | This face determines the color of the mouse pointer. | |
131 | @item tool-bar | |
132 | This is the basic tool-bar face. No text appears in the tool bar, but the | |
133 | colors of this face affect the appearance of tool bar icons. | |
134 | @item tooltip | |
135 | This face is used for tooltips. | |
136 | @item menu | |
137 | This face determines the colors and font of Emacs's menus. Setting the | |
138 | font of LessTif/Motif menus is currently not supported; attempts to set | |
139 | the font are ignored in this case. | |
140 | @item trailing-whitespace | |
141 | The face for highlighting trailing whitespace when | |
142 | @code{show-trailing-whitespace} is non-nil. | |
143 | @item variable-pitch | |
144 | The basic variable-pitch face. | |
145 | @end table | |
146 | ||
147 | @cindex @code{region} face | |
148 | When Transient Mark mode is enabled, the text of the region is | |
149 | highlighted when the mark is active. This uses the face named | |
150 | @code{region}; you can control the style of highlighting by changing the | |
151 | style of this face (@pxref{Face Customization}). @xref{Transient Mark}, | |
152 | for more information about Transient Mark mode and activation and | |
153 | deactivation of the mark. | |
154 | ||
155 | One easy way to use faces is to turn on Font Lock mode. This minor | |
156 | mode, which is always local to a particular buffer, arranges to | |
157 | choose faces according to the syntax of the text you are editing. It | |
158 | can recognize comments and strings in most languages; in several | |
159 | languages, it can also recognize and properly highlight various other | |
160 | important constructs. @xref{Font Lock}, for more information about | |
161 | Font Lock mode and syntactic highlighting. | |
162 | ||
163 | You can print out the buffer with the highlighting that appears | |
164 | on your screen using the command @code{ps-print-buffer-with-faces}. | |
165 | @xref{PostScript}. | |
166 | ||
167 | @node Font Lock | |
168 | @section Font Lock mode | |
169 | @cindex Font Lock mode | |
170 | @cindex mode, Font Lock | |
171 | @cindex syntax highlighting and coloring | |
172 | ||
173 | Font Lock mode is a minor mode, always local to a particular | |
174 | buffer, which highlights (or ``fontifies'') using various faces | |
175 | according to the syntax of the text you are editing. It can | |
176 | recognize comments and strings in most languages; in several | |
177 | languages, it can also recognize and properly highlight various other | |
178 | important constructs---for example, names of functions being defined | |
179 | or reserved keywords. | |
180 | ||
181 | @findex font-lock-mode | |
182 | @findex turn-on-font-lock | |
183 | The command @kbd{M-x font-lock-mode} turns Font Lock mode on or off | |
184 | according to the argument, and toggles the mode when it has no argument. | |
185 | The function @code{turn-on-font-lock} unconditionally enables Font Lock | |
186 | mode. This is useful in mode-hook functions. For example, to enable | |
187 | Font Lock mode whenever you edit a C file, you can do this: | |
188 | ||
189 | @example | |
190 | (add-hook 'c-mode-hook 'turn-on-font-lock) | |
191 | @end example | |
192 | ||
193 | @findex global-font-lock-mode | |
194 | @vindex global-font-lock-mode | |
195 | To turn on Font Lock mode automatically in all modes which support | |
196 | it, customize the user option @code{global-font-lock-mode} or use the | |
197 | function @code{global-font-lock-mode} in your @file{.emacs} file, like | |
198 | this: | |
199 | ||
200 | @example | |
201 | (global-font-lock-mode 1) | |
202 | @end example | |
203 | ||
204 | Font Lock mode uses several specifically named faces to do its job, | |
205 | including @code{font-lock-string-face}, @code{font-lock-comment-face}, | |
206 | and others. The easiest way to find them all is to use completion | |
207 | on the face name in @code{set-face-foreground}. | |
208 | ||
209 | To change the colors or the fonts used by Font Lock mode to fontify | |
210 | different parts of text, just change these faces. There are | |
211 | two ways to do it: | |
212 | ||
213 | @itemize @bullet | |
214 | @item | |
215 | Invoke @kbd{M-x set-face-foreground} or @kbd{M-x set-face-background} | |
216 | to change the colors of a particular face used by Font Lock. | |
217 | @xref{Faces}. The command @kbd{M-x list-faces-display} displays all | |
218 | the faces currently known to Emacs, including those used by Font Lock. | |
219 | ||
220 | @item | |
221 | Customize the faces interactively with @kbd{M-x customize-face}, as | |
222 | described in @ref{Face Customization}. | |
223 | @end itemize | |
224 | ||
225 | To get the full benefit of Font Lock mode, you need to choose a | |
226 | default font which has bold, italic, and bold-italic variants; or else | |
227 | you need to have a color or gray-scale screen. | |
228 | ||
229 | @vindex font-lock-maximum-decoration | |
230 | The variable @code{font-lock-maximum-decoration} specifies the | |
231 | preferred level of fontification, for modes that provide multiple | |
232 | levels. Level 1 is the least amount of fontification; some modes | |
233 | support levels as high as 3. The normal default is ``as high as | |
234 | possible.'' You can specify an integer, which applies to all modes, or | |
235 | you can specify different numbers for particular major modes; for | |
236 | example, to use level 1 for C/C++ modes, and the default level | |
237 | otherwise, use this: | |
238 | ||
239 | @example | |
240 | (setq font-lock-maximum-decoration | |
241 | '((c-mode . 1) (c++-mode . 1))) | |
242 | @end example | |
243 | ||
244 | @vindex font-lock-maximum-size | |
245 | Fontification can be too slow for large buffers, so you can suppress | |
246 | it. The variable @code{font-lock-maximum-size} specifies a buffer size, | |
247 | beyond which buffer fontification is suppressed. | |
248 | ||
249 | @c @w is used below to prevent a bad page-break. | |
250 | @vindex font-lock-beginning-of-syntax-function | |
251 | Comment and string fontification (or ``syntactic'' fontification) | |
252 | relies on analysis of the syntactic structure of the buffer text. For | |
253 | the purposes of speed, some modes including C mode and Lisp mode rely on | |
254 | a special convention: an open-parenthesis in the leftmost column always | |
255 | defines the @w{beginning} of a defun, and is thus always outside any string | |
256 | or comment. (@xref{Defuns}.) If you don't follow this convention, | |
257 | then Font Lock mode can misfontify the text after an open-parenthesis in | |
258 | the leftmost column that is inside a string or comment. | |
259 | ||
6bb2ed9b | 260 | @cindex slow display during scrolling |
b8f3a9e3 GM |
261 | The variable @code{font-lock-beginning-of-syntax-function} (always |
262 | buffer-local) specifies how Font Lock mode can find a position | |
263 | guaranteed to be outside any comment or string. In modes which use the | |
264 | leftmost column parenthesis convention, the default value of the variable | |
265 | is @code{beginning-of-defun}---that tells Font Lock mode to use the | |
266 | convention. If you set this variable to @code{nil}, Font Lock no longer | |
267 | relies on the convention. This avoids incorrect results, but the price | |
268 | is that, in some cases, fontification for a changed text must rescan | |
6bb2ed9b EZ |
269 | buffer text from the beginning of the buffer. This can considerably |
270 | slow down redisplay while scrolling, particularly if you are close to | |
271 | the end of a large buffer. | |
b8f3a9e3 GM |
272 | |
273 | @findex font-lock-add-keywords | |
274 | Font Lock highlighting patterns already exist for many modes, but you | |
275 | may want to fontify additional patterns. You can use the function | |
276 | @code{font-lock-add-keywords}, to add your own highlighting patterns for | |
277 | a particular mode. For example, to highlight @samp{FIXME:} words in C | |
278 | comments, use this: | |
279 | ||
280 | @example | |
281 | (font-lock-add-keywords | |
282 | 'c-mode | |
283 | '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t))) | |
284 | @end example | |
285 | ||
286 | @node Highlight Changes | |
287 | @section Highlight Changes Mode | |
288 | ||
289 | @findex highlight-changes-mode | |
290 | Use @kbd{M-x highlight-changes-mode} to enable a minor mode | |
291 | that uses faces (colors, typically) to indicate which parts of | |
292 | the buffer were changed most recently. | |
293 | ||
294 | @node Highlight Interactively | |
295 | @section Interactive Highlighting by Matching | |
296 | @cindex highlighting by matching | |
297 | @cindex interactive highlighting | |
298 | ||
299 | It is sometimes useful to highlight the strings that match a certain | |
300 | regular expression. For example, you might wish to see all the | |
301 | references to a certain variable in a program source file, or highlight | |
302 | certain parts in a voluminous output of some program, or make certain | |
303 | cliches stand out in an article. | |
304 | ||
305 | @findex hi-lock-mode | |
306 | Use the @kbd{M-x hi-lock-mode} command to turn on a minor mode that | |
307 | allows you to specify regular expressions of the text to be | |
308 | highlighted. Hi-lock mode works like Font Lock (@pxref{Font Lock}), | |
309 | except that it lets you specify explicitly what parts of text to | |
310 | highlight. You control Hi-lock mode with these commands: | |
311 | ||
312 | @table @kbd | |
313 | @item C-x w h @var{regexp} @key{RET} @var{face} @key{RET} | |
314 | @kindex C-x w h | |
315 | @findex highlight-regexp | |
316 | Highlight text that matches | |
317 | @var{regexp} using face @var{face} (@code{highlight-regexp}). | |
318 | By using this command more than once, you can highlight various | |
319 | parts of the text in different ways. | |
320 | ||
321 | @item C-x w r @var{regexp} @key{RET} | |
322 | @kindex C-x w r | |
323 | @findex unhighlight-regexp | |
324 | Unhighlight @var{regexp} (@code{unhighlight-regexp}). You must enter | |
325 | one of the regular expressions currently specified for highlighting. | |
326 | (You can use completion, or a menu, to enter one of them | |
327 | conveniently.) | |
328 | ||
329 | @item C-x w l @var{regexp} @key{RET} @var{face} @key{RET} | |
330 | @kindex C-x w l | |
331 | @findex highlight-lines-matching-regexp | |
332 | @cindex lines, highlighting | |
333 | @cindex highlighting lines of text | |
334 | Highlight lines containing a match for @var{regexp}, using face | |
335 | @var{face} (@code{highlight-lines-matching-regexp}). | |
336 | ||
337 | @item C-x w b | |
338 | @kindex C-x w b | |
339 | @findex hi-lock-write-interactive-patterns | |
340 | Insert all the current highlighting regexp/face pairs into the buffer | |
341 | at point, with comment delimiters to prevent them from changing your | |
342 | program. This key binding runs the | |
343 | @code{hi-lock-write-interactive-patterns} command. | |
344 | ||
345 | These patterns will be read the next time you visit the file while | |
346 | Hi-lock mode is enabled, or whenever you use the @kbd{M-x | |
347 | hi-lock-find-patterns} command. | |
348 | ||
349 | @item C-x w i | |
350 | @kindex C-x w i | |
351 | @findex hi-lock-find-patterns | |
352 | @vindex hi-lock-exclude-modes | |
353 | Re-read regexp/face pairs in the current buffer | |
354 | (@code{hi-lock-write-interactive-patterns}). The list of pairs is | |
355 | found no matter where in the buffer it may be. | |
356 | ||
357 | This command does nothing if the major mode is a member of the list | |
358 | @code{hi-lock-exclude-modes}. | |
359 | @end table | |
360 | ||
361 | @node Trailing Whitespace | |
362 | @section Trailing Whitespace | |
363 | ||
364 | @cindex trailing whitespace | |
365 | @cindex whitespace, trailing | |
366 | @vindex show-trailing-whitespace | |
367 | It is easy to leave unnecessary spaces at the end of a line without | |
368 | realizing it. In most cases, this @dfn{trailing whitespace} has no | |
369 | effect, but there are special circumstances where it matters. | |
370 | ||
371 | You can make trailing whitespace visible on the screen by setting | |
372 | the variable @code{show-trailing-whitespace} to @code{t}. Then Emacs | |
373 | displays trailing whitespace in the face @code{trailing-whitespace}. | |
374 | ||
375 | Trailing whitespace is defined as spaces or tabs at the end of a | |
376 | line. But trailing whitespace is not displayed specially if point is | |
377 | at the end of the line containing the whitespace. (Doing that looks | |
378 | ugly while you are typing in new text, and the location of point is | |
379 | enough in that case to show you that the spaces are present.) | |
380 | ||
381 | @vindex indicate-empty-lines | |
382 | @vindex default-indicate-empty-lines | |
383 | @cindex empty lines | |
384 | Emacs can indicate empty lines at the end of the buffer with a | |
385 | special bitmap on the left fringe of the window. To enable this | |
386 | feature, set the buffer-local variable @code{indicate-empty-lines} to | |
387 | a non-@code{nil} value. The default value of this variable is | |
388 | controlled by the variable @code{default-indicate-empty-lines}; | |
389 | by setting that variable, you can enable or disable this feature | |
390 | for all new buffers. | |
391 | ||
6bf7aab6 DL |
392 | @node Scrolling |
393 | @section Scrolling | |
394 | ||
395 | If a buffer contains text that is too large to fit entirely within a | |
396 | window that is displaying the buffer, Emacs shows a contiguous portion of | |
397 | the text. The portion shown always contains point. | |
398 | ||
399 | @cindex scrolling | |
400 | @dfn{Scrolling} means moving text up or down in the window so that | |
401 | different parts of the text are visible. Scrolling forward means that text | |
402 | moves up, and new text appears at the bottom. Scrolling backward moves | |
403 | text down and new text appears at the top. | |
404 | ||
405 | Scrolling happens automatically if you move point past the bottom or top | |
406 | of the window. You can also explicitly request scrolling with the commands | |
407 | in this section. | |
408 | ||
409 | @table @kbd | |
410 | @item C-l | |
411 | Clear screen and redisplay, scrolling the selected window to center | |
412 | point vertically within it (@code{recenter}). | |
413 | @item C-v | |
414 | Scroll forward (a windowful or a specified number of lines) (@code{scroll-up}). | |
415 | @item @key{NEXT} | |
416 | Likewise, scroll forward. | |
417 | @item M-v | |
418 | Scroll backward (@code{scroll-down}). | |
419 | @item @key{PRIOR} | |
420 | Likewise, scroll backward. | |
421 | @item @var{arg} C-l | |
422 | Scroll so point is on line @var{arg} (@code{recenter}). | |
423 | @item C-M-l | |
424 | Scroll heuristically to bring useful information onto the screen | |
425 | (@code{reposition-window}). | |
426 | @end table | |
427 | ||
428 | @kindex C-l | |
429 | @findex recenter | |
430 | The most basic scrolling command is @kbd{C-l} (@code{recenter}) with | |
431 | no argument. It clears the entire screen and redisplays all windows. | |
432 | In addition, it scrolls the selected window so that point is halfway | |
433 | down from the top of the window. | |
434 | ||
435 | @kindex C-v | |
436 | @kindex M-v | |
437 | @kindex NEXT | |
438 | @kindex PRIOR | |
439 | @findex scroll-up | |
440 | @findex scroll-down | |
441 | The scrolling commands @kbd{C-v} and @kbd{M-v} let you move all the text | |
442 | in the window up or down a few lines. @kbd{C-v} (@code{scroll-up}) with an | |
443 | argument shows you that many more lines at the bottom of the window, moving | |
444 | the text and point up together as @kbd{C-l} might. @kbd{C-v} with a | |
445 | negative argument shows you more lines at the top of the window. | |
446 | @kbd{M-v} (@code{scroll-down}) is like @kbd{C-v}, but moves in the | |
447 | opposite direction. The function keys @key{NEXT} and @key{PRIOR} are | |
448 | equivalent to @kbd{C-v} and @kbd{M-v}. | |
449 | ||
450 | The names of scroll commands are based on the direction that the text | |
451 | moves in the window. Thus, the command to scroll forward is called | |
452 | @code{scroll-up} because it moves the text upward on the screen. | |
453 | ||
454 | @vindex next-screen-context-lines | |
455 | To read the buffer a windowful at a time, use @kbd{C-v} with no argument. | |
456 | It takes the last two lines at the bottom of the window and puts them at | |
457 | the top, followed by nearly a whole windowful of lines not previously | |
458 | visible. If point was in the text scrolled off the top, it moves to the | |
459 | new top of the window. @kbd{M-v} with no argument moves backward with | |
460 | overlap similarly. The number of lines of overlap across a @kbd{C-v} or | |
461 | @kbd{M-v} is controlled by the variable @code{next-screen-context-lines}; by | |
462 | default, it is 2. | |
463 | ||
464 | @vindex scroll-preserve-screen-position | |
465 | Some users like the full-screen scroll commands to keep point at the | |
466 | same screen line. To enable this behavior, set the variable | |
467 | @code{scroll-preserve-screen-position} to a non-@code{nil} value. This | |
468 | mode is convenient for browsing through a file by scrolling by | |
469 | screenfuls; if you come back to the screen where you started, point goes | |
470 | back to the line where it started. However, this mode is inconvenient | |
471 | when you move to the next screen in order to move point to the text | |
472 | there. | |
473 | ||
474 | Another way to do scrolling is with @kbd{C-l} with a numeric argument. | |
475 | @kbd{C-l} does not clear the screen when given an argument; it only scrolls | |
476 | the selected window. With a positive argument @var{n}, it repositions text | |
477 | to put point @var{n} lines down from the top. An argument of zero puts | |
478 | point on the very top line. Point does not move with respect to the text; | |
479 | rather, the text and point move rigidly on the screen. @kbd{C-l} with a | |
480 | negative argument puts point that many lines from the bottom of the window. | |
481 | For example, @kbd{C-u - 1 C-l} puts point on the bottom line, and @kbd{C-u | |
482 | - 5 C-l} puts it five lines from the bottom. Just @kbd{C-u} as argument, | |
483 | as in @kbd{C-u C-l}, scrolls point to the center of the selected window. | |
484 | ||
485 | @kindex C-M-l | |
486 | @findex reposition-window | |
487 | The @kbd{C-M-l} command (@code{reposition-window}) scrolls the current | |
488 | window heuristically in a way designed to get useful information onto | |
489 | the screen. For example, in a Lisp file, this command tries to get the | |
490 | entire current defun onto the screen if possible. | |
491 | ||
492 | @vindex scroll-conservatively | |
493 | Scrolling happens automatically if point has moved out of the visible | |
494 | portion of the text when it is time to display. Normally, automatic | |
495 | scrolling centers point vertically within the window. However, if you | |
496 | set @code{scroll-conservatively} to a small number @var{n}, then if you | |
497 | move point just a little off the screen---less than @var{n} lines---then | |
498 | Emacs scrolls the text just far enough to bring point back on screen. | |
499 | By default, @code{scroll-conservatively} is 0. | |
500 | ||
6dd5e8cc EZ |
501 | @cindex aggressive scrolling |
502 | @vindex scroll-up-aggressively | |
503 | @vindex scroll-down-aggressively | |
e598186c RS |
504 | When the window does scroll by a longer distance, you can control |
505 | how aggressively it scrolls, by setting the variables | |
506 | @code{scroll-up-aggressively} and @code{scroll-down-aggressively}. | |
507 | The value of @code{scroll-up-aggressively} should be either | |
508 | @code{nil}, or a fraction @var{f} between 0 and 1. A fraction | |
509 | specifies where on the screen to put point when scrolling upward. | |
510 | More precisely, when a window scrolls up because point is above the | |
511 | window start, the new start position is chosen to put point @var{f} | |
512 | part of the window height from the top. The larger @var{f}, the more | |
513 | aggressive the scrolling. | |
514 | ||
515 | @code{nil}, which is the default, scrolls to put point at the center. | |
516 | So it is equivalent to .5. | |
517 | ||
518 | Likewise, @code{scroll-down-aggressively} is used for scrolling | |
519 | down. The value, @var{f}, specifies how far point should be placed | |
520 | from the bottom of the window; thus, as with | |
521 | @code{scroll-up-aggressively}, a larger value is more aggressive. | |
6dd5e8cc | 522 | |
6bf7aab6 DL |
523 | @vindex scroll-margin |
524 | The variable @code{scroll-margin} restricts how close point can come | |
525 | to the top or bottom of a window. Its value is a number of screen | |
526 | lines; if point comes within that many lines of the top or bottom of the | |
527 | window, Emacs recenters the window. By default, @code{scroll-margin} is | |
528 | 0. | |
529 | ||
530 | @node Horizontal Scrolling | |
531 | @section Horizontal Scrolling | |
532 | @cindex horizontal scrolling | |
533 | ||
534 | @dfn{Horizontal scrolling} means shifting all the lines sideways | |
e598186c RS |
535 | within a window---so that some of the text near the left margin is not |
536 | displayed at all. Emacs does this automatically, in any window that | |
537 | uses line truncation rather than continuation: whenever point moves | |
538 | off the left or right edge of the screen, Emacs scrolls the buffer | |
539 | horizontally to make point visible. | |
540 | ||
541 | When a window has been scrolled horizontally, text lines are truncated | |
542 | rather than continued (@pxref{Continuation Lines}), with a @samp{$} | |
543 | appearing in the first column when there is text truncated to the left, | |
544 | and in the last column when there is text truncated to the right. | |
545 | ||
546 | You can use these commands to do explicit horizontal scrolling. | |
6bf7aab6 DL |
547 | |
548 | @table @kbd | |
549 | @item C-x < | |
550 | Scroll text in current window to the left (@code{scroll-left}). | |
551 | @item C-x > | |
552 | Scroll to the right (@code{scroll-right}). | |
553 | @end table | |
554 | ||
6bf7aab6 DL |
555 | @kindex C-x < |
556 | @kindex C-x > | |
557 | @findex scroll-left | |
558 | @findex scroll-right | |
559 | The command @kbd{C-x <} (@code{scroll-left}) scrolls the selected | |
560 | window to the left by @var{n} columns with argument @var{n}. This moves | |
561 | part of the beginning of each line off the left edge of the window. | |
562 | With no argument, it scrolls by almost the full width of the window (two | |
563 | columns less, to be precise). | |
564 | ||
565 | @kbd{C-x >} (@code{scroll-right}) scrolls similarly to the right. The | |
566 | window cannot be scrolled any farther to the right once it is displayed | |
567 | normally (with each line starting at the window's left margin); | |
568 | attempting to do so has no effect. This means that you don't have to | |
569 | calculate the argument precisely for @w{@kbd{C-x >}}; any sufficiently large | |
570 | argument will restore the normal display. | |
571 | ||
e598186c RS |
572 | If you scroll a window horizontally by hand, that sets a lower bound |
573 | for automatic horizontal scrolling. Automatic scrolling will continue | |
574 | to scroll the window, but never further to the right than the amount | |
575 | you previously set by @code{scroll-left}. | |
6bf7aab6 | 576 | |
e598186c RS |
577 | @vindex automatic-hscrolling |
578 | To disable automatic horizontal scrolling, set the variable | |
579 | @code{automatic-hscrolling} to @code{nil}. | |
03ff8aab | 580 | |
6bf7aab6 DL |
581 | @node Follow Mode |
582 | @section Follow Mode | |
583 | @cindex Follow mode | |
584 | @cindex mode, Follow | |
fd3d3075 RS |
585 | @findex follow-mode |
586 | @cindex windows, synchronizing | |
587 | @cindex synchronizing windows | |
6bf7aab6 DL |
588 | |
589 | @dfn{Follow mode} is a minor mode that makes two windows showing the | |
590 | same buffer scroll as one tall ``virtual window.'' To use Follow mode, | |
591 | go to a frame with just one window, split it into two side-by-side | |
592 | windows using @kbd{C-x 3}, and then type @kbd{M-x follow-mode}. From | |
593 | then on, you can edit the buffer in either of the two windows, or scroll | |
594 | either one; the other window follows it. | |
595 | ||
8f399c9b RS |
596 | In Follow mode, if you move point outside the portion visible in one |
597 | window and into the portion visible in the other window, that selects | |
598 | the other window---again, treating the two as if they were parts of | |
599 | one large window. | |
600 | ||
6bf7aab6 DL |
601 | To turn off Follow mode, type @kbd{M-x follow-mode} a second time. |
602 | ||
603 | @node Selective Display | |
604 | @section Selective Display | |
4946337d | 605 | @cindex selective display |
6bf7aab6 DL |
606 | @findex set-selective-display |
607 | @kindex C-x $ | |
608 | ||
609 | Emacs has the ability to hide lines indented more than a certain number | |
610 | of columns (you specify how many columns). You can use this to get an | |
611 | overview of a part of a program. | |
612 | ||
613 | To hide lines, type @kbd{C-x $} (@code{set-selective-display}) with a | |
614 | numeric argument @var{n}. Then lines with at least @var{n} columns of | |
615 | indentation disappear from the screen. The only indication of their | |
616 | presence is that three dots (@samp{@dots{}}) appear at the end of each | |
617 | visible line that is followed by one or more hidden ones. | |
618 | ||
619 | The commands @kbd{C-n} and @kbd{C-p} move across the hidden lines as | |
620 | if they were not there. | |
621 | ||
622 | The hidden lines are still present in the buffer, and most editing | |
623 | commands see them as usual, so you may find point in the middle of the | |
624 | hidden text. When this happens, the cursor appears at the end of the | |
625 | previous line, after the three dots. If point is at the end of the | |
626 | visible line, before the newline that ends it, the cursor appears before | |
627 | the three dots. | |
628 | ||
629 | To make all lines visible again, type @kbd{C-x $} with no argument. | |
630 | ||
631 | @vindex selective-display-ellipses | |
632 | If you set the variable @code{selective-display-ellipses} to | |
633 | @code{nil}, the three dots do not appear at the end of a line that | |
634 | precedes hidden lines. Then there is no visible indication of the | |
635 | hidden lines. This variable becomes local automatically when set. | |
636 | ||
637 | @node Optional Mode Line | |
638 | @section Optional Mode Line Features | |
639 | ||
e598186c RS |
640 | @cindex line number display |
641 | @cindex display of line number | |
6bf7aab6 DL |
642 | @findex line-number-mode |
643 | The current line number of point appears in the mode line when Line | |
644 | Number mode is enabled. Use the command @kbd{M-x line-number-mode} to | |
645 | turn this mode on and off; normally it is on. The line number appears | |
646 | before the buffer percentage @var{pos}, with the letter @samp{L} to | |
647 | indicate what it is. @xref{Minor Modes}, for more information about | |
648 | minor modes and about how to use this command. | |
649 | ||
650 | @vindex line-number-display-limit | |
651 | If the buffer is very large (larger than the value of | |
652 | @code{line-number-display-limit}), then the line number doesn't appear. | |
653 | Emacs doesn't compute the line number when the buffer is large, because | |
14977fea DL |
654 | that would be too slow. Set it to @code{nil} to remove the limit. If |
655 | you have narrowed the buffer (@pxref{Narrowing}), the displayed line | |
656 | number is relative to the accessible portion of the buffer. | |
6bf7aab6 DL |
657 | |
658 | @cindex Column Number mode | |
659 | @cindex mode, Column Number | |
660 | @findex column-number-mode | |
661 | You can also display the current column number by turning on Column | |
662 | Number mode. It displays the current column number preceded by the | |
663 | letter @samp{C}. Type @kbd{M-x column-number-mode} to toggle this mode. | |
664 | ||
665 | @findex display-time | |
666 | @cindex time (on mode line) | |
667 | Emacs can optionally display the time and system load in all mode | |
4f00b8c1 DL |
668 | lines. To enable this feature, type @kbd{M-x display-time} or customize |
669 | the option @code{display-time-mode}. The information added to the mode | |
670 | line usually appears after the buffer name, before the mode names and | |
671 | their parentheses. It looks like this: | |
6bf7aab6 DL |
672 | |
673 | @example | |
674 | @var{hh}:@var{mm}pm @var{l.ll} | |
675 | @end example | |
676 | ||
677 | @noindent | |
678 | @vindex display-time-24hr-format | |
679 | Here @var{hh} and @var{mm} are the hour and minute, followed always by | |
680 | @samp{am} or @samp{pm}. @var{l.ll} is the average number of running | |
681 | processes in the whole system recently. (Some fields may be missing if | |
682 | your operating system cannot support them.) If you prefer time display | |
683 | in 24-hour format, set the variable @code{display-time-24hr-format} | |
684 | to @code{t}. | |
685 | ||
686 | @cindex mail (on mode line) | |
72bd7b7b DL |
687 | @vindex display-time-use-mail-icon |
688 | @vindex display-time-mail-face | |
6bf7aab6 | 689 | The word @samp{Mail} appears after the load level if there is mail |
72bd7b7b DL |
690 | for you that you have not read yet. On a graphical display you can use |
691 | an icon instead of @samp{Mail} by customizing | |
692 | @code{display-time-use-mail-icon}; this may save some space on the mode | |
693 | line. You can customize @code{display-time-mail-face} to make the mail | |
694 | indicator prominent. | |
6bf7aab6 | 695 | |
bd3ead08 EZ |
696 | @cindex mode line, 3D appearence |
697 | @cindex attributes of mode line, changing | |
698 | @cindex non-integral number of lines in a window | |
699 | By default, the mode line is drawn on graphics displays as a 3D | |
700 | released button. Depending on the font used for the mode line's text, | |
701 | this might make the mode line use more space than a text line in a | |
702 | window, and cause the last line of the window be partially obscured. | |
703 | That is, the window displays a non-integral number of text lines. If | |
704 | you don't like this effect, you can disable the 3D appearence of the | |
705 | mode line by customizing the attributes of the @code{mode-line} face in | |
706 | your @file{.emacs} init file, like this: | |
707 | ||
708 | @example | |
709 | (set-face-attribute 'mode-line nil :box nil) | |
710 | @end example | |
711 | ||
712 | @noindent | |
713 | Alternatively, you could turn off the box attribute in your | |
714 | @file{.Xdefaults} file: | |
715 | ||
716 | @example | |
717 | Emacs.mode-line.AttributeBox: off | |
718 | @end example | |
719 | ||
6bf7aab6 DL |
720 | @node Text Display |
721 | @section How Text Is Displayed | |
722 | @cindex characters (in text) | |
723 | ||
724 | ASCII printing characters (octal codes 040 through 0176) in Emacs | |
725 | buffers are displayed with their graphics. So are non-ASCII multibyte | |
726 | printing characters (octal codes above 0400). | |
727 | ||
728 | Some ASCII control characters are displayed in special ways. The | |
729 | newline character (octal code 012) is displayed by starting a new line. | |
730 | The tab character (octal code 011) is displayed by moving to the next | |
731 | tab stop column (normally every 8 columns). | |
732 | ||
733 | Other ASCII control characters are normally displayed as a caret | |
734 | (@samp{^}) followed by the non-control version of the character; thus, | |
735 | control-A is displayed as @samp{^A}. | |
736 | ||
7c9960d7 DL |
737 | Non-ASCII characters 0200 through 0237 (octal) are displayed with |
738 | octal escape sequences; thus, character code 0230 (octal) is displayed | |
739 | as @samp{\230}. The display of character codes 0240 through 0377 | |
740 | (octal) may be either as escape sequences or as graphics. They do not | |
741 | normally occur in multibyte buffers but if they do, they are displayed | |
742 | as Latin-1 graphics. In unibyte mode, if you enable European display | |
743 | they are displayed using their graphics (assuming your terminal supports | |
744 | them), otherwise as escape sequences. @xref{Single-Byte Character | |
745 | Support}. | |
6bf7aab6 | 746 | |
e598186c RS |
747 | @node Display Custom |
748 | @section Customization of Display | |
6bf7aab6 DL |
749 | |
750 | This section contains information for customization only. Beginning | |
751 | users should skip it. | |
752 | ||
753 | @vindex mode-line-inverse-video | |
dddbaa16 MB |
754 | The variable @code{mode-line-inverse-video} is an obsolete way of |
755 | controlling whether the mode line is displayed in inverse video; the | |
756 | preferred way of doing this is to change the @code{mode-line} face. | |
757 | @xref{Mode Line}. If you specify the foreground color for the | |
758 | @code{mode-line} face, and @code{mode-line-inverse-video} is | |
759 | non-@code{nil}, then the default background color for that face is the | |
760 | usual foreground color. @xref{Faces}. | |
6bf7aab6 DL |
761 | |
762 | @vindex inverse-video | |
763 | If the variable @code{inverse-video} is non-@code{nil}, Emacs attempts | |
764 | to invert all the lines of the display from what they normally are. | |
765 | ||
766 | @vindex visible-bell | |
767 | If the variable @code{visible-bell} is non-@code{nil}, Emacs attempts | |
768 | to make the whole screen blink when it would normally make an audible bell | |
769 | sound. This variable has no effect if your terminal does not have a way | |
770 | to make the screen blink.@refill | |
771 | ||
772 | @vindex no-redraw-on-reenter | |
773 | When you reenter Emacs after suspending, Emacs normally clears the | |
774 | screen and redraws the entire display. On some terminals with more than | |
775 | one page of memory, it is possible to arrange the termcap entry so that | |
776 | the @samp{ti} and @samp{te} strings (output to the terminal when Emacs | |
777 | is entered and exited, respectively) switch between pages of memory so | |
778 | as to use one page for Emacs and another page for other output. Then | |
779 | you might want to set the variable @code{no-redraw-on-reenter} | |
780 | non-@code{nil}; this tells Emacs to assume, when resumed, that the | |
781 | screen page it is using still contains what Emacs last wrote there. | |
782 | ||
783 | @vindex echo-keystrokes | |
784 | The variable @code{echo-keystrokes} controls the echoing of multi-character | |
785 | keys; its value is the number of seconds of pause required to cause echoing | |
786 | to start, or zero meaning don't echo at all. @xref{Echo Area}. | |
787 | ||
788 | @vindex ctl-arrow | |
789 | If the variable @code{ctl-arrow} is @code{nil}, control characters in | |
790 | the buffer are displayed with octal escape sequences, except for newline | |
791 | and tab. Altering the value of @code{ctl-arrow} makes it local to the | |
792 | current buffer; until that time, the default value is in effect. The | |
793 | default is initially @code{t}. @xref{Display Tables,, Display Tables, | |
794 | elisp, The Emacs Lisp Reference Manual}. | |
795 | ||
796 | @vindex tab-width | |
797 | Normally, a tab character in the buffer is displayed as whitespace which | |
798 | extends to the next display tab stop position, and display tab stops come | |
799 | at intervals equal to eight spaces. The number of spaces per tab is | |
800 | controlled by the variable @code{tab-width}, which is made local by | |
801 | changing it, just like @code{ctl-arrow}. Note that how the tab character | |
802 | in the buffer is displayed has nothing to do with the definition of | |
803 | @key{TAB} as a command. The variable @code{tab-width} must have an | |
804 | integer value between 1 and 1000, inclusive. | |
805 | ||
806 | @c @vindex truncate-lines @c No index entry here, because we have one | |
807 | @c in the continuation section. | |
808 | If the variable @code{truncate-lines} is non-@code{nil}, then each | |
809 | line of text gets just one screen line for display; if the text line is | |
810 | too long, display shows only the part that fits. If | |
811 | @code{truncate-lines} is @code{nil}, then long text lines display as | |
812 | more than one screen line, enough to show the whole text of the line. | |
813 | @xref{Continuation Lines}. Altering the value of @code{truncate-lines} | |
814 | makes it local to the current buffer; until that time, the default value | |
815 | is in effect. The default is initially @code{nil}. | |
816 | ||
817 | @c @vindex truncate-partial-width-windows @c Idx entry is in Split Windows. | |
818 | If the variable @code{truncate-partial-width-windows} is | |
819 | non-@code{nil}, it forces truncation rather than continuation in any | |
820 | window less than the full width of the screen or frame, regardless of | |
821 | the value of @code{truncate-lines}. For information about side-by-side | |
822 | windows, see @ref{Split Window}. See also @ref{Display,, Display, | |
823 | elisp, The Emacs Lisp Reference Manual}. | |
824 | ||
825 | @vindex baud-rate | |
87c8b5fd RS |
826 | The variable @code{baud-rate} holds the output speed of the |
827 | terminal, as far as Emacs knows. Setting this variable does not | |
828 | change the speed of actual data transmission, but the value is used | |
829 | for calculations. On terminals, it affects padding, and decisions | |
830 | about whether to scroll part of the screen or redraw it instead. | |
860dab78 | 831 | |
e598186c RS |
832 | On window-systems, @code{baud-rate} is only used to determine how |
833 | frequently to look for pending input during display updating. A | |
834 | higher value of @code{baud-rate} means that check for pending input | |
835 | will be done less frequently. | |
6bf7aab6 DL |
836 | |
837 | You can customize the way any particular character code is displayed | |
838 | by means of a display table. @xref{Display Tables,, Display Tables, | |
839 | elisp, The Emacs Lisp Reference Manual}. | |
e598186c | 840 | |
62095f01 GM |
841 | @cindex hourglass pointer display |
842 | @vindex hourglass-delay | |
099bfef9 RS |
843 | On a window system, Emacs can optionally display the mouse pointer |
844 | in a special shape to say that Emacs is busy. To turn this feature on | |
845 | or off, customize the group @code{cursor}. You can also control the | |
846 | amount of time Emacs must remain busy before the busy indicator is | |
62095f01 | 847 | displayed, by setting the variable @code{hourglass-delay}. |
099bfef9 RS |
848 | |
849 | @node Cursor Display | |
850 | @section Displaying the Cursor | |
851 | ||
e598186c RS |
852 | @findex hl-line-mode |
853 | @findex blink-cursor-mode | |
854 | @cindex cursor, locating visually | |
855 | @cindex cursor, blinking | |
856 | There are a number of ways to customize the display of the cursor. | |
857 | @kbd{M-x hl-line-mode} enables or disables a global minor mode which | |
099bfef9 | 858 | highlights the line containing point. On window systems, the command |
e598186c RS |
859 | @kbd{M-x blink-cursor-mode} turns on or off the blinking of the |
860 | cursor. (On terminals, the terminal itself blinks the cursor, and | |
87c8b5fd | 861 | Emacs has no control over it.) |
e598186c RS |
862 | |
863 | You can customize the cursor's color, and whether it blinks, using | |
864 | the @code{cursor} Custom group (@pxref{Easy Customization}). | |
099bfef9 RS |
865 | |
866 | @vindex x-stretch-cursor | |
867 | @cindex wide block cursor | |
868 | When displaying on a window system, Emacs can optionally draw the | |
869 | block cursor as wide as the character under the cursor---for example, | |
870 | if the cursor is on a tab character, it would cover the full width | |
871 | occupied by that tab character. To enable this feature, set the | |
872 | variable @code{x-stretch-cursor} to a non-@code{nil} value. | |
0f613b80 RS |
873 | |
874 | @cindex cursor in non-selected windows | |
4946337d | 875 | @vindex show-cursor-in-non-selected-windows |
0f613b80 | 876 | @vindex cursor-in-non-selected-windows |
4946337d EZ |
877 | Normally, the cursor in non-selected windows is shown as a hollow box. |
878 | To turn off cursor display in non-selected windows, customize the option | |
879 | @code{show-cursor-in-non-selected-windows}, or set the variable | |
880 | @code{cursor-in-non-selected-windows} to @code{nil}. |