Commit | Line | Data |
---|---|---|
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 |
10 | show only a part of it. This chapter describes commands and variables | |
11 | that let you specify which part of the text you want to see, and how | |
12 | the 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 |
46 | displays only a portion of it. @dfn{Scrolling} commands change which | |
47 | portion of the buffer is displayed. | |
dc917bd9 | 48 | |
550f41cd CY |
49 | Scrolling ``forward'' or ``up'' advances the portion of the buffer |
50 | displayed in the window; equivalently, it moves the buffer text | |
51 | upwards relative to the window. Scrolling ``backward'' or ``down'' | |
e7a3ff06 CY |
52 | displays an earlier portion of the buffer, and moves the text |
53 | downwards relative to the window. | |
54 | ||
55 | In Emacs, scrolling ``up'' or ``down'' refers to the direction that | |
56 | the text moves in the window, @emph{not} the direction that the window | |
57 | moves relative to the text. This terminology was adopted by Emacs | |
58 | before the modern meaning of ``scrolling up'' and ``scrolling down'' | |
59 | became widespread. Hence, the strange result that @key{PageDown} | |
60 | scrolls ``up'' in the Emacs sense. | |
dc917bd9 | 61 | |
550f41cd CY |
62 | The portion of a buffer displayed in a window always contains point. |
63 | If you move point past the bottom or top of the window, scrolling | |
64 | occurs automatically to bring it back onscreen (@pxref{Auto | |
65 | Scrolling}). 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 | 71 | Scroll 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 | 75 | Scroll 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 | |
87 | whole window height. The effect is to take the two lines at the | |
88 | bottom of the window and put them at the top, followed by lines that | |
89 | were not previously visible. If point was in the text that scrolled | |
90 | off 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 | |
94 | way. 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 | |
99 | controlled by the variable @code{next-screen-context-lines}, whose | |
100 | default value is 2. You can supply the commands with a numeric prefix | |
101 | argument, @var{n}, to scroll by @var{n} lines; Emacs attempts to leave | |
102 | point 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 | |
107 | the screen) if no more scrolling is possible, because the window has | |
108 | reached the beginning or end of the buffer. If you change the | |
109 | variable @code{scroll-error-top-bottom} to @code{t}, the command moves | |
110 | point to the farthest possible position. If point is already there, | |
111 | the 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 | |
116 | position, so that scrolling back to the same screen conveniently | |
117 | returns point to its original position. You can enable this behavior | |
118 | via the variable @code{scroll-preserve-screen-position}. If the value | |
119 | is @code{t}, Emacs adjusts point to keep the cursor at the same screen | |
120 | position whenever a scroll command moves it off-window, rather than | |
121 | moving it to the topmost or bottommost line. With any other | |
122 | non-@code{nil} value, Emacs adjusts point this way even if the scroll | |
123 | command leaves point in the window. This variable affects all the | |
124 | scroll commands documented in this section, as well as scrolling with | |
125 | the mouse wheel (@pxref{Wheeled Mice}); in general, it affects any | |
126 | command 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 | |
134 | similarly to @code{scroll-up-command} and @code{scroll-down-command}, | |
135 | except they do not obey @code{scroll-error-top-bottom}. Prior to | |
136 | Emacs 24, these were the default commands for scrolling up and down. | |
137 | The commands @kbd{M-x scroll-up-line} and @kbd{M-x scroll-down-line} | |
138 | scroll the current window by one line at a time. If you intend to use | |
139 | any 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 | |
147 | Scroll the selected window so the current line is the center-most text | |
148 | line; on subsequent consecutive invocations, make the current line the | |
149 | top line, the bottom line, and so on in cyclic order. Possibly | |
150 | redisplay the screen too (@code{recenter-top-bottom}). | |
151 | ||
152 | @item M-x recenter | |
153 | Scroll the selected window so the current line is the center-most text | |
154 | line. Possibly redisplay the screen too. | |
155 | ||
dc917bd9 RS |
156 | @item C-M-l |
157 | Scroll 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} |
164 | the selected window, scrolling it so that the current screen line is | |
165 | exactly in the center of the window, or as close to the center as | |
166 | possible. | |
956c76ef CY |
167 | |
168 | Typing @kbd{C-l} twice in a row (@kbd{C-l C-l}) scrolls the window | |
169 | so that point is on the topmost screen line. Typing a third @kbd{C-l} | |
170 | scrolls the window so that point is on the bottom-most screen line. | |
41859241 | 171 | Each 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 | 177 | means to move the line to the specified screen line, while a |
91ed7ea8 | 178 | floating-point number between 0.0 and 1.0 specifies a percentage of |
41859241 CY |
179 | the screen space from the top of the window. The default, |
180 | @code{(middle top bottom)}, is the cycling order described above. | |
181 | Furthermore, if you change the variable @code{scroll-margin} to a | |
182 | non-zero value @var{n}, @kbd{C-l} always leaves at least @var{n} | |
183 | screen 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 |
187 | argument, @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 | |
189 | argument 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 | |
191 | given an argument, @kbd{C-l} does not clear the screen or cycle | |
192 | through 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 |
196 | value, each invocation of @kbd{C-l} also clears and redisplays the |
197 | screen; the special value @code{tty} (the default) says to do this on | |
198 | text-terminal frames only. Redisplaying is useful in case the screen | |
199 | becomes 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 |
208 | heuristically in a way designed to get useful information onto the | |
209 | screen. For example, in a Lisp file, this command tries to get the | |
dc917bd9 RS |
210 | entire 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 |
216 | visible portion of the text. | |
217 | ||
dc917bd9 | 218 | @vindex scroll-conservatively |
956c76ef CY |
219 | Normally, this centers point vertically within the window. However, |
220 | if you set @code{scroll-conservatively} to a small number @var{n}, | |
221 | then if you move point just a little off the screen (less than @var{n} | |
222 | lines), Emacs scrolls the text just far enough to bring point back on | |
09725d26 EZ |
223 | screen. By default, @code{scroll-conservatively} is@tie{}0. If you |
224 | set @code{scroll-conservatively} to a large number (larger than 100), | |
225 | Emacs will never center point as result of scrolling, even if point | |
226 | moves far away from the text previously displayed in the window. With | |
227 | such a large value, Emacs will always scroll text just enough for | |
228 | bringing point into view, so point will end up at the top or bottom of | |
229 | the window, depending on the scroll direction. | |
230 | ||
231 | @vindex scroll-step | |
232 | The variable @code{scroll-step} determines how many lines to scroll | |
233 | the window when point moves off the screen. If moving by that number | |
234 | of lines fails to bring point back into view, point is centered | |
235 | instead. The default value is zero, which causes point to always be | |
236 | centered 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 | 242 | how aggressively it scrolls by setting the variables |
dc917bd9 RS |
243 | @code{scroll-up-aggressively} and @code{scroll-down-aggressively}. |
244 | The value of @code{scroll-up-aggressively} should be either | |
245 | @code{nil}, or a fraction @var{f} between 0 and 1. A fraction | |
3b361baf | 246 | specifies where on the screen to put point when scrolling upward, |
41859241 CY |
247 | i.e. forward. When point goes off the window end, the new start |
248 | position is chosen to put point @var{f} parts of the window height | |
249 | from the bottom. Thus, larger @var{f} means more aggressive | |
3b361baf EZ |
250 | scrolling: 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 |
254 | down, i.e. backward. The value specifies how far point should be |
255 | placed 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 | |
263 | to the top or bottom of a window. Its value is a number of screen | |
956c76ef CY |
264 | lines; if point comes within that many lines of the top or bottom of |
265 | the 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 |
274 | within a window, so that some of the text near the left margin is not |
275 | displayed. When the text in a window is scrolled horizontally, text | |
276 | lines are truncated rather than continued (@pxref{Line Truncation}). | |
277 | If a window shows truncated lines, Emacs performs automatic horizontal | |
278 | scrolling whenever point moves off the left or right edge of the | |
279 | screen. To disable automatic horizontal scrolling, set the variable | |
6308321a EZ |
280 | @code{auto-hscroll-mode} to @code{nil}. Note that when the automatic |
281 | horizontal scrolling is turned off, if point moves off the edge of the | |
41859241 | 282 | screen, the cursor disappears to indicate that. (On text-only |
6308321a | 283 | terminals, 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 |
287 | to the window's edges before automatic scrolling occurs. It is |
288 | measured in columns. For example, if the value is 5, then moving | |
289 | point within 5 columns of an edge causes horizontal scrolling away | |
290 | from that edge. | |
956c76ef CY |
291 | |
292 | @vindex hscroll-step | |
293 | The variable @code{hscroll-step} determines how many columns to | |
294 | scroll the window when point gets too close to the edge. Zero, the | |
295 | default value, means to center point horizontally within the window. | |
296 | A positive integer value specifies the number of columns to scroll by. | |
297 | A floating-point number specifies the fraction of the window's width | |
298 | to scroll by. | |
299 | ||
300 | You can also perform explicit horizontal scrolling with the | |
301 | following commands: | |
dc917bd9 RS |
302 | |
303 | @table @kbd | |
304 | @item C-x < | |
305 | Scroll text in current window to the left (@code{scroll-left}). | |
306 | @item C-x > | |
307 | Scroll 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 |
315 | to the left by the full width of the window, less two columns. (In | |
316 | other words, the text in the window moves left relative to the | |
317 | window.) With a numeric argument @var{n}, it scrolls by @var{n} | |
318 | columns. | |
319 | ||
320 | If the text is scrolled to the left, and point moves off the left | |
321 | edge of the window, the cursor will freeze at the left edge of the | |
322 | window, until point moves back to the displayed portion of the text. | |
323 | This is independent of the current setting of | |
324 | @code{auto-hscroll-mode}, which, for text scrolled to the left, only | |
325 | affects the behavior at the right edge of the window. | |
956c76ef CY |
326 | |
327 | @kbd{C-x >} (@code{scroll-right}) scrolls similarly to the right. | |
328 | The window cannot be scrolled any farther to the right once it is | |
329 | displayed normally, with each line starting at the window's left | |
330 | margin; attempting to do so has no effect. This means that you don't | |
331 | have to calculate the argument precisely for @w{@kbd{C-x >}}; any | |
332 | sufficiently large argument will restore the normal display. | |
dc917bd9 RS |
333 | |
334 | If you use those commands to scroll a window horizontally, that sets | |
335 | a lower bound for automatic horizontal scrolling. Automatic scrolling | |
336 | will continue to scroll the window, but never farther to the right | |
337 | than 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, | |
347 | making the rest temporarily inaccessible. The portion which you can | |
348 | still get to is called the @dfn{accessible portion}. Canceling the | |
349 | narrowing, which makes the entire buffer once again accessible, is | |
350 | called @dfn{widening}. The bounds of narrowing in effect in a buffer | |
351 | are called the buffer's @dfn{restriction}. | |
352 | ||
353 | Narrowing can make it easier to concentrate on a single subroutine or | |
354 | paragraph by eliminating clutter. It can also be used to limit the | |
355 | range of operation of a replace command or repeating keyboard macro. | |
356 | ||
357 | @table @kbd | |
358 | @item C-x n n | |
359 | Narrow down to between point and mark (@code{narrow-to-region}). | |
360 | @item C-x n w | |
361 | Widen to make the entire buffer accessible again (@code{widen}). | |
362 | @item C-x n p | |
363 | Narrow down to the current page (@code{narrow-to-page}). | |
364 | @item C-x n d | |
365 | Narrow 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 | |
369 | to 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 | |
371 | it in any way. However, it is not gone, and if you save the file all | |
372 | the inaccessible text will be saved. The word @samp{Narrow} appears in | |
373 | the 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}). | |
378 | It sets the current buffer's restrictions so that the text in the current | |
379 | region remains accessible, but all text before the region or after the | |
380 | region 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 | |
387 | down 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 | |
389 | containing 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 | |
397 | to 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 | |
401 | this command asks for confirmation and gives you the option of enabling it; | |
402 | if you enable the command, confirmation will no longer be required for | |
403 | it. @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 |
414 | screenfuls. It provides commands for scrolling through the buffer | |
415 | conveniently but not for changing it. Apart from the usual Emacs | |
416 | cursor motion commands, you can type @key{SPC} to scroll forward one | |
e2aeef63 CY |
417 | windowful, @key{DEL} to scroll backward, and @kbd{s} to start an |
418 | incremental 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 | |
425 | back to the buffer and position before View mode was enabled. Typing | |
426 | @kbd{e} (@code{View-exit}) disables View mode, keeping the current | |
427 | buffer 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 | |
432 | to it, and enables View mode. @kbd{M-x view-file} prompts for a file | |
433 | and 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 | |
444 | showing the same buffer, scroll as a single tall ``virtual window.'' | |
445 | To use Follow mode, go to a frame with just one window, split it into | |
446 | two side-by-side windows using @kbd{C-x 3}, and then type @kbd{M-x | |
447 | follow-mode}. From then on, you can edit the buffer in either of the | |
448 | two 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 | |
451 | window and into the portion visible in the other window, that selects | |
452 | the other window---again, treating the two as if they were parts of | |
453 | one 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 |
463 | such as the font, height, weight, slant, foreground and background |
464 | color, and underlining or overlining. Most major modes assign faces | |
465 | to the text automatically, via Font Lock mode. @xref{Font Lock}, for | |
466 | more 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, | |
470 | type @kbd{M-x list-faces-display}. With a prefix argument, this | |
471 | prompts for a regular expression, and displays only faces with names | |
472 | matching that regular expression (@pxref{Regexps}). | |
473 | ||
474 | It's possible for a given face to look different in different | |
475 | frames. For instance, some text-only terminals do not support all | |
476 | face attributes, particularly font, height, and width, and some | |
477 | support a limited range of colors. The @code{list-faces-display} | |
478 | command 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 | |
484 | changes for future Emacs sessions. @xref{Face Customization}. A face | |
485 | does not have to specify every single attribute; often it inherits | |
486 | most attributes from another face. Any ultimately unspecified | |
487 | attribute is taken from a face named @code{default}, whose attributes | |
488 | are all specified. The @code{default} face is the default for | |
489 | displaying text, and its background color is also used as the frame's | |
490 | background color. | |
491 | ||
492 | You can also use X resources to specify attributes of any particular | |
493 | face. @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 |
498 | with @kbd{M-x set-face-foreground} and @kbd{M-x set-face-background}. | |
499 | These commands prompt in the minibuffer for a face name and a color | |
500 | name, with completion, and then set that face to use the specified | |
501 | color (@pxref{Face Customization}, for information about color names). | |
502 | They affect the face colors on all frames, but their effects do not | |
503 | persist for future Emacs sessions, unlike using the customization | |
504 | buffer or X resources. You can also use frame parameters to set | |
505 | foreground and background colors for a specific frame; see @ref{Frame | |
506 | Parameters}. | |
507 | ||
508 | Emacs can display variable-width fonts, but some Emacs commands, | |
509 | particularly indentation commands, do not account for variable | |
510 | character display widths. Therefore, we recommend not using | |
511 | variable-width fonts for most faces, particularly those assigned by | |
512 | Font 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 |
518 | apply them to specific text when you want the effects they produce. | |
b8f3a9e3 GM |
519 | |
520 | @table @code | |
521 | @item default | |
54952612 | 522 | This face is used for ordinary text that doesn't specify any face. |
d366bd53 | 523 | Its background color is used as the frame's background color. |
43d08eb9 | 524 | @item bold |
956c76ef | 525 | This face uses a bold variant of the default font. |
43d08eb9 | 526 | @item italic |
956c76ef | 527 | This face uses an italic variant of the default font. |
43d08eb9 | 528 | @item bold-italic |
956c76ef | 529 | This face uses a bold italic variant of the default font. |
43d08eb9 RS |
530 | @item underline |
531 | This face underlines text. | |
532 | @item fixed-pitch | |
956c76ef CY |
533 | This face forces use of a fixed-width font. It's reasonable to |
534 | customize this face to use a different fixed-width font, if you like, | |
535 | but you should not make it a variable-width font. | |
43d08eb9 | 536 | @item variable-pitch |
956c76ef | 537 | This face forces use of a variable-width font. |
3b91a16d JL |
538 | @item shadow |
539 | This face is used for making the text less noticeable than the surrounding | |
540 | ordinary text. Usually this can be achieved by using shades of gray in | |
541 | contrast 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 | |
545 | text temporarily for specific purposes. (Many other modes define | |
546 | their own faces for this purpose.) | |
547 | ||
548 | @table @code | |
549 | @item highlight | |
d366bd53 CY |
550 | This face is used for text highlighting in various contexts, such as |
551 | when the mouse cursor is moved over a hyperlink. | |
43d08eb9 | 552 | @item isearch |
d366bd53 | 553 | This face is used to highlight the current Isearch match |
956c76ef | 554 | (@pxref{Incremental Search}). |
54952612 | 555 | @item query-replace |
d366bd53 | 556 | This face is used to highlight the current Query Replace match |
956c76ef | 557 | (@pxref{Replace}). |
43d08eb9 | 558 | @item lazy-highlight |
d366bd53 CY |
559 | This face is used to highlight ``lazy matches'' for Isearch and Query |
560 | Replace (matches other than the current one). | |
43d08eb9 | 561 | @item region |
d366bd53 CY |
562 | This face is used for displaying an active region (@pxref{Mark}). |
563 | When Emacs is built with GTK support, its colors are taken from the | |
564 | current GTK theme. | |
43d08eb9 RS |
565 | @item secondary-selection |
566 | This face is used for displaying a secondary X selection (@pxref{Secondary | |
567 | Selection}). | |
568 | @item trailing-whitespace | |
3b91a16d | 569 | The face for highlighting excess spaces and tabs at the end of a line |
d366bd53 CY |
570 | when @code{show-trailing-whitespace} is non-@code{nil} (@pxref{Useless |
571 | Whitespace}). | |
43d08eb9 | 572 | @item escape-glyph |
d366bd53 CY |
573 | The face for displaying control characters and escape sequences |
574 | (@pxref{Text Display}). | |
575 | @item nobreak-space | |
939db9ac | 576 | The face for displaying ``no-break'' space characters (@pxref{Text |
d366bd53 | 577 | Display}). |
43d08eb9 RS |
578 | @end table |
579 | ||
d366bd53 CY |
580 | The following faces control the appearance of parts of the Emacs |
581 | frame: | |
43d08eb9 RS |
582 | |
583 | @table @code | |
b8f3a9e3 | 584 | @item mode-line |
3b91a16d JL |
585 | This face is used for the mode line of the currently selected window, |
586 | and for menu bars when toolkit menus are not used. By default, it's | |
54952612 | 587 | drawn with shadows for a ``raised'' effect on graphical displays, and |
3b91a16d | 588 | drawn as the inverse of the default face on non-windowed terminals. |
b9e58bf2 EZ |
589 | @item mode-line-inactive |
590 | Like @code{mode-line}, but used for mode lines of the windows other | |
591 | than the selected one (if @code{mode-line-in-non-selected-windows} is | |
ac6875fc RS |
592 | non-@code{nil}). This face inherits from @code{mode-line}, so changes |
593 | in that face affect mode lines in all windows. | |
d545c9fd JL |
594 | @item mode-line-highlight |
595 | Like @code{highlight}, but used for portions of text on mode lines. | |
596 | @item mode-line-buffer-id | |
597 | This face is used for buffer identification parts in the mode line. | |
b8f3a9e3 | 598 | @item header-line |
54952612 RS |
599 | Similar to @code{mode-line} for a window's header line, which appears |
600 | at the top of a window just as the mode line appears at the bottom. | |
601 | Most windows do not have a header line---only some special modes, such | |
602 | Info mode, create one. | |
53abc3bf | 603 | @item vertical-border |
d366bd53 CY |
604 | This face is used for the vertical divider between windows on |
605 | text-only terminals. | |
3094ad7a | 606 | @item minibuffer-prompt |
3b91a16d JL |
607 | @cindex @code{minibuffer-prompt} face |
608 | @vindex minibuffer-prompt-properties | |
3094ad7a | 609 | This face is used for the prompt strings displayed in the minibuffer. |
3b91a16d JL |
610 | By default, Emacs automatically adds this face to the value of |
611 | @code{minibuffer-prompt-properties}, which is a list of text | |
43d67313 RS |
612 | properties used to display the prompt text. (This variable takes |
613 | effect when you enter the minibuffer.) | |
b8f3a9e3 | 614 | @item fringe |
3b91a16d | 615 | @cindex @code{fringe} face |
b8f3a9e3 GM |
616 | The face for the fringes to the left and right of windows on graphic |
617 | displays. (The fringes are the narrow portions of the Emacs frame | |
940627fe | 618 | between the text area and the window's right and left borders.) |
43d08eb9 | 619 | @xref{Fringes}. |
b8f3a9e3 | 620 | @item cursor |
939db9ac CY |
621 | The @code{:background} attribute of this face specifies the color of |
622 | the text cursor. @xref{Cursor Display}. | |
d366bd53 CY |
623 | @item tooltip |
624 | This face is used for tooltip text. By default, if Emacs is built | |
625 | with GTK support, tooltips are drawn via GTK and this face has no | |
626 | effect. @xref{Tooltips}. | |
b8f3a9e3 GM |
627 | @item mouse |
628 | This 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 | |
632 | Emacs frame, but only on text-only terminals, or when Emacs is built | |
633 | on X with no toolkit support. (For all other cases, the appearance of | |
634 | the respective frame elements is determined by system-wide settings.) | |
635 | ||
636 | @table @code | |
637 | @item scroll-bar | |
638 | This face determines the visual appearance of the scroll bar. | |
639 | @xref{Scroll Bars}. | |
b8f3a9e3 | 640 | @item tool-bar |
54952612 | 641 | This 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 | |
646 | This face determines the colors and font of Emacs's menus. @xref{Menu | |
d366bd53 | 647 | Bars}. |
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, | |
660 | type @kbd{C-x C-+} or @kbd{C-x C-=}. To decrease it, type @kbd{C-x | |
661 | C--}. To restore the default (global) face height, type @kbd{C-x | |
662 | C-0}. These keys are all bound to the same command, | |
663 | @code{text-scale-adjust}, which looks at the last key typed to | |
664 | determine 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 |
668 | height by three steps. Each step scales the text height by a factor |
669 | of 1.2; to change this factor, customize the variable | |
670 | @code{text-scale-mode-step}. As an exception, a numeric argument of 0 | |
671 | to the @code{text-scale-adjust} command restores the default height, | |
672 | similar 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 | |
680 | default face, just like @kbd{C-x C-+} and @kbd{C-x C--} respectively. | |
681 | You 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 |
687 | face in the current buffer to an absolute level specified by its | |
688 | prefix 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, | |
693 | and 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 |
702 | which assigns faces to (or @dfn{fontifies}) the text in the buffer. |
703 | Each buffer's major mode tells Font Lock mode which text to fontify; | |
704 | for instance, programming language modes fontify syntactically | |
705 | relevant 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 |
709 | buffer, type @kbd{M-x font-lock-mode}. A positive numeric argument | |
710 | unconditionally enables Font Lock mode, and a negative or zero | |
711 | argument 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 |
716 | global-font-lock-mode}. To impose this setting for future Emacs | |
717 | sessions, customize the variable @code{global-font-lock-mode} | |
718 | (@pxref{Easy Customization}), or add the following line to your init | |
719 | file: | |
b8f3a9e3 GM |
720 | |
721 | @example | |
c4e8acbc | 722 | (global-font-lock-mode 0) |
b8f3a9e3 GM |
723 | @end example |
724 | ||
d366bd53 CY |
725 | @noindent |
726 | If you have disabled Global Font Lock mode, you can still enable Font | |
54952612 | 727 | Lock for specific major modes by adding the function |
6e317956 CY |
728 | @code{font-lock-mode} to the mode hooks (@pxref{Hooks}). For example, |
729 | to 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, |
736 | including @code{font-lock-string-face}, @code{font-lock-comment-face}, | |
54952612 RS |
737 | and others. The easiest way to find them all is to use @kbd{M-x |
738 | customize-group @key{RET} font-lock-faces @key{RET}}. You can then | |
739 | use that customization buffer to customize the appearance of these | |
740 | faces. @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} |
744 | to alter the amount of fontification applied by Font Lock mode, for | |
745 | major modes that support this feature. The value should be a number | |
746 | (with 1 representing a minimal amount of fontification; some modes | |
747 | support levels as high as 3); or @code{t}, meaning ``as high as | |
748 | possible'' (the default). You can also specify different numbers for | |
749 | particular major modes; for example, to use level 1 for C/C++ modes, | |
750 | and 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) |
761 | relies on analysis of the syntactic structure of the buffer text. For | |
174862cf RS |
762 | the sake of speed, some modes, including Lisp mode, rely on a special |
763 | convention: an open-parenthesis or open-brace in the leftmost column | |
d366bd53 | 764 | always defines the beginning of a defun, and is thus always outside |
20db1522 | 765 | any string or comment. Therefore, you should avoid placing an |
d366bd53 CY |
766 | open-parenthesis or open-brace in the leftmost column, if it is inside |
767 | a 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 |
771 | always buffer-local, specifies how Font Lock mode can find a position | |
772 | guaranteed to be outside any comment or string. In modes which use | |
773 | the leftmost column parenthesis convention, the default value of the | |
774 | variable is @code{beginning-of-defun}---that tells Font Lock mode to | |
775 | use the convention. If you set this variable to @code{nil}, Font Lock | |
776 | no longer relies on the convention. This avoids incorrect results, | |
777 | but the price is that, in some cases, fontification for a changed text | |
778 | must rescan buffer text from the beginning of the buffer. This can | |
779 | considerably slow down redisplay while scrolling, particularly if you | |
780 | are 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 |
784 | you may want to fontify additional patterns. You can use the function | |
785 | @code{font-lock-add-keywords}, to add your own highlighting patterns | |
786 | for a particular mode. For example, to highlight @samp{FIXME:} words | |
787 | in 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 |
799 | To remove keywords from the font-lock highlighting patterns, use the | |
cd77ce13 | 800 | function @code{font-lock-remove-keywords}. @xref{Search-based |
956c76ef | 801 | Fontification,,, 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 |
806 | delays when a file is visited, Emacs initially fontifies only the |
807 | visible portion of a buffer. As you scroll through the buffer, each | |
808 | portion that becomes visible is fontified as soon as it is displayed; | |
809 | this type of Font Lock is called @dfn{Just-In-Time} (or @dfn{JIT}) | |
810 | Lock. You can control how JIT Lock behaves, including telling it to | |
811 | perform fontification while idle, by customizing variables in the | |
956c76ef | 812 | customization 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 | 821 | Highlight Changes mode is a minor mode that @dfn{highlights} the parts |
d366bd53 | 822 | of the buffer that were changed most recently, by giving that text a |
956c76ef CY |
823 | different 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 |
829 | regular expressions you specify. For example, you can use it to | |
830 | highlight all the references to a certain variable in a program source | |
831 | file, highlight certain parts in a voluminous output of some program, | |
832 | or highlight certain names in an article. To enable or disable Hi | |
833 | Lock mode, use the command @kbd{M-x hi-lock-mode}. To enable Hi Lock | |
834 | mode 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 | |
838 | that you specify explicitly the regular expressions to highlight. You | |
839 | control 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 | 845 | Highlight text that matches @var{regexp} using face @var{face} |
54952612 RS |
846 | (@code{highlight-regexp}). The highlighting will remain as long as |
847 | the buffer is loaded. For example, to highlight all occurrences of | |
848 | the 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 | |
850 | highlighting, Hi Lock provides several of its own and these are | |
29a483ac JL |
851 | pre-loaded into a list of default values. While being prompted |
852 | for a face use @kbd{M-n} and @kbd{M-p} to cycle through them. | |
54952612 RS |
853 | |
854 | You can use this command multiple times, specifying various regular | |
855 | expressions 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 | 860 | Unhighlight @var{regexp} (@code{unhighlight-regexp}). |
54952612 RS |
861 | |
862 | If you invoke this from the menu, you select the expression to | |
863 | unhighlight from a list. If you invoke this from the keyboard, you | |
864 | use the minibuffer. It will show the most recently added regular | |
865 | expression; 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 | |
867 | expression by hand, with completion.) When the expression you want to | |
868 | unhighlight appears in the minibuffer, press @kbd{@key{RET}} to exit | |
869 | the 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 | 876 | Highlight 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 | |
882 | Insert all the current highlighting regexp/face pairs into the buffer | |
883 | at point, with comment delimiters to prevent them from changing your | |
54952612 RS |
884 | program. (This key binding runs the |
885 | @code{hi-lock-write-interactive-patterns} command.) | |
b8f3a9e3 | 886 | |
3173ce7e RS |
887 | These patterns are extracted from the comments, if appropriate, if you |
888 | invoke @kbd{M-x hi-lock-find-patterns}, or if you visit the file while | |
889 | Hi 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 |
894 | Extract regexp/face pairs from comments in the current buffer |
895 | (@code{hi-lock-find-patterns}). Thus, you can enter patterns | |
896 | interactively with @code{highlight-regexp}, store them into the file | |
897 | with @code{hi-lock-write-interactive-patterns}, edit them (perhaps | |
cedf175b | 898 | including different faces for different parenthesized parts of the |
3173ce7e RS |
899 | match), and finally use this command (@code{hi-lock-find-patterns}) to |
900 | have Hi Lock highlight the edited patterns. | |
b8f3a9e3 | 901 | |
3173ce7e | 902 | @vindex hi-lock-file-patterns-policy |
d439bcd8 | 903 | The variable @code{hi-lock-file-patterns-policy} controls whether Hi |
0419b8d6 GM |
904 | Lock mode should automatically extract and highlight patterns found in a |
905 | file 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 | |
908 | the function returns non-@code{nil}, the patterns are used. The default | |
909 | is @code{ask}. Note that patterns are always highlighted if you call | |
910 | @code{hi-lock-find-patterns} directly, regardless of the value of this | |
911 | variable. | |
3173ce7e RS |
912 | |
913 | @vindex hi-lock-exclude-modes | |
914 | Also, @code{hi-lock-find-patterns} does nothing if the current major | |
915 | mode'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 |
926 | display symbols that provide information about the text in the window. | |
939db9ac CY |
927 | You can type @kbd{M-x fringe-mode} to disable the fringes, or modify |
928 | their width. This command affects fringes in all frames; to modify | |
929 | fringes 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 |
932 | line (@pxref{Continuation Lines}). When one line of text is split |
933 | into multiple screen lines, the left fringe shows a curving arrow for | |
934 | each screen line except the first, indicating that ``this is not the | |
935 | real beginning.'' The right fringe shows a curving arrow for each | |
936 | screen line except the last, indicating that ``this is not the real | |
937 | end.'' If the line's direction is right-to-left (@pxref{Bidirectional | |
938 | Editing}), the meanings of the curving arrows in the fringes are | |
34313041 | 939 | swapped. |
fad78d58 | 940 | |
566da2e7 | 941 | The fringes indicate line truncation with short horizontal arrows |
fad78d58 | 942 | meaning ``there's more text on this line which is scrolled |
d366bd53 CY |
943 | horizontally out of view.'' Clicking the mouse on one of the arrows |
944 | scrolls the display horizontally in the direction of the arrow. | |
945 | ||
946 | The fringes can also indicate other things, such as buffer | |
947 | boundaries (@pxref{Displaying Boundaries}), and where a program you | |
948 | are 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 | |
952 | is exactly as wide as the window and point is at the end of the line. | |
953 | To disable this, change the variable | |
954 | @code{overflow-newline-into-fringe} to @code{nil}; this causes Emacs | |
955 | to 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 |
962 | the fringes. If you enable this feature, the first line and the last |
963 | line are marked with angle images in the fringes. This can be | |
964 | combined with up and down arrow images which say whether it is | |
965 | possible to scroll the window. | |
9d2908a6 RS |
966 | |
967 | The buffer-local variable @code{indicate-buffer-boundaries} controls | |
968 | how the buffer boundaries and window scrolling is indicated in the | |
969 | fringes. If the value is @code{left} or @code{right}, both angle and | |
970 | arrow 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. | |
974 | The @var{indicator} must be one of @code{top}, @code{bottom}, | |
975 | @code{up}, @code{down}, or @code{t} which specifies the default | |
976 | position for the indicators not present in the alist. | |
977 | The @var{position} is one of @code{left}, @code{right}, or @code{nil} | |
978 | which specifies not to show this indicator. | |
979 | ||
980 | For example, @code{((top . left) (t . right))} places the top angle | |
981 | bitmap in left fringe, the bottom angle bitmap in right fringe, and | |
982 | both arrow bitmaps in right fringe. To show just the angle bitmaps in | |
983 | the 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 | |
993 | empty lines at the end of a file, without realizing it. In most | |
994 | cases, this @dfn{trailing whitespace} has no effect, but there are | |
956c76ef | 995 | special 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 |
998 | setting 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 | |
1003 | containing the whitespace. Strictly speaking, that is ``trailing | |
1004 | whitespace'' nonetheless, but displaying it specially in that case | |
1005 | looks ugly while you are typing in new text. In this special case, | |
1006 | the location of point is enough to show you that the spaces are | |
1007 | present. | |
1008 | ||
1009 | @findex delete-trailing-whitespace | |
d366bd53 CY |
1010 | Type @kbd{M-x delete-trailing-whitespace} to delete all trailing |
1011 | whitespace within the buffer. If the region is active, it deletes all | |
1012 | trailing 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 |
1018 | the window with a small image in the left fringe (@pxref{Fringes}). | |
1019 | The image appears for window lines that do not correspond to any | |
1020 | buffer text. Blank lines at the end of the buffer then stand out | |
1021 | because they do not have this image in the fringe. To enable this | |
1022 | feature, set the buffer-local variable @code{indicate-empty-lines} to | |
1023 | a non-@code{nil} value. You can enable or disable this feature for | |
1024 | all new buffers by setting the default value of this variable, | |
1025 | e.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 |
1034 | number of columns. You can use this to get an overview of a part of a | |
1035 | program. | |
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 | |
1039 | lines with at least @var{n} columns of indentation disappear from the | |
1040 | screen. The only indication of their presence is that three dots | |
1041 | (@samp{@dots{}}) appear at the end of each visible line that is | |
1042 | followed 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 | |
1045 | if they were not there. | |
1046 | ||
1047 | The hidden lines are still present in the buffer, and most editing | |
1048 | commands see them as usual, so you may find point in the middle of the | |
1049 | hidden text. When this happens, the cursor appears at the end of the | |
1050 | previous line, after the three dots. If point is at the end of the | |
1051 | visible line, before the newline that ends it, the cursor appears before | |
1052 | the 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 | |
1059 | precedes hidden lines. Then there is no visible indication of the | |
1060 | hidden lines. This variable becomes local automatically when set. | |
1061 | ||
0015d677 RS |
1062 | See also @ref{Outline Mode} for another way to hide part of |
1063 | the 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 | |
1072 | buffer above the top of the window. You can additionally display the | |
1073 | size of the buffer by typing @kbd{M-x size-indication-mode} to turn on | |
1074 | Size Indication mode. The size will be displayed immediately | |
1075 | following the buffer percentage like this: | |
1076 | ||
1077 | @example | |
1078 | @var{POS} of @var{SIZE} | |
1079 | @end example | |
1080 | ||
1081 | @noindent | |
1082 | Here @var{SIZE} is the human readable representation of the number of | |
1083 | characters in the buffer, which means that @samp{k} for 10^3, @samp{M} | |
1084 | for 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 | |
1090 | Number mode is enabled. Use the command @kbd{M-x line-number-mode} to | |
1091 | turn this mode on and off; normally it is on. The line number appears | |
b213b767 | 1092 | after the buffer percentage @var{pos}, with the letter @samp{L} to |
79199dd2 AM |
1093 | indicate 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 | |
1099 | Column number mode with @kbd{M-x column-number-mode}. The column | |
1100 | number is indicated by the letter @samp{C}. However, when both of | |
1101 | these modes are enabled, the line and column numbers are displayed in | |
1102 | parentheses, the line number first, rather than with @samp{L} and | |
1103 | @samp{C}. For example: @samp{(561,2)}. @xref{Minor Modes}, for more | |
1104 | information 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 | |
1108 | line number is relative to the accessible portion of the buffer. | |
54952612 RS |
1109 | Thus, 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 | |
1111 | file.) | |
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 |
1116 | number, because that would be too slow; therefore, the line number | |
1117 | won'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 |
1122 | are too long. For this reason, Emacs doesn't display line numbers if |
1123 | the average width, in characters, of lines near point is larger than | |
1124 | the value of @code{line-number-display-limit-width}. The default | |
1125 | value 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 |
1130 | lines. To enable this feature, type @kbd{M-x display-time} or customize |
1131 | the option @code{display-time-mode}. The information added to the mode | |
bb3865e8 | 1132 | line 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 | |
1140 | Here @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 |
1142 | for the last few minutes, of processes in the whole system that were | |
1143 | either running or ready to run (i.e.@: were waiting for an available | |
1144 | processor). (Some fields may be missing if your operating system | |
1145 | cannot support them.) If you prefer time display in 24-hour format, | |
1146 | set 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 |
1154 | for you that you have not read yet. On graphical displays, you can |
1155 | use an icon instead of @samp{Mail} by customizing | |
1156 | @code{display-time-use-mail-icon}; this may save some space on the | |
1157 | mode line. You can customize @code{display-time-mail-face} to make | |
1158 | the mail indicator prominent. Use @code{display-time-mail-file} to | |
1159 | specify the mail file to check, or set | |
1160 | @code{display-time-mail-directory} to specify the directory to check | |
1161 | for incoming mail (any nonempty regular file in the directory is | |
1162 | considered 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 | |
1169 | charge 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 | |
1173 | is displayed; the exact mode-line message depends on the operating | |
1174 | system, and it usually shows the current battery charge as a | |
1175 | percentage 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 |
1181 | don'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 | 1187 | different face, called @code{mode-line-inactive}. Only the selected |
ac6875fc RS |
1188 | window is displayed in the @code{mode-line} face. This helps show |
1189 | which window is selected. When the minibuffer is selected, since | |
1190 | it has no mode line, the window from which you activated the minibuffer | |
1191 | has its mode line displayed using @code{mode-line}; as a result, | |
1192 | ordinary 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 |
1197 | lines 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 | |
1204 | formats 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 |
1214 | buffer, they are displayed literally on the screen. Printing | |
1215 | characters include @acronym{ASCII} numbers, letters, and punctuation | |
1216 | characters, 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 | |
1221 | characters}. Two of these are displayed specially: the newline | |
1222 | character (Unicode code point @code{U+000A}) is displayed by starting | |
1223 | a new line, while the tab character (@code{U+0009}) is displayed as a | |
1224 | space that extends to the next tab stop column (normally every 8 | |
1225 | columns). The number of spaces per tab is controlled by the | |
1226 | buffer-local variable @code{tab-width}, which must have an integer | |
1227 | value between 1 and 1000, inclusive. Note that how the tab character | |
1228 | in 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 | |
1233 | the @code{escape-glyph} face. For instance, the @samp{control-A} | |
1234 | character, @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 | |
1239 | escape sequences, with the @code{escape-glyph} face. For instance, | |
1240 | character code @code{U+0098} (octal 230) is displayed as @samp{\230}. | |
1241 | If you change the buffer-local variable @code{ctl-arrow} to | |
1242 | @code{nil}, @acronym{ASCII} control characters are also displayed as | |
1243 | octal 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 | |
1251 | can cause problems if they are entered into a buffer without your | |
1252 | realization, e.g. by yanking; for instance, source code compilers | |
1253 | typically do not treat non-@acronym{ASCII} spaces as whitespace | |
1254 | characters. To deal with this problem, Emacs displays such characters | |
1255 | specially: it displays @code{U+00A0} (no-break space) with the | |
1256 | @code{nobreak-space} face, and it displays @code{U+00AD} (soft | |
1257 | hyphen), @code{U+2010} (hyphen), and @code{U+2011} (non-breaking | |
1258 | hyphen) with the @code{escape-glyph} face. To disable this, change | |
1259 | the variable @code{nobreak-char-display} to @code{nil}. If you give | |
1260 | this variable a non-@code{nil} and non-@code{t} value, Emacs instead | |
1261 | displays such characters as a highlighted backslash followed by a | |
1262 | space or hyphen. | |
b5cced4b | 1263 | |
54952612 RS |
1264 | You can customize the way any particular character code is displayed |
1265 | by means of a display table. @xref{Display Tables,, Display Tables, | |
1266 | elisp, 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 |
1271 | the fonts available to Emacs. These @dfn{glyphless characters} are | |
1272 | normally displayed as boxes containing the hexadecimal character code. | |
1273 | You can control the display method by customizing the variable | |
1274 | @code{glyphless-char-display-control}. @xref{Glyphless Chars,, | |
1275 | Glyphless Character Display, elisp, The Emacs Lisp Reference Manual}, | |
1276 | for 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 |
1284 | terminal, largely out of the control of Emacs. Some terminals offer | |
1285 | two different cursors: a ``visible'' static cursor, and a ``very | |
1286 | visible'' blinking cursor. By default, Emacs uses the very visible | |
1287 | cursor, and switches to it when you start or resume Emacs. If the | |
1288 | variable @code{visible-cursor} is @code{nil} when Emacs starts or | |
1289 | resumes, 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 | |
1294 | be altered. To customize its color, change the @code{:background} | |
1295 | attribute of the face named @code{cursor} (@pxref{Face | |
1296 | Customization}). (The other attributes of this face have no effect; | |
1297 | the text shown under the cursor is drawn using the frame's background | |
1298 | color.) 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 | |
1302 | horizontal bar), @code{(hbar . @var{n})} (a horizontal bar @var{n} | |
1303 | pixels 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}), | |
1311 | or add the line @code{(blink-cursor-mode 0)} to your init file. | |
1312 | Alternatively, you can change how the cursor looks when it ``blinks | |
1313 | off'' by customizing the list variable @code{blink-cursor-alist}. | |
1314 | Each 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 | |
1317 | cursor types described above), then it is displayed as @var{off-type} | |
1318 | when 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 |
1323 | the cursor is positioned over such a character, it is normally drawn | |
1324 | with the default character width. You can make the cursor stretch to | |
1325 | cover 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 | |
1331 | non-blinking hollow box. (For a bar cursor, it instead appears as a | |
1332 | thinner bar.) To turn off cursors in non-selected windows, change the | |
1333 | variable @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 |
1339 | minor mode that highlights the line containing point. Use @kbd{M-x | |
0015d677 RS |
1340 | hl-line-mode} to enable or disable it in the current buffer. @kbd{M-x |
1341 | global-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}), |
1349 | Emacs can display long lines by @dfn{truncation}. This means that all | |
1350 | the characters that do not fit in the width of the screen or window do | |
1351 | not appear at all. On graphical displays, a small straight arrow in | |
1352 | the fringe indicates truncation at either end of the line. On | |
1353 | text-only terminals, this is indicated with @samp{$} signs in the | |
1354 | leftmost 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 | |
1360 | truncation for a particular buffer with the command @kbd{M-x | |
1361 | toggle-truncate-lines}. This works by locally changing the variable | |
1362 | @code{truncate-lines}. If that variable is non-@code{nil}, long lines | |
1363 | are truncated; if it is @code{nil}, they are continued onto multiple | |
1364 | screen lines. Setting the variable @code{truncate-lines} in any way | |
1365 | makes it local to the current buffer; until that time, the default | |
939db9ac | 1366 | value, 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 | |
1370 | line 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 | |
1379 | more screen lines, like in ordinary line continuation. However, Emacs | |
1380 | attempts to wrap the line at word boundaries near the right window | |
1381 | edge. This makes the text easier to read, as wrapping does not occur | |
1382 | in 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. | |
1388 | To turn on Visual Line mode in the current buffer, type @kbd{M-x | |
1389 | visual-line-mode}; repeating this command turns it off. You can also | |
1390 | turn on Visual Line mode using the menu bar: in the Options menu, | |
1391 | select the @samp{Line Wrapping in this Buffer} submenu, followed by | |
1392 | the @samp{Word Wrap (Visual Line Mode)} menu item. While Visual Line | |
1393 | mode is enabled, the mode-line shows the string @samp{wrap} in the | |
1394 | mode display. The command @kbd{M-x global-visual-line-mode} toggles | |
1395 | Visual 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 | |
1402 | instead of logical lines: @kbd{C-a} (@code{beginning-of-visual-line}) | |
1403 | moves 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 |
1406 | screen line. |
1407 | ||
1408 | To move by logical lines, use the commands @kbd{M-x | |
1409 | next-logical-line} and @kbd{M-x previous-logical-line}. These move | |
1410 | point to the next logical line and the previous logical line | |
1411 | respectively, regardless of whether Visual Line mode is enabled. If | |
1412 | you use these commands frequently, it may be convenient to assign key | |
1413 | bindings to them. @xref{Init Rebinding}. | |
458db4b6 CY |
1414 | |
1415 | By default, word-wrapped lines do not display fringe indicators. | |
1416 | Visual Line mode is often used to edit files that contain many long | |
1417 | logical lines, so having a fringe indicator for each wrapped line | |
1418 | would be visually distracting. You can change this by customizing the | |
1419 | variable @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 |
1425 | of 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 | |
1429 | to make the whole screen blink when it would normally make an audible bell | |
1430 | sound. This variable has no effect if your terminal does not have a way | |
1431 | to make the screen blink. | |
80174a97 | 1432 | |
9d2908a6 RS |
1433 | @vindex echo-keystrokes |
1434 | The variable @code{echo-keystrokes} controls the echoing of multi-character | |
1435 | keys; its value is the number of seconds of pause required to cause echoing | |
1436 | to start, or zero, meaning don't echo at all. The value takes effect when | |
bfd779dd | 1437 | there 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 |
1444 | hourglass 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 | |
1447 | time'' 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 | |
1451 | invisible each time you type a character to insert text, to prevent it | |
1452 | from obscuring the text. (To be precise, the hiding occurs when you | |
1453 | type a ``self-inserting'' character. @xref{Inserting Text}.) Moving | |
1454 | the mouse pointer makes it visible again. To disable this feature, | |
1455 | set 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} | |
1460 | determines the minimum distance between the baseline and underline, in | |
1461 | pixels, for underlined text. By default, the value is 1; increasing | |
1462 | it may improve the legibility of underlined text for certain fonts. | |
1463 | (However, Emacs will never draw the underline below the current line | |
1464 | area.) The variable @code{x-underline-at-descent-line} determines how | |
1465 | to draw underlined text. The default is @code{nil}, which means to | |
1466 | draw 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 | |
1468 | descent line. | |
099bfef9 | 1469 | |
9d2908a6 | 1470 | @vindex overline-margin |
b4a1a8b2 CY |
1471 | The variable @code{overline-margin} specifies the vertical position |
1472 | of an overline above the text, including the height of the overline | |
1473 | itself, 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 | |
1477 | result in text that is hard to read. Call the function | |
1478 | @code{tty-suppress-bold-inverse-default-colors} with a non-@code{nil} | |
1479 | argument to suppress the effect of bold-face in this case. |