Commit | Line | Data |
---|---|---|
6bf7aab6 | 1 | @c This is part of the Emacs manual. |
70c88b57 | 2 | @c Copyright (C) 1985, 86, 87, 93-95, 97, 99, 2000 Free Software Foundation, Inc. |
6bf7aab6 DL |
3 | @c See file emacs.texi for copying conditions. |
4 | @node Frames, International, Windows, Top | |
5 | @chapter Frames and X Windows | |
6 | @cindex frames | |
7 | ||
8 | When using the X Window System, you can create multiple windows at the | |
9 | X level in a single Emacs session. Each X window that belongs to Emacs | |
10 | displays a @dfn{frame} which can contain one or several Emacs windows. | |
11 | A frame initially contains a single general-purpose Emacs window which | |
12 | you can subdivide vertically or horizontally into smaller windows. A | |
13 | frame normally contains its own echo area and minibuffer, but you can | |
14 | make frames that don't have these---they use the echo area and | |
15 | minibuffer of another frame. | |
16 | ||
17 | Editing you do in one frame also affects the other frames. For | |
18 | instance, if you put text in the kill ring in one frame, you can yank it | |
19 | in another frame. If you exit Emacs through @kbd{C-x C-c} in one frame, | |
20 | it terminates all the frames. To delete just one frame, use @kbd{C-x 5 | |
21 | 0}. | |
22 | ||
23 | To avoid confusion, we reserve the word ``window'' for the | |
24 | subdivisions that Emacs implements, and never use it to refer to a | |
25 | frame. | |
26 | ||
27 | Emacs compiled for MS-DOS emulates some aspects of the window system | |
28 | so that you can use many of the features described in this chapter. | |
29 | @xref{MS-DOS Input}, for more information. | |
30 | ||
70c88b57 DL |
31 | @cindex MS Windows |
32 | Emacs compiled for MS Windows mostly supports the same features as | |
33 | under X. | |
34 | ||
35 | Features which rely on text in multiple faces (such as Font Lock mode) | |
36 | will also work on non-windowed terminals that can display more than one | |
37 | face, whether by colors or underlining and emboldening, such as the | |
38 | Linux console. Emacs determines automatically whether the terminal has | |
39 | such support. | |
40 | ||
6bf7aab6 DL |
41 | @menu |
42 | * Mouse Commands:: Moving, cutting, and pasting, with the mouse. | |
43 | * Secondary Selection:: Cutting without altering point and mark. | |
44 | * Mouse References:: Using the mouse to select an item from a list. | |
45 | * Menu Mouse Clicks:: Mouse clicks that bring up menus. | |
46 | * Mode Line Mouse:: Mouse clicks on the mode line. | |
47 | * Speedbar:: How to make and use a speedbar frame. | |
48 | * Creating Frames:: Creating additional Emacs frames with various contents. | |
49 | * Multiple Displays:: How one Emacs job can talk to several displays. | |
50 | * Special Buffer Frames:: You can make certain buffers have their own frames. | |
51 | * Frame Parameters:: Changing the colors and other modes of frames. | |
52 | * Scroll Bars:: How to enable and disable scroll bars; how to use them. | |
70c88b57 | 53 | * Wheeled Mice:: Using mouse wheels for scrolling. |
6bf7aab6 | 54 | * Menu Bars:: Enabling and disabling the menu bar. |
70c88b57 DL |
55 | @c * Tool Bars:: Enabling and disabling the tool bar. |
56 | * Dialog Boxes:: Controlling use of dialog boxes. | |
6bf7aab6 DL |
57 | * Faces:: How to change the display style using faces. |
58 | * Font Lock:: Minor mode for syntactic highlighting using faces. | |
59 | * Support Modes:: Font Lock support modes make Font Lock faster. | |
60 | * Highlight Changes:: Using colors to show where you changed the buffer. | |
70c88b57 DL |
61 | * Trailing Whitespace:: Showing possibly-spurious trailing whitespace. |
62 | * Tooltips:: Showing `tooltips', AKA `ballon help' for active text. | |
63 | * Misc X:: Iconifying and deleting frames. | |
6bf7aab6 | 64 | * Non-Window Terminals:: Multiple frames on terminals that show only one. |
70c88b57 | 65 | * XTerm Mouse:: Using the mouse in an XTerm terminal emulator. |
6bf7aab6 DL |
66 | @end menu |
67 | ||
68 | @node Mouse Commands | |
69 | @section Mouse Commands for Editing | |
70 | @cindex mouse buttons (what they do) | |
71 | ||
72 | The mouse commands for selecting and copying a region are mostly | |
73 | compatible with the @code{xterm} program. You can use the same mouse | |
74 | commands for copying between Emacs and other X client programs. | |
75 | ||
76 | @kindex DELETE | |
77 | If you select a region with any of these mouse commands, and then | |
78 | immediately afterward type the @key{DELETE} function key, it deletes the | |
79 | region that you selected. The @key{BACKSPACE} function key and the | |
80 | ASCII character @key{DEL} do not do this; if you type any other key | |
81 | in between the mouse command and @key{DELETE}, it does not do this. | |
82 | ||
83 | @findex mouse-set-region | |
84 | @findex mouse-set-point | |
85 | @findex mouse-yank-at-click | |
86 | @findex mouse-save-then-click | |
87 | @kindex Mouse-1 | |
88 | @kindex Mouse-2 | |
89 | @kindex Mouse-3 | |
90 | @table @kbd | |
91 | @item Mouse-1 | |
92 | Move point to where you click (@code{mouse-set-point}). | |
93 | This is normally the left button. | |
94 | ||
95 | @item Drag-Mouse-1 | |
96 | Set the region to the text you select by dragging, and copy it to the | |
97 | kill ring (@code{mouse-set-region}). You can specify both ends of the | |
98 | region with this single command. | |
99 | ||
100 | @vindex mouse-scroll-min-lines | |
101 | If you move the mouse off the top or bottom of the window while | |
102 | dragging, the window scrolls at a steady rate until you move the mouse | |
103 | back into the window. This way, you can select regions that don't fit | |
104 | entirely on the screen. The number of lines scrolled per step depends | |
105 | on how far away from the window edge the mouse has gone; the variable | |
106 | @code{mouse-scroll-min-lines} specifies a minimum step size. | |
107 | ||
108 | @item Mouse-2 | |
109 | Yank the last killed text, where you click (@code{mouse-yank-at-click}). | |
110 | This is normally the middle button. | |
111 | ||
112 | @item Mouse-3 | |
113 | This command, @code{mouse-save-then-kill}, has several functions | |
114 | depending on where you click and the status of the region. | |
115 | ||
116 | The most basic case is when you click @kbd{Mouse-1} in one place and | |
117 | then @kbd{Mouse-3} in another. This selects the text between those two | |
118 | positions as the region. It also copies the new region to the kill | |
119 | ring, so that you can copy it to someplace else. | |
120 | ||
121 | If you click @kbd{Mouse-1} in the text, scroll with the scroll bar, and | |
122 | then click @kbd{Mouse-3}, it remembers where point was before scrolling | |
123 | (where you put it with @kbd{Mouse-1}), and uses that position as the | |
124 | other end of the region. This is so that you can select a region that | |
125 | doesn't fit entirely on the screen. | |
126 | ||
127 | More generally, if you do not have a highlighted region, @kbd{Mouse-3} | |
128 | selects the text between point and the click position as the region. It | |
129 | does this by setting the mark where point was, and moving point to where | |
130 | you click. | |
131 | ||
132 | If you have a highlighted region, or if the region was set just before | |
133 | by dragging button 1, @kbd{Mouse-3} adjusts the nearer end of the region | |
134 | by moving it to where you click. The adjusted region's text also | |
135 | replaces the old region's text in the kill ring. | |
136 | ||
137 | If you originally specified the region using a double or triple | |
138 | @kbd{Mouse-1}, so that the region is defined to consist of entire words | |
139 | or lines, then adjusting the region with @kbd{Mouse-3} also proceeds by | |
140 | entire words or lines. | |
141 | ||
142 | If you use @kbd{Mouse-3} a second time consecutively, at the same place, | |
143 | that kills the region already selected. | |
144 | ||
145 | @item Double-Mouse-1 | |
146 | This key sets the region around the word which you click on. If you | |
147 | click on a character with ``symbol'' syntax (such as underscore, in C | |
148 | mode), it sets the region around the symbol surrounding that character. | |
149 | ||
150 | If you click on a character with open-parenthesis or close-parenthesis | |
151 | syntax, it sets the region around the parenthetical grouping (sexp) | |
152 | which that character starts or ends. If you click on a character with | |
153 | string-delimiter syntax (such as a singlequote or doublequote in C), it | |
154 | sets the region around the string constant (using heuristics to figure | |
155 | out whether that character is the beginning or the end of it). | |
156 | ||
157 | @item Double-Drag-Mouse-1 | |
158 | This key selects a region made up of the words you drag across. | |
159 | ||
160 | @item Triple-Mouse-1 | |
161 | This key sets the region around the line you click on. | |
162 | ||
163 | @item Triple-Drag-Mouse-1 | |
164 | This key selects a region made up of the lines you drag across. | |
165 | @end table | |
166 | ||
167 | The simplest way to kill text with the mouse is to press @kbd{Mouse-1} | |
168 | at one end, then press @kbd{Mouse-3} twice at the other end. | |
169 | @xref{Killing}. To copy the text into the kill ring without deleting it | |
170 | from the buffer, press @kbd{Mouse-3} just once---or just drag across the | |
171 | text with @kbd{Mouse-1}. Then you can copy it elsewhere by yanking it. | |
172 | ||
173 | @vindex mouse-yank-at-point | |
174 | To yank the killed or copied text somewhere else, move the mouse there | |
175 | and press @kbd{Mouse-2}. @xref{Yanking}. However, if | |
176 | @code{mouse-yank-at-point} is non-@code{nil}, @kbd{Mouse-2} yanks at | |
177 | point. Then it does not matter where you click, or even which of the | |
178 | frame's windows you click on. The default value is @code{nil}. This | |
179 | variable also affects yanking the secondary selection. | |
180 | ||
181 | @cindex cutting and X | |
182 | @cindex pasting and X | |
183 | @cindex X cutting and pasting | |
184 | To copy text to another X window, kill it or save it in the kill ring. | |
185 | Under X, this also sets the @dfn{primary selection}. Then use the | |
186 | ``paste'' or ``yank'' command of the program operating the other window | |
187 | to insert the text from the selection. | |
188 | ||
189 | To copy text from another X window, use the ``cut'' or ``copy'' command | |
190 | of the program operating the other window, to select the text you want. | |
191 | Then yank it in Emacs with @kbd{C-y} or @kbd{Mouse-2}. | |
192 | ||
193 | These cutting and pasting commands also work on MS-Windows. | |
194 | ||
195 | @cindex primary selection | |
196 | @cindex cut buffer | |
197 | @cindex selection, primary | |
198 | @vindex x-cut-buffer-max | |
199 | When Emacs puts text into the kill ring, or rotates text to the front | |
200 | of the kill ring, it sets the @dfn{primary selection} in the X server. | |
201 | This is how other X clients can access the text. Emacs also stores the | |
202 | text in the cut buffer, but only if the text is short enough | |
203 | (@code{x-cut-buffer-max} specifies the maximum number of characters); | |
204 | putting long strings in the cut buffer can be slow. | |
205 | ||
206 | The commands to yank the first entry in the kill ring actually check | |
207 | first for a primary selection in another program; after that, they check | |
208 | for text in the cut buffer. If neither of those sources provides text | |
209 | to yank, the kill ring contents are used. | |
210 | ||
211 | @node Secondary Selection | |
212 | @section Secondary Selection | |
213 | @cindex secondary selection | |
214 | ||
215 | The @dfn{secondary selection} is another way of selecting text using | |
216 | X. It does not use point or the mark, so you can use it to kill text | |
217 | without setting point or the mark. | |
218 | ||
219 | @table @kbd | |
220 | @findex mouse-set-secondary | |
221 | @kindex M-Drag-Mouse-1 | |
222 | @item M-Drag-Mouse-1 | |
223 | Set the secondary selection, with one end at the place where you press | |
224 | down the button, and the other end at the place where you release it | |
225 | (@code{mouse-set-secondary}). The highlighting appears and changes as | |
226 | you drag. | |
227 | ||
228 | If you move the mouse off the top or bottom of the window while | |
229 | dragging, the window scrolls at a steady rate until you move the mouse | |
230 | back into the window. This way, you can mark regions that don't fit | |
231 | entirely on the screen. | |
232 | ||
233 | @findex mouse-start-secondary | |
234 | @kindex M-Mouse-1 | |
235 | @item M-Mouse-1 | |
236 | Set one endpoint for the @dfn{secondary selection} | |
237 | (@code{mouse-start-secondary}). | |
238 | ||
239 | @findex mouse-secondary-save-then-kill | |
240 | @kindex M-Mouse-3 | |
241 | @item M-Mouse-3 | |
242 | Make a secondary selection, using the place specified with @kbd{M-Mouse-1} | |
243 | as the other end (@code{mouse-secondary-save-then-kill}). A second click | |
244 | at the same place kills the secondary selection just made. | |
245 | ||
246 | @findex mouse-yank-secondary | |
247 | @kindex M-Mouse-2 | |
248 | @item M-Mouse-2 | |
249 | Insert the secondary selection where you click | |
250 | (@code{mouse-yank-secondary}). This places point at the end of the | |
251 | yanked text. | |
252 | @end table | |
253 | ||
254 | Double or triple clicking of @kbd{M-Mouse-1} operates on words and | |
255 | lines, much like @kbd{Mouse-1}. | |
256 | ||
257 | If @code{mouse-yank-at-point} is non-@code{nil}, @kbd{M-Mouse-2} | |
258 | yanks at point. Then it does not matter precisely where you click; all | |
259 | that matters is which window you click on. @xref{Mouse Commands}. | |
260 | ||
261 | @node Mouse References | |
262 | @section Following References with the Mouse | |
263 | @kindex Mouse-2 @r{(selection)} | |
264 | ||
265 | Some Emacs buffers display lists of various sorts. These include | |
266 | lists of files, of buffers, of possible completions, of matches for | |
267 | a pattern, and so on. | |
268 | ||
269 | Since yanking text into these buffers is not very useful, most of them | |
270 | define @kbd{Mouse-2} specially, as a command to use or view the item you | |
271 | click on. | |
272 | ||
273 | For example, if you click @kbd{Mouse-2} on a file name in a Dired | |
274 | buffer, you visit that file. If you click @kbd{Mouse-2} on an error | |
275 | message in the @samp{*Compilation*} buffer, you go to the source code | |
276 | for that error message. If you click @kbd{Mouse-2} on a completion in | |
277 | the @samp{*Completions*} buffer, you choose that completion. | |
278 | ||
279 | You can usually tell when @kbd{Mouse-2} has this special sort of | |
280 | meaning because the sensitive text highlights when you move the mouse | |
281 | over it. | |
282 | ||
283 | @node Menu Mouse Clicks | |
284 | @section Mouse Clicks for Menus | |
285 | ||
286 | Mouse clicks modified with the @key{CTRL} and @key{SHIFT} keys | |
287 | bring up menus. | |
288 | ||
289 | @kindex C-Mouse-3 | |
290 | @table @kbd | |
291 | @item C-Mouse-1 | |
292 | This menu is for selecting a buffer. | |
293 | ||
294 | @item C-Mouse-2 | |
295 | This menu is for specifying faces and other text properties | |
296 | for editing formatted text. @xref{Formatted Text}. | |
297 | ||
298 | @item C-Mouse-3 | |
299 | This menu is mode-specific. For most modes, this menu has the same | |
300 | items as all the mode-specific menu-bar menus put together. Some modes | |
301 | may specify a different menu for this button.@footnote{Some systems use | |
302 | @kbd{Mouse-3} for a mode-specific menu. We took a survey of users, and | |
303 | found they preferred to keep @kbd{Mouse-3} for selecting and killing | |
304 | regions. Hence the decision to use @kbd{C-Mouse-3} for this menu.} | |
305 | ||
306 | @item S-mouse-1 | |
307 | This menu is for specifying the frame's principal font. | |
308 | @end table | |
309 | ||
310 | @node Mode Line Mouse | |
311 | @section Mode Line Mouse Commands | |
312 | ||
313 | You can use mouse clicks on window mode lines to select and manipulate | |
314 | windows. | |
315 | ||
316 | @table @kbd | |
317 | @item Mouse-1 | |
318 | @kbd{Mouse-1} on a mode line selects the window above. By dragging | |
319 | @kbd{Mouse-1} on the mode line, you can move it, thus changing the | |
320 | height of the windows above and below. | |
321 | ||
322 | @item Mouse-2 | |
323 | @kbd{Mouse-2} on a mode line expands that window to fill its frame. | |
324 | ||
325 | @item Mouse-3 | |
326 | @kbd{Mouse-3} on a mode line deletes the window above. | |
327 | ||
328 | @item C-Mouse-2 | |
329 | @kbd{C-Mouse-2} on a mode line splits the window above | |
330 | horizontally, above the place in the mode line where you click. | |
331 | @end table | |
332 | ||
333 | @kbd{C-Mouse-2} on a scroll bar splits the corresponding window | |
334 | vertically. @xref{Split Window}. | |
335 | ||
70c88b57 DL |
336 | The commands above apply to areas of the mode line which do not have |
337 | mouse bindings of their own. Normally some areas, such as those | |
338 | displaying the buffer name and the major mode name, have their own mouse | |
339 | bindings. Help on these bindings is echoed when the mouse is positioned | |
340 | over them. | |
341 | ||
6bf7aab6 DL |
342 | @node Creating Frames |
343 | @section Creating Frames | |
344 | @cindex creating frames | |
345 | ||
346 | @kindex C-x 5 | |
347 | The prefix key @kbd{C-x 5} is analogous to @kbd{C-x 4}, with parallel | |
348 | subcommands. The difference is that @kbd{C-x 5} commands create a new | |
349 | frame rather than just a new window in the selected frame (@pxref{Pop | |
350 | Up Window}). If an existing visible or iconified frame already displays | |
351 | the requested material, these commands use the existing frame, after | |
352 | raising or deiconifying as necessary. | |
353 | ||
354 | The various @kbd{C-x 5} commands differ in how they find or create the | |
355 | buffer to select: | |
356 | ||
357 | @table @kbd | |
358 | @item C-x 5 2 | |
359 | @kindex C-x 5 2 | |
360 | @findex make-frame-command | |
361 | Create a new frame (@code{make-frame-command}). | |
362 | @item C-x 5 b @var{bufname} @key{RET} | |
363 | Select buffer @var{bufname} in another frame. This runs | |
364 | @code{switch-to-buffer-other-frame}. | |
365 | @item C-x 5 f @var{filename} @key{RET} | |
366 | Visit file @var{filename} and select its buffer in another frame. This | |
367 | runs @code{find-file-other-frame}. @xref{Visiting}. | |
368 | @item C-x 5 d @var{directory} @key{RET} | |
369 | Select a Dired buffer for directory @var{directory} in another frame. | |
370 | This runs @code{dired-other-frame}. @xref{Dired}. | |
371 | @item C-x 5 m | |
372 | Start composing a mail message in another frame. This runs | |
373 | @code{mail-other-frame}. It is the other-frame variant of @kbd{C-x m}. | |
374 | @xref{Sending Mail}. | |
375 | @item C-x 5 . | |
376 | Find a tag in the current tag table in another frame. This runs | |
377 | @code{find-tag-other-frame}, the multiple-frame variant of @kbd{M-.}. | |
378 | @xref{Tags}. | |
379 | @item C-x 5 r @var{filename} @key{RET} | |
380 | @kindex C-x 5 r | |
381 | @findex find-file-read-only-other-frame | |
382 | Visit file @var{filename} read-only, and select its buffer in another | |
383 | frame. This runs @code{find-file-read-only-other-frame}. | |
384 | @xref{Visiting}. | |
385 | @end table | |
386 | ||
387 | @cindex default-frame-alist | |
388 | @cindex initial-frame-alist | |
389 | You can control the appearance of new frames you create by setting the | |
390 | frame parameters in @code{default-frame-alist}. You can use the | |
391 | variable @code{initial-frame-alist} to specify parameters that affect | |
392 | only the initial frame. @xref{Initial Parameters,,, elisp, The Emacs | |
393 | Lisp Reference Manual}, for more information. | |
394 | ||
395 | @cindex font (default) | |
396 | The easiest way to specify the principal font for all your Emacs | |
397 | frames is with an X resource (@pxref{Font X}), but you can also do it by | |
398 | modifying @code{default-frame-alist} to specify the @code{font} | |
399 | parameter, as shown here: | |
400 | ||
401 | @example | |
402 | (add-to-list 'default-frame-alist '(font . "10x20")) | |
403 | @end example | |
404 | ||
405 | @node Speedbar | |
406 | @section Making and Using a Speedbar Frame | |
407 | @cindex speedbar | |
408 | ||
409 | An Emacs frame can have a @dfn{speedbar}, which is a vertical window | |
410 | that serves as a scrollable menu of files you could visit and tags | |
411 | within those files. To create a speedbar, type @kbd{M-x speedbar}; this | |
412 | creates a speedbar window for the selected frame. From then on, you can | |
413 | click on a file name in the speedbar to visit that file in the | |
414 | corresponding Emacs frame, or click on a tag name to jump to that tag in | |
415 | the Emacs frame. | |
416 | ||
417 | Initially the speedbar lists the immediate contents of the current | |
418 | directory, one file per line. Each line also has a box, @samp{[+]} or | |
419 | @samp{<+>}, that you can click on with @kbd{Mouse-2} to ``open up'' the | |
420 | contents of that item. If the line names a directory, opening it adds | |
421 | the contents of that directory to the speedbar display, underneath the | |
422 | directory's own line. If the line lists an ordinary file, opening it up | |
423 | adds a list of the tags in that file to the speedbar display. When a | |
424 | file is opened up, the @samp{[+]} changes to @samp{[-]}; you can click | |
425 | on that box to ``close up'' that file (hide its contents). | |
426 | ||
427 | Some major modes, including Rmail mode, Info, and GUD, have | |
428 | specialized ways of putting useful items into the speedbar for you to | |
429 | select. For example, in Rmail mode, the speedbar shows a list of Rmail | |
430 | files, and lets you move the current message to another Rmail file by | |
431 | clicking on its @samp{<M>} box. | |
432 | ||
433 | A speedbar belongs to one Emacs frame, and always operates on that | |
434 | frame. If you use multiple frames, you can make a speedbar for some or | |
435 | all of the frames; type @kbd{M-x speedbar} in any given frame to make a | |
436 | speedbar for it. | |
437 | ||
438 | @node Multiple Displays | |
439 | @section Multiple Displays | |
440 | @cindex multiple displays | |
441 | ||
442 | A single Emacs can talk to more than one X Windows display. | |
443 | Initially, Emacs uses just one display---the one specified with the | |
444 | @code{DISPLAY} environment variable or with the @samp{--display} option | |
445 | (@pxref{Initial Options}). To connect to another display, use the | |
446 | command @code{make-frame-on-display}: | |
447 | ||
448 | @findex make-frame-on-display | |
449 | @table @kbd | |
450 | @item M-x make-frame-on-display @key{RET} @var{display} @key{RET} | |
451 | Create a new frame on display @var{display}. | |
452 | @end table | |
453 | ||
454 | A single X server can handle more than one screen. When you open | |
455 | frames on two screens belonging to one server, Emacs knows they share a | |
456 | single keyboard, and it treats all the commands arriving from these | |
457 | screens as a single stream of input. | |
458 | ||
459 | When you open frames on different X servers, Emacs makes a separate | |
460 | input stream for each server. This way, two users can type | |
461 | simultaneously on the two displays, and Emacs will not garble their | |
462 | input. Each server also has its own selected frame. The commands you | |
463 | enter with a particular X server apply to that server's selected frame. | |
464 | ||
465 | Despite these features, people using the same Emacs job from different | |
466 | displays can still interfere with each other if they are not careful. | |
467 | For example, if any one types @kbd{C-x C-c}, that exits the Emacs job | |
468 | for all of them! | |
469 | ||
470 | @node Special Buffer Frames | |
471 | @section Special Buffer Frames | |
472 | ||
473 | @vindex special-display-buffer-names | |
474 | You can make certain chosen buffers, for which Emacs normally creates | |
475 | a second window when you have just one window, appear in special frames | |
476 | of their own. To do this, set the variable | |
477 | @code{special-display-buffer-names} to a list of buffer names; any | |
478 | buffer whose name is in that list automatically gets a special frame, | |
479 | when an Emacs command wants to display it ``in another window.'' | |
480 | ||
481 | For example, if you set the variable this way, | |
482 | ||
483 | @example | |
484 | (setq special-display-buffer-names | |
485 | '("*Completions*" "*grep*" "*tex-shell*")) | |
486 | @end example | |
487 | ||
488 | @noindent | |
489 | then completion lists, @code{grep} output and the @TeX{} mode shell | |
490 | buffer get individual frames of their own. These frames, and the | |
491 | windows in them, are never automatically split or reused for any other | |
492 | buffers. They continue to show the buffers they were created for, | |
493 | unless you alter them by hand. Killing the special buffer deletes its | |
494 | frame automatically. | |
495 | ||
496 | @vindex special-display-regexps | |
497 | More generally, you can set @code{special-display-regexps} to a list | |
498 | of regular expressions; then a buffer gets its own frame if its name | |
499 | matches any of those regular expressions. (Once again, this applies only | |
500 | to buffers that normally get displayed for you in a separate window.) | |
501 | ||
502 | @vindex special-display-frame-alist | |
503 | The variable @code{special-display-frame-alist} specifies the frame | |
504 | parameters for these frames. It has a default value, so you don't need | |
505 | to set it. | |
506 | ||
507 | For those who know Lisp, an element of | |
508 | @code{special-display-buffer-names} or @code{special-display-regexps} | |
509 | can also be a list. Then the first element is the buffer name or | |
510 | regular expression; the rest of the list specifies how to create the | |
511 | frame. It can be an association list specifying frame parameter values; | |
512 | these values take precedence over parameter values specified in | |
513 | @code{special-display-frame-alist}. Alternatively, it can have this | |
514 | form: | |
515 | ||
516 | @example | |
517 | (@var{function} @var{args}...) | |
518 | @end example | |
519 | ||
520 | @noindent | |
521 | where @var{function} is a symbol. Then the frame is constructed by | |
522 | calling @var{function}; its first argument is the buffer, and its | |
523 | remaining arguments are @var{args}. | |
524 | ||
525 | An analogous feature lets you specify buffers which should be | |
526 | displayed in the selected window. @xref{Force Same Window}. The | |
527 | same-window feature takes precedence over the special-frame feature; | |
528 | therefore, if you add a buffer name to | |
529 | @code{special-display-buffer-names} and it has no effect, check to see | |
530 | whether that feature is also in use for the same buffer name. | |
531 | ||
532 | @node Frame Parameters | |
533 | @section Setting Frame Parameters | |
534 | @cindex colors | |
535 | @cindex Auto-Raise mode | |
536 | @cindex Auto-Lower mode | |
537 | ||
538 | This section describes commands for altering the display style and | |
539 | window management behavior of the selected frame. | |
540 | ||
541 | @findex set-foreground-color | |
542 | @findex set-background-color | |
543 | @findex set-cursor-color | |
544 | @findex set-mouse-color | |
545 | @findex set-border-color | |
546 | @findex auto-raise-mode | |
547 | @findex auto-lower-mode | |
548 | @table @kbd | |
549 | @item M-x set-foreground-color @key{RET} @var{color} @key{RET} | |
550 | Specify color @var{color} for the foreground of the selected frame. | |
551 | (This also changes the foreground color of the default face.) | |
552 | ||
553 | @item M-x set-background-color @key{RET} @var{color} @key{RET} | |
554 | Specify color @var{color} for the background of the selected frame. | |
555 | (This also changes the background color of the default face.) | |
556 | ||
557 | @item M-x set-cursor-color @key{RET} @var{color} @key{RET} | |
558 | Specify color @var{color} for the cursor of the selected frame. | |
559 | ||
560 | @item M-x set-mouse-color @key{RET} @var{color} @key{RET} | |
561 | Specify color @var{color} for the mouse cursor when it is over the | |
562 | selected frame. | |
563 | ||
564 | @item M-x set-border-color @key{RET} @var{color} @key{RET} | |
565 | Specify color @var{color} for the border of the selected frame. | |
566 | ||
567 | @item M-x list-colors-display | |
568 | Display the defined color names and show what the colors look like. | |
569 | This command is somewhat slow. | |
570 | ||
571 | @item M-x auto-raise-mode | |
572 | Toggle whether or not the selected frame should auto-raise. Auto-raise | |
573 | means that every time you move the mouse onto the frame, it raises the | |
574 | frame. | |
575 | ||
576 | Note that this auto-raise feature is implemented by Emacs itself. Some | |
577 | window managers also implement auto-raise. If you enable auto-raise for | |
578 | Emacs frames in your X window manager, it should work, but it is beyond | |
579 | Emacs's control and therefore @code{auto-raise-mode} has no effect on | |
580 | it. | |
581 | ||
582 | @item M-x auto-lower-mode | |
583 | Toggle whether or not the selected frame should auto-lower. | |
584 | Auto-lower means that every time you move the mouse off the frame, | |
585 | the frame moves to the bottom of the stack of X windows. | |
586 | ||
587 | The command @code{auto-lower-mode} has no effect on auto-lower | |
588 | implemented by the X window manager. To control that, you must use | |
589 | the appropriate window manager features. | |
590 | ||
591 | @findex set-frame-font | |
592 | @item M-x set-frame-font @key{RET} @var{font} @key{RET} | |
593 | @cindex font (principal) | |
594 | Specify font @var{font} as the principal font for the selected frame. | |
595 | The principal font controls several face attributes of the | |
596 | @code{default} face (@pxref{Faces}). For example, if the principal font | |
597 | has a height of 12 pt, all text will be drawn in 12 pt fonts, unless you | |
598 | use another face that specifies a different height. @xref{Font X}, for | |
599 | ways to list the available fonts on your system. | |
600 | ||
601 | @kindex S-Mouse-1 | |
602 | You can also set a frame's principal font through a pop-up menu. | |
603 | Press @kbd{S-Mouse-1} to activate this menu. | |
604 | @end table | |
605 | ||
606 | In Emacs versions that use an X toolkit, the color-setting and | |
607 | font-setting functions don't affect menus and the menu bar, since they | |
608 | are displayed by their own widget classes. To change the appearance of | |
609 | the menus and menu bar, you must use X resources (@pxref{Resources X}). | |
610 | @xref{Colors X}, regarding colors. @xref{Font X}, regarding choice of | |
611 | font. | |
612 | ||
613 | For information on frame parameters and customization, see @ref{Frame | |
614 | Parameters,,, elisp, The Emacs Lisp Reference Manual}. | |
615 | ||
616 | @node Scroll Bars | |
617 | @section Scroll Bars | |
618 | @cindex Scroll Bar mode | |
619 | @cindex mode, Scroll Bar | |
620 | ||
621 | When using X, Emacs normally makes a @dfn{scroll bar} at the left of | |
70c88b57 DL |
622 | each Emacs window.@footnote{Placing it at the left is usually more |
623 | useful with overlapping frames with text starting at the left margin.} | |
624 | The scroll bar runs the height of the window, and shows a moving | |
625 | rectangular inner box which represents the portion of the buffer | |
626 | currently displayed. The entire height of the scroll bar represents the | |
627 | entire length of the buffer. | |
6bf7aab6 DL |
628 | |
629 | You can use @kbd{Mouse-2} (normally, the middle button) in the scroll | |
630 | bar to move or drag the inner box up and down. If you move it to the | |
631 | top of the scroll bar, you see the top of the buffer. If you move it to | |
632 | the bottom of the scroll bar, you see the bottom of the buffer. | |
633 | ||
634 | The left and right buttons in the scroll bar scroll by controlled | |
635 | increments. @kbd{Mouse-1} (normally, the left button) moves the line at | |
636 | the level where you click up to the top of the window. @kbd{Mouse-3} | |
637 | (normally, the right button) moves the line at the top of the window | |
638 | down to the level where you click. By clicking repeatedly in the same | |
639 | place, you can scroll by the same distance over and over. | |
640 | ||
641 | Aside from scrolling, you can also click @kbd{C-Mouse-2} in the scroll | |
642 | bar to split a window vertically. The split occurs on the line where | |
643 | you click. | |
644 | ||
645 | @findex scroll-bar-mode | |
70c88b57 | 646 | @vindex scroll-bar-mode |
6bf7aab6 DL |
647 | You can enable or disable Scroll Bar mode with the command @kbd{M-x |
648 | scroll-bar-mode}. With no argument, it toggles the use of scroll bars. | |
649 | With an argument, it turns use of scroll bars on if and only if the | |
650 | argument is positive. This command applies to all frames, including | |
70c88b57 DL |
651 | frames yet to be created. Customize the option @code{scroll-bar-mode} |
652 | to control the use of scroll bars at startup. You can use it to specify | |
653 | that they are placed at the right of windows if you prefer that. You | |
654 | can use the X resource @samp{verticalScrollBars} to control the initial | |
655 | setting of Scroll Bar mode similarly. @xref{Resources X}. | |
6bf7aab6 DL |
656 | |
657 | @findex toggle-scroll-bar | |
658 | To enable or disable scroll bars for just the selected frame, use the | |
659 | @kbd{M-x toggle-scroll-bar} command. | |
660 | ||
70c88b57 DL |
661 | @node Wheeled Mice |
662 | @section Scrolling With `Wheeled' Mice | |
663 | ||
664 | @cindex mouse wheel | |
665 | @findex mwheel-install | |
666 | Some mice have a `wheel' instead of a third button. You can usually | |
667 | click the wheel to act as @kbd{mouse-3}. You can also use the wheel to | |
668 | scroll windows instead of using the scroll bar or keyboard commands. | |
669 | Use @kbd{M-x mwheel-install} to set up the wheel for scrolling or put | |
670 | @samp{(require 'mwheel)} in your @file{.emacs}. (Support for the wheel | |
671 | depends on the window system generating appropriate events for Emacs.) | |
672 | ||
673 | @vindex mwheel-follow-mouse | |
674 | @vindex mwheel-scroll-amount | |
675 | The variables @code{mwheel-follow-mouse} and @code{mwheel-scroll-amount} | |
676 | determine where and by how much buffers are scrolled. | |
677 | ||
6bf7aab6 DL |
678 | @node Menu Bars |
679 | @section Menu Bars | |
680 | @cindex Menu Bar mode | |
681 | @cindex mode, Menu Bar | |
682 | ||
683 | You can turn display of menu bars on or off with @kbd{M-x | |
684 | menu-bar-mode}. With no argument, this command toggles Menu Bar mode, a | |
685 | minor mode. With an argument, the command turns Menu Bar mode on if the | |
686 | argument is positive, off if the argument is not positive. You can use | |
687 | the X resource @samp{menuBarLines} to control the initial setting of | |
688 | Menu Bar mode. @xref{Resources X}. Expert users often turn off the | |
689 | menu bar, especially on text-only terminals, where this makes one | |
690 | additional line available for text. | |
691 | ||
692 | @xref{Menu Bar}, for information on how to invoke commands with the | |
693 | menu bar. | |
694 | ||
70c88b57 DL |
695 | @c Presumably not useful until we make toolbar items. |
696 | @c @node Tool Bars | |
697 | @c @section Tool Bars | |
698 | @c @cindex Tool Bar mode | |
699 | @c @cindex mode, Tool Bar | |
700 | ||
701 | @c You can turn display of tool bars on or off with @kbd{M-x | |
702 | @c tool-bar-mode}. With no argument, this command toggles Tool Bar mode, a | |
703 | @c minor mode. With an argument, the command turns Tool Bar mode on if the | |
704 | @c argument is positive, off if the argument is not positive. | |
705 | ||
706 | @node Dialog Boxes | |
707 | @section Using Dialog Boxes | |
708 | @cindex dialog boxes | |
709 | ||
710 | @vindex use-dialog-box | |
711 | Certain operations invoked from menus will use a window system dialog | |
712 | box to get information via the mouse if such dialog boxes are supported. | |
713 | This includes yes/no questions and file selection under Motif/LessTif | |
714 | and MS Windows. Customize the option @code{use-dialog-box} to suppress | |
715 | the use of dialog boxes. | |
716 | ||
6bf7aab6 DL |
717 | @node Faces |
718 | @section Using Multiple Typefaces | |
719 | @cindex faces | |
720 | ||
721 | When using Emacs with X, you can set up multiple styles of displaying | |
722 | characters. The aspects of style that you can control are the type | |
723 | font, the foreground color, the background color, and whether to | |
724 | underline. Emacs on MS-DOS supports faces partially by letting you | |
725 | control the foreground and background colors of each face | |
70c88b57 DL |
726 | (@pxref{MS-DOS}). On non-windowed terminals faces are supported to the |
727 | extent the terminal can display them. | |
6bf7aab6 DL |
728 | |
729 | The way you control display style is by defining named @dfn{faces}. | |
730 | Each face can specify a type font, a foreground color, a background | |
731 | color, and an underline flag; but it does not have to specify all of | |
732 | them. Then by specifying the face or faces to use for a given part | |
733 | of the text in the buffer, you control how that text appears. | |
734 | ||
735 | The style of display used for a given character in the text is | |
736 | determined by combining several faces. Any aspect of the display style | |
737 | that isn't specified by overlays or text properties comes from the frame | |
738 | itself. | |
739 | ||
740 | Enriched mode, the mode for editing formatted text, includes several | |
741 | commands and menus for specifying faces. @xref{Format Faces}, for how | |
742 | to specify the font for text in the buffer. @xref{Format Colors}, for | |
743 | how to specify the foreground and background color. | |
744 | ||
745 | To alter the appearance of a face, use the customization buffer. | |
746 | @xref{Face Customization}. You can also use X resources to specify | |
747 | attributes of particular faces (@pxref{Resources X}). | |
748 | ||
749 | @findex list-faces-display | |
750 | To see what faces are currently defined, and what they look like, type | |
751 | @kbd{M-x list-faces-display}. It's possible for a given face to look | |
752 | different in different frames; this command shows the appearance in the | |
753 | frame in which you type it. Here's a list of the standardly defined | |
754 | faces: | |
755 | ||
756 | @table @code | |
757 | @item default | |
758 | This face is used for ordinary text that doesn't specify any other face. | |
759 | @item modeline | |
70c88b57 DL |
760 | This face is used for mode lines. By default, it's drawn with shadows |
761 | for a `raised' effect under X and set up as the inverse of the default | |
762 | face on non-windowed terminals. @xref{Display Vars}. | |
763 | @item header-line | |
764 | Similar to @code{modeline} for a window's header line. | |
6bf7aab6 DL |
765 | @item highlight |
766 | This face is used for highlighting portions of text, in various modes. | |
767 | @item region | |
768 | This face is used for displaying a selected region (when Transient Mark | |
769 | mode is enabled---see below). | |
770 | @item secondary-selection | |
771 | This face is used for displaying a secondary selection (@pxref{Secondary | |
772 | Selection}). | |
773 | @item bold | |
774 | This face uses a bold variant of the default font, if it has one. | |
775 | @item italic | |
776 | This face uses an italic variant of the default font, if it has one. | |
777 | @item bold-italic | |
778 | This face uses a bold italic variant of the default font, if it has one. | |
779 | @item underline | |
780 | This face underlines text. | |
70c88b57 DL |
781 | @item fixed-pitch |
782 | The basic fixed-pitch face. | |
783 | @item fringe | |
784 | The face for the fringes to the left and right of windows under X. | |
785 | @item scroll-bar | |
786 | This face determines the colors of the scroll bar. | |
787 | @item border | |
788 | This face determines the color of the frame border. | |
789 | @item cursor | |
790 | This face determines the color of the cursor. | |
791 | @item mouse | |
792 | This face determines the color of the mouse pointer. | |
793 | @item tool-bar | |
794 | The basic tool-bar face. | |
795 | @item menu | |
796 | This face determines the colors and font of Emacs's menus. Setting the | |
797 | font of LessTif/Motif menus is currently not supported; attempts to set | |
798 | the font are ignored in this case. | |
799 | @item trailing-whitespace | |
800 | The face for highlighting trailing whitespace when | |
801 | @code{show-trailing-whitespace} is non-nil. | |
802 | @item variable-pitch | |
803 | The basic variable-pitch face. | |
6bf7aab6 DL |
804 | @end table |
805 | ||
806 | @cindex @code{region} face | |
807 | When Transient Mark mode is enabled, the text of the region is | |
808 | highlighted when the mark is active. This uses the face named | |
809 | @code{region}; you can control the style of highlighting by changing the | |
810 | style of this face (@pxref{Face Customization}). @xref{Transient Mark}, | |
811 | for more information about Transient Mark mode and activation and | |
812 | deactivation of the mark. | |
813 | ||
814 | One easy way to use faces is to turn on Font Lock mode. This minor | |
815 | mode, which is always local to a particular buffer, arranges to | |
816 | choose faces according to the syntax of the text you are editing. It | |
817 | can recognize comments and strings in most languages; in several | |
818 | languages, it can also recognize and properly highlight various other | |
819 | important constructs. @xref{Font Lock}, for more information about | |
820 | Font Lock mode and syntactic highlighting. | |
821 | ||
822 | You can print out the buffer with the highlighting that appears | |
823 | on your screen using the command @code{ps-print-buffer-with-faces}. | |
70c88b57 | 824 | @xref{PostScript}. |
6bf7aab6 DL |
825 | |
826 | @node Font Lock | |
827 | @section Font Lock mode | |
828 | @cindex Font Lock mode | |
829 | @cindex mode, Font Lock | |
830 | @cindex syntax highlighting | |
70c88b57 | 831 | @cindex syntax coloring |
6bf7aab6 DL |
832 | |
833 | Font Lock mode is a minor mode, always local to a particular | |
834 | buffer, which highlights (or ``fontifies'') using various faces | |
835 | according to the syntax of the text you are editing. It can | |
836 | recognize comments and strings in most languages; in several | |
837 | languages, it can also recognize and properly highlight various other | |
838 | important constructs---for example, names of functions being defined | |
839 | or reserved keywords. | |
840 | ||
841 | @findex font-lock-mode | |
842 | @findex turn-on-font-lock | |
843 | The command @kbd{M-x font-lock-mode} turns Font Lock mode on or off | |
844 | according to the argument, and toggles the mode when it has no argument. | |
845 | The function @code{turn-on-font-lock} unconditionally enables Font Lock | |
846 | mode. This is useful in mode-hook functions. For example, to enable | |
847 | Font Lock mode whenever you edit a C file, you can do this: | |
848 | ||
849 | @example | |
850 | (add-hook 'c-mode-hook 'turn-on-font-lock) | |
851 | @end example | |
852 | ||
853 | @findex global-font-lock-mode | |
70c88b57 | 854 | @vindex global-font-lock-mode |
6bf7aab6 | 855 | To turn on Font Lock mode automatically in all modes which support it, |
70c88b57 DL |
856 | customize the user option @code{global-font-lock-mode} or use the |
857 | function @code{global-font-lock-mode}, like this: | |
6bf7aab6 DL |
858 | |
859 | @example | |
860 | (global-font-lock-mode 1) | |
861 | @end example | |
862 | ||
863 | @kindex M-g M-g | |
864 | @findex font-lock-fontify-block | |
865 | In Font Lock mode, when you edit the text, the highlighting updates | |
866 | automatically in the line that you changed. Most changes don't affect | |
867 | the highlighting of subsequent lines, but occasionally they do. To | |
868 | rehighlight a range of lines, use the command @kbd{M-g M-g} | |
869 | (@code{font-lock-fontify-block}). | |
870 | ||
871 | @vindex font-lock-mark-block-function | |
872 | In certain major modes, @kbd{M-g M-g} refontifies the entire current | |
873 | function. (The variable @code{font-lock-mark-block-function} controls | |
874 | how to find the current function.) In other major modes, @kbd{M-g M-g} | |
875 | refontifies 16 lines above and below point. | |
876 | ||
877 | With a prefix argument @var{n}, @kbd{M-g M-g} refontifies @var{n} | |
878 | lines above and below point, regardless of the mode. | |
879 | ||
880 | To get the full benefit of Font Lock mode, you need to choose a | |
881 | default font which has bold, italic, and bold-italic variants; or else | |
882 | you need to have a color or gray-scale screen. | |
883 | ||
884 | @vindex font-lock-maximum-decoration | |
885 | The variable @code{font-lock-maximum-decoration} specifies the | |
886 | preferred level of fontification, for modes that provide multiple | |
887 | levels. Level 1 is the least amount of fontification; some modes | |
888 | support levels as high as 3. The normal default is ``as high as | |
889 | possible.'' You can specify an integer, which applies to all modes, or | |
890 | you can specify different numbers for particular major modes; for | |
891 | example, to use level 1 for C/C++ modes, and the default level | |
892 | otherwise, use this: | |
893 | ||
894 | @example | |
895 | (setq font-lock-maximum-decoration | |
896 | '((c-mode . 1) (c++-mode . 1))) | |
897 | @end example | |
898 | ||
899 | @vindex font-lock-maximum-size | |
900 | Fontification can be too slow for large buffers, so you can suppress | |
901 | it. The variable @code{font-lock-maximum-size} specifies a buffer size, | |
902 | beyond which buffer fontification is suppressed. | |
903 | ||
904 | @c @w is used below to prevent a bad page-break. | |
905 | @vindex font-lock-beginning-of-syntax-function | |
906 | Comment and string fontification (or ``syntactic'' fontification) | |
907 | relies on analysis of the syntactic structure of the buffer text. For | |
908 | the purposes of speed, some modes including C mode and Lisp mode rely on | |
909 | a special convention: an open-parenthesis in the leftmost column always | |
910 | defines the @w{beginning} of a defun, and is thus always outside any string | |
911 | or comment. (@xref{Defuns}.) If you don't follow this convention, | |
912 | then Font Lock mode can misfontify the text after an open-parenthesis in | |
913 | the leftmost column that is inside a string or comment. | |
914 | ||
915 | The variable @code{font-lock-beginning-of-syntax-function} (always | |
916 | buffer-local) specifies how Font Lock mode can find a position | |
917 | guaranteed to be outside any comment or string. In modes which use the | |
918 | leftmost column parenthesis convention, the default value of the variable | |
919 | is @code{beginning-of-defun}---that tells Font Lock mode to use the | |
920 | convention. If you set this variable to @code{nil}, Font Lock no longer | |
921 | relies on the convention. This avoids incorrect results, but the price | |
922 | is that, in some cases, fontification for a changed text must rescan | |
923 | buffer text from the beginning of the buffer. | |
924 | ||
925 | @findex font-lock-add-keywords | |
926 | Font Lock highlighting patterns already exist for many modes, but you | |
927 | may want to fontify additional patterns. You can use the function | |
928 | @code{font-lock-add-keywords}, to add your own highlighting patterns for | |
929 | a particular mode. For example, to highlight @samp{FIXME:} words in C | |
930 | comments, use this: | |
931 | ||
932 | @example | |
933 | (font-lock-add-keywords | |
934 | 'c-mode | |
935 | '(("\\<\\(FIXME\\):" 1 font-lock-warning-face t))) | |
936 | @end example | |
937 | ||
938 | @node Support Modes | |
939 | @section Font Lock Support Modes | |
940 | ||
941 | Font Lock support modes make Font Lock mode faster for large buffers. | |
942 | There are two support modes: Fast Lock mode and Lazy Lock mode. They | |
943 | use two different methods of speeding up Font Lock mode. | |
944 | ||
945 | @menu | |
946 | * Fast Lock Mode:: Saving font information in files. | |
947 | * Lazy Lock Mode:: Fontifying only text that is actually displayed. | |
70c88b57 | 948 | * JIT Lock Mode:: Like Lazy Lock, but generally faster. |
6bf7aab6 DL |
949 | * Fast or Lazy:: Which support mode is best for you? |
950 | @end menu | |
951 | ||
952 | @node Fast Lock Mode | |
953 | @subsection Fast Lock Mode | |
954 | ||
955 | @cindex Fast Lock mode | |
956 | @cindex mode, Fast Lock | |
957 | To make Font Lock mode faster for buffers visiting large files, you | |
958 | can use Fast Lock mode. Fast Lock mode saves the font information for | |
959 | each file in a separate cache file; each time you visit the file, it | |
960 | rereads the font information from the cache file instead of refontifying | |
961 | the text from scratch. | |
962 | ||
963 | @findex fast-lock-mode | |
964 | The command @kbd{M-x fast-lock-mode} turns Fast Lock mode on or off, | |
965 | according to the argument (with no argument, it toggles). You can also | |
966 | arrange to enable Fast Lock mode whenever you use Font Lock mode, like | |
967 | this: | |
968 | ||
969 | @example | |
970 | (setq font-lock-support-mode 'fast-lock-mode) | |
971 | @end example | |
972 | ||
973 | @vindex fast-lock-minimum-size | |
974 | It is not worth writing a cache file for small buffers. Therefore, | |
975 | the variable @code{fast-lock-minimum-size} specifies a minimum file size | |
976 | for caching font information. | |
977 | ||
978 | @vindex fast-lock-cache-directories | |
979 | The variable @code{fast-lock-cache-directories} specifies where to put | |
980 | the cache files. Its value is a list of directories to try; @code{"."} | |
981 | means the same directory as the file being edited. The default value is | |
982 | @w{@code{("." "~/.emacs-flc")}}, which means to use the same directory if | |
983 | possible, and otherwise the directory @file{~/.emacs-flc}. | |
984 | ||
985 | @vindex fast-lock-save-others | |
986 | The variable @code{fast-lock-save-others} specifies whether Fast Lock | |
987 | mode should save cache files for files that you do not own. A | |
988 | non-@code{nil} value means yes (and that is the default). | |
989 | ||
990 | @node Lazy Lock Mode | |
991 | @subsection Lazy Lock Mode | |
992 | @cindex Lazy Lock mode | |
993 | @cindex mode, Lazy Lock | |
994 | ||
995 | To make Font Lock mode faster for large buffers, you can use Lazy Lock | |
996 | mode to reduce the amount of text that is fontified. In Lazy Lock mode, | |
997 | buffer fontification is demand-driven; it happens to portions of the | |
998 | buffer that are about to be displayed. And fontification of your | |
999 | changes is deferred; it happens only when Emacs has been idle for a | |
1000 | certain short period of time. | |
1001 | ||
1002 | @findex lazy-lock-mode | |
1003 | The command @kbd{M-x lazy-lock-mode} turns Lazy Lock mode on or off, | |
1004 | according to the argument (with no argument, it toggles). You can also | |
1005 | arrange to enable Lazy Lock mode whenever you use Font Lock mode, like | |
1006 | this: | |
1007 | ||
1008 | @example | |
1009 | (setq font-lock-support-mode 'lazy-lock-mode) | |
1010 | @end example | |
1011 | ||
1012 | @vindex lazy-lock-minimum-size | |
1013 | It is not worth avoiding buffer fontification for small buffers. | |
1014 | Therefore, the variable @code{lazy-lock-minimum-size} specifies a | |
1015 | minimum buffer size for demand-driven buffer fontification. Buffers | |
1016 | smaller than that are fontified all at once, as in plain Font Lock mode. | |
1017 | ||
1018 | @vindex lazy-lock-defer-time | |
1019 | When you alter the buffer, Lazy Lock mode defers fontification of the | |
1020 | text you changed. The variable @code{lazy-lock-defer-time} specifies | |
1021 | how many seconds Emacs must be idle before it starts fontifying your | |
1022 | changes. If the value is 0, then changes are fontified immediately, as | |
1023 | in plain Font Lock mode. | |
1024 | ||
1025 | @vindex lazy-lock-defer-on-scrolling | |
1026 | Lazy Lock mode normally fontifies newly visible portions of the buffer | |
1027 | before they are first displayed. However, if the value of | |
1028 | @code{lazy-lock-defer-on-scrolling} is non-@code{nil}, newly visible | |
1029 | text is fontified only when Emacs is idle for | |
1030 | @code{lazy-lock-defer-time} seconds. | |
1031 | ||
1032 | @vindex lazy-lock-defer-contextually | |
1033 | In some modes, including C mode and Emacs Lisp mode, changes in one | |
1034 | line's contents can alter the context for subsequent lines, and thus | |
1035 | change how they ought to be fontified. Ordinarily, you must type | |
1036 | @kbd{M-g M-g} to refontify the subsequent lines. However, if you set | |
1037 | the variable @code{lazy-lock-defer-contextually} to non-@code{nil}, Lazy | |
1038 | Lock mode does this automatically, after @code{lazy-lock-defer-time} | |
1039 | seconds. | |
1040 | ||
1041 | @cindex stealth fontification | |
1042 | When Emacs is idle for a long time, Lazy Lock fontifies additional | |
1043 | portions of the buffer, not yet displayed, in case you will display them | |
1044 | later. This is called @dfn{stealth fontification}. | |
1045 | ||
1046 | @vindex lazy-lock-stealth-time | |
1047 | @vindex lazy-lock-stealth-lines | |
1048 | @vindex lazy-lock-stealth-verbose | |
1049 | The variable @code{lazy-lock-stealth-time} specifies how many seconds | |
1050 | Emacs has to be idle before stealth fontification starts. A value of | |
1051 | @code{nil} means no stealth fontification. The variables | |
1052 | @code{lazy-lock-stealth-lines} and @code{lazy-lock-stealth-verbose} | |
1053 | specify the granularity and verbosity of stealth fontification. | |
1054 | ||
70c88b57 DL |
1055 | @node JIT Lock Mode |
1056 | @subsection JIT Lock Mode | |
1057 | ||
1058 | @findex jit-lock-mode | |
1059 | The command @kbd{M-x lazy-lock-mode} turns JIT Lock mode on or off, | |
1060 | according to the argument (with no argument, it toggles). This support | |
1061 | mode is roughly equivalent to Lazy Lock but is generally faster. It | |
1062 | supports stealth and deferred fontification. | |
1063 | ||
1064 | Font-lock uses @code{jit-lock-mode} as default support mode, so you | |
1065 | don't have to do anything to activate it. | |
1066 | ||
6bf7aab6 DL |
1067 | @node Fast or Lazy |
1068 | @subsection Fast Lock or Lazy Lock? | |
1069 | ||
1070 | Here is a simple guide to help you choose one of the Font Lock support | |
1071 | modes. | |
1072 | ||
1073 | @itemize @bullet | |
1074 | @item | |
1075 | Fast Lock mode intervenes only during file visiting and buffer | |
1076 | killing (and related events); therefore buffer editing and window | |
1077 | scrolling are no faster or slower than in plain Font Lock mode. | |
1078 | ||
1079 | @item | |
1080 | Fast Lock mode is slower at reading a cache file than Lazy Lock | |
1081 | mode is at fontifying a window; therefore Fast Lock mode is slower at | |
1082 | visiting a file than Lazy Lock mode. | |
1083 | ||
1084 | @item | |
1085 | Lazy Lock mode intervenes during window scrolling to fontify text that | |
1086 | scrolls onto the screen; therefore, scrolling is slower than in plain | |
1087 | Font Lock mode. | |
1088 | ||
1089 | @item | |
1090 | Lazy Lock mode doesn't fontify during buffer editing (it defers | |
1091 | fontification of changes); therefore, editing is faster than in plain | |
1092 | Font Lock mode. | |
1093 | ||
1094 | @item | |
1095 | Fast Lock mode can be fooled by a file that is kept under version | |
1096 | control software; therefore buffer fontification may occur even when | |
1097 | a cache file exists for the file. | |
1098 | ||
1099 | @item | |
1100 | Fast Lock mode only works with a buffer visiting a file; Lazy Lock | |
1101 | mode works with any buffer. | |
1102 | ||
1103 | @item | |
1104 | Fast Lock mode generates cache files; Lazy Lock mode does not. | |
1105 | @end itemize | |
1106 | ||
1107 | @vindex font-lock-support-mode | |
1108 | The variable @code{font-lock-support-mode} specifies which of these | |
1109 | support modes to use; for example, to specify that Fast Lock mode is | |
1110 | used for C/C++ modes, and Lazy Lock mode otherwise, set the variable | |
1111 | like this: | |
1112 | ||
1113 | @example | |
1114 | (setq font-lock-support-mode | |
1115 | '((c-mode . fast-lock-mode) (c++-mode . fast-lock-mode) | |
1116 | (t . lazy-lock-mode))) | |
1117 | @end example | |
1118 | ||
1119 | @node Highlight Changes | |
1120 | @section Highlight Changes Mode | |
1121 | ||
1122 | @findex highlight-changes-mode | |
1123 | Use @kbd{M-x highlight-changes-mode} to enable a minor mode | |
1124 | that uses faces (colors, typically) to indicate which parts of | |
1125 | the buffer were changed most recently. | |
1126 | ||
70c88b57 DL |
1127 | @node Trailing Whitespace |
1128 | @section Trailing Whitespace | |
1129 | ||
1130 | @cindex trailing whitespace | |
1131 | @vindex show-trailing-whitespace | |
1132 | The option @code{show-trailing-whitespace} can be customized so that | |
1133 | Emacs displays trailing whitespace in the face | |
1134 | @code{trailing-whitespace}. Trailing whitespace is defined as spaces or | |
1135 | tabs at the end of a line. To avoid busy highlighting when entering new | |
1136 | text, trailing whitespace is not displayed if point is at the end of the | |
1137 | line containing the whitespace. | |
1138 | ||
1139 | @node Tooltips | |
1140 | @section Tooltips (or `Ballon Help') | |
1141 | ||
1142 | @cindex balloon help | |
1143 | @findex tooltip-mode | |
1144 | Tooltips are small X windows displaying a help string at the current | |
1145 | mouse position, typically over text which can be activated with the | |
1146 | mouse or other keys. (This facility is sometimes known as `balloon | |
1147 | help'.) To use them customize the user option. @code{tooltip-mode}. | |
1148 | The customization group @code{tooltip} controls various aspects of their | |
1149 | display. | |
1150 | ||
1151 | ||
6bf7aab6 DL |
1152 | @node Misc X |
1153 | @section Miscellaneous X Window Features | |
1154 | ||
1155 | The following commands let you create, delete and operate on frames: | |
1156 | ||
1157 | @table @kbd | |
1158 | @item C-z | |
1159 | @kindex C-z @r{(X windows)} | |
1160 | @findex iconify-or-deiconify-frame | |
1161 | Iconify the selected Emacs frame (@code{iconify-or-deiconify-frame}). | |
1162 | The normal meaning of @kbd{C-z}, to suspend Emacs, is not useful under a | |
1163 | window system, so it has a different binding in that case. | |
1164 | ||
1165 | If you type this command on an Emacs frame's icon, it deiconifies the frame. | |
1166 | ||
1167 | @item C-x 5 0 | |
1168 | @kindex C-x 5 0 | |
1169 | @findex delete-frame | |
1170 | Delete the selected frame (@code{delete-frame}). This is not allowed if | |
1171 | there is only one frame. | |
1172 | ||
1173 | @item C-x 5 o | |
1174 | @kindex C-x 5 o | |
1175 | @findex other-frame | |
1176 | Select another frame, raise it, and warp the mouse to it so that it | |
1177 | stays selected. If you repeat this command, it cycles through all the | |
1178 | frames on your terminal. | |
1179 | @end table | |
1180 | ||
1181 | @node Non-Window Terminals | |
1182 | @section Non-Window Terminals | |
1183 | @cindex non-window terminals | |
1184 | @cindex single-frame terminals | |
1185 | ||
1186 | If your terminal does not have a window system that Emacs supports, | |
1187 | then it can display only one Emacs frame at a time. However, you can | |
1188 | still create multiple Emacs frames, and switch between them. Switching | |
1189 | frames on these terminals is much like switching between different | |
1190 | window configurations. | |
1191 | ||
1192 | Use @kbd{C-x 5 2} to create a new frame and switch to it; use @kbd{C-x | |
1193 | 5 o} to cycle through the existing frames; use @kbd{C-x 5 0} to delete | |
1194 | the current frame. | |
1195 | ||
1196 | Each frame has a number to distinguish it. If your terminal can | |
1197 | display only one frame at a time, the selected frame's number @var{n} | |
1198 | appears near the beginning of the mode line, in the form | |
1199 | @samp{F@var{n}}. | |
1200 | ||
1201 | @findex set-frame-name | |
1202 | @findex select-frame-by-name | |
1203 | @samp{F@var{n}} is actually the frame's name. You can also specify a | |
1204 | different name if you wish, and you can select a frame by its name. Use | |
1205 | the command @kbd{M-x set-frame-name @key{RET} @var{name} @key{RET}} to | |
1206 | specify a new name for the selected frame, and use @kbd{M-x | |
1207 | select-frame-by-name @key{RET} @var{name} @key{RET}} to select a frame | |
1208 | according to its name. The name you specify appears in the mode line | |
1209 | when the frame is selected. | |
1210 | ||
70c88b57 DL |
1211 | @node XTerm Mouse |
1212 | @section Using a Mouse in Terminal Emulators | |
1213 | ||
1214 | Some terminal emulators under X support mouse clicks in the terminal | |
1215 | window. In a terminal emulator which is compatible with @code{xterm}, | |
1216 | you can use @kbd{M-x xterm-mouse-mode} to enable simple use of the | |
1217 | mouse---only single clicks are supported. The normal @code{xterm} mouse | |
1218 | functionality is still available by holding down the @kbd{SHIFT} key | |
1219 | when you press the mouse button. |