0
|
1
|
|
2 @node Customization, Quitting, Emulation, Top
|
|
3 @chapter Customization
|
|
4 @cindex customization
|
|
5
|
|
6 This chapter talks about various topics relevant to adapting the
|
|
7 behavior of Emacs in minor ways.
|
|
8
|
|
9 All kinds of customization affect only the particular Emacs job that you
|
|
10 do them in. They are completely lost when you kill the Emacs job, and have
|
|
11 no effect on other Emacs jobs you may run at the same time or later. The
|
|
12 only way an Emacs job can affect anything outside of it is by writing a
|
|
13 file; in particular, the only way to make a customization `permanent' is to
|
|
14 put something in your @file{.emacs} file or other appropriate file to do the
|
|
15 customization in each session. @xref{Init File}.
|
|
16
|
|
17 @menu
|
|
18 * Minor Modes:: Each minor mode is one feature you can turn on
|
|
19 independently of any others.
|
|
20 * Variables:: Many Emacs commands examine Emacs variables
|
|
21 to decide what to do; by setting variables,
|
|
22 you can control their functioning.
|
|
23 * Keyboard Macros:: A keyboard macro records a sequence of keystrokes
|
|
24 to be replayed with a single command.
|
|
25 * Key Bindings:: The keymaps say what command each key runs.
|
|
26 By changing them, you can "redefine keys".
|
|
27 * Syntax:: The syntax table controls how words and expressions
|
|
28 are parsed.
|
|
29 * Init File:: How to write common customizations in the @file{.emacs}
|
|
30 file.
|
|
31 * Audible Bell:: Changing how Emacs sounds the bell.
|
|
32 * Faces:: Changing the fonts and colors of a region of text.
|
|
33 * X Resources:: X resources controlling various aspects of the
|
|
34 behavior of XEmacs.
|
|
35 @end menu
|
|
36
|
|
37 @node Minor Modes
|
|
38 @section Minor Modes
|
|
39 @cindex minor modes
|
|
40
|
|
41 @cindex mode line
|
|
42 Minor modes are options which you can use or not. For example, Auto
|
|
43 Fill mode is a minor mode in which @key{SPC} breaks lines between words
|
|
44 as you type. All the minor modes are independent of each other and of
|
|
45 the selected major mode. Most minor modes inform you in the mode line
|
|
46 when they are on; for example, @samp{Fill} in the mode line means that
|
|
47 Auto Fill mode is on.
|
|
48
|
|
49 Append @code{-mode} to the name of a minor mode to get the name of a
|
|
50 command function that turns the mode on or off. Thus, the command to
|
|
51 enable or disable Auto Fill mode is called @kbd{M-x auto-fill-mode}. These
|
|
52 commands are usually invoked with @kbd{M-x}, but you can bind keys to them
|
|
53 if you wish. With no argument, the function turns the mode on if it was
|
|
54 off and off if it was on. This is known as @dfn{toggling}. A positive
|
|
55 argument always turns the mode on, and an explicit zero argument or a
|
|
56 negative argument always turns it off.
|
|
57
|
|
58 @cindex Auto Fill mode
|
|
59 @findex auto-fill-mode
|
|
60 Auto Fill mode allows you to enter filled text without breaking lines
|
|
61 explicitly. Emacs inserts newlines as necessary to prevent lines from
|
|
62 becoming too long. @xref{Filling}.
|
|
63
|
|
64 @cindex Overwrite mode
|
|
65 @findex overwrite-mode
|
|
66 Overwrite mode causes ordinary printing characters to replace existing
|
|
67 text instead of moving it to the right. For example, if point is in
|
|
68 front of the @samp{B} in @samp{FOOBAR}, and you type a @kbd{G} in Overwrite
|
|
69 mode, it changes to @samp{FOOGAR}, instead of @samp{FOOGBAR}.@refill
|
|
70
|
|
71 @cindex Abbrev mode
|
|
72 @findex abbrev-mode
|
|
73 Abbrev mode allows you to define abbreviations that automatically expand
|
|
74 as you type them. For example, @samp{amd} might expand to @samp{abbrev
|
|
75 mode}. @xref{Abbrevs}, for full information.
|
|
76
|
|
77 @node Variables
|
|
78 @section Variables
|
|
79 @cindex variable
|
|
80 @cindex option
|
|
81
|
|
82 A @dfn{variable} is a Lisp symbol which has a value. Variable names
|
|
83 can contain any characters, but by convention they are words separated
|
|
84 by hyphens. A variable can also have a documentation string, which
|
|
85 describes what kind of value it should have and how the value will be
|
|
86 used.
|
|
87
|
|
88 Lisp allows any variable to have any kind of value, but most variables
|
|
89 that Emacs uses require a value of a certain type. Often the value has
|
|
90 to be a string or a number. Sometimes we say that a certain feature is
|
|
91 turned on if a variable is ``non-@code{nil},'' meaning that if the
|
|
92 variable's value is @code{nil}, the feature is off, but the feature is
|
|
93 on for @i{any} other value. The conventional value to turn on the
|
|
94 feature---since you have to pick one particular value when you set the
|
|
95 variable---is @code{t}.
|
|
96
|
|
97 Emacs uses many Lisp variables for internal recordkeeping, as any Lisp
|
|
98 program must, but the most interesting variables for you are the ones that
|
|
99 exist for the sake of customization. Emacs does not (usually) change the
|
|
100 values of these variables; instead, you set the values, and thereby alter
|
|
101 and control the behavior of certain Emacs commands. These variables are
|
|
102 called @dfn{options}. Most options are documented in this manual and
|
|
103 appear in the Variable Index (@pxref{Variable Index}).
|
|
104
|
|
105 One example of a variable which is an option is @code{fill-column}, which
|
|
106 specifies the position of the right margin (as a number of characters from
|
|
107 the left margin) to be used by the fill commands (@pxref{Filling}).
|
|
108
|
|
109 @menu
|
|
110 * Examining:: Examining or setting one variable's value.
|
195
|
111 * Easy Customization:: Convenient and easy customization of variables.
|
0
|
112 * Edit Options:: Examining or editing list of all variables' values.
|
|
113 * Locals:: Per-buffer values of variables.
|
|
114 * File Variables:: How files can specify variable values.
|
|
115 @end menu
|
|
116
|
|
117 @node Examining
|
|
118 @subsection Examining and Setting Variables
|
|
119 @cindex setting variables
|
|
120
|
|
121 @table @kbd
|
|
122 @item C-h v
|
|
123 @itemx M-x describe-variable
|
|
124 Print the value and documentation of a variable.
|
|
125 @findex set-variable
|
|
126 @item M-x set-variable
|
|
127 Change the value of a variable.
|
|
128 @end table
|
|
129
|
|
130 @kindex C-h v
|
|
131 @findex describe-variable
|
|
132 To examine the value of a single variable, use @kbd{C-h v}
|
|
133 (@code{describe-variable}), which reads a variable name using the
|
|
134 minibuffer, with completion. It prints both the value and the
|
|
135 documentation of the variable.
|
|
136
|
|
137 @example
|
|
138 C-h v fill-column @key{RET}
|
|
139 @end example
|
|
140
|
|
141 @noindent
|
|
142 prints something like:
|
|
143
|
|
144 @smallexample
|
|
145 fill-column's value is 75
|
|
146
|
|
147 Documentation:
|
|
148 *Column beyond which automatic line-wrapping should happen.
|
|
149 Automatically becomes local when set in any fashion.
|
|
150 @end smallexample
|
|
151
|
|
152 @cindex option
|
|
153 @noindent
|
|
154 The star at the beginning of the documentation indicates that this variable
|
|
155 is an option. @kbd{C-h v} is not restricted to options; it allows any
|
|
156 variable name.
|
|
157
|
|
158 @findex set-variable
|
|
159 If you know which option you want to set, you can use @kbd{M-x
|
|
160 set-variable} to set it. This prompts for the variable name in the
|
|
161 minibuffer (with completion), and then prompts for a Lisp expression for the
|
|
162 new value using the minibuffer a second time. For example,
|
|
163
|
|
164 @example
|
|
165 M-x set-variable @key{RET} fill-column @key{RET} 75 @key{RET}
|
|
166 @end example
|
|
167
|
|
168 @noindent
|
|
169 sets @code{fill-column} to 75, as if you had executed the Lisp expression
|
|
170 @code{(setq fill-column 75)}.
|
|
171
|
|
172 Setting variables in this way, like all means of customizing Emacs
|
|
173 except where explicitly stated, affects only the current Emacs session.
|
|
174
|
195
|
175 @node Easy Customization
|
|
176 @subsection Easy Customization Interface
|
|
177
|
|
178 @findex customize
|
|
179 @cindex customization buffer
|
|
180 A convenient way to find the user option variables that you want to
|
|
181 change, and then change them, is with @kbd{M-x customize}. This command
|
|
182 creates a @dfn{customization buffer} with which you can browse through
|
|
183 the Emacs user options in a logically organized structure, then edit and
|
|
184 set their values. You can also use the customization buffer to save
|
|
185 settings permanently. (Not all Emacs user options are included in this
|
|
186 structure as of yet, but we are adding the rest.)
|
|
187
|
|
188 @menu
|
|
189 * Groups: Customization Groups.
|
|
190 How options are classified in a structure.
|
|
191 * Changing an Option:: How to edit a value and set an option.
|
|
192 * Face Customization:: How to edit the attributes of a face.
|
|
193 * Specific Customization:: Making a customization buffer for specific
|
|
194 options, faces, or groups.
|
|
195 @end menu
|
|
196
|
|
197 @node Customization Groups
|
|
198 @subsubsection Customization Groups
|
|
199 @cindex customization groups
|
|
200
|
|
201 For customization purposes, user options are organized into
|
|
202 @dfn{groups} to help you find them. Groups are collected into bigger
|
|
203 groups, all the way up to a master group called @code{Emacs}.
|
|
204
|
|
205 @kbd{M-x customize} creates a customization buffer that shows the
|
|
206 top-level @code{Emacs} group and the second-level groups immediately
|
|
207 under it. It looks like this, in part:
|
|
208
|
|
209 @smallexample
|
|
210 /- Emacs group: ---------------------------------------------------\
|
|
211 [State]: visible group members are all at standard settings.
|
|
212 Customization of the One True Editor.
|
|
213 See also [Manual].
|
|
214
|
|
215 Editing group: [Go to Group]
|
|
216 Basic text editing facilities.
|
|
217
|
|
218 External group: [Go to Group]
|
|
219 Interfacing to external utilities.
|
|
220
|
|
221 @var{more second-level groups}
|
|
222
|
|
223 \- Emacs group end ------------------------------------------------/
|
|
224
|
|
225 @end smallexample
|
|
226
|
|
227 @noindent
|
|
228 This says that the buffer displays the contents of the @code{Emacs}
|
|
229 group. The other groups are listed because they are its contents. But
|
|
230 they are listed differently, without indentation and dashes, because
|
|
231 @emph{their} contents are not included. Each group has a single-line
|
|
232 documentation string; the @code{Emacs} group also has a @samp{[State]}
|
|
233 line.
|
|
234
|
|
235 @cindex editable fields (customization buffer)
|
|
236 @cindex active fields (customization buffer)
|
|
237 Most of the text in the customization buffer is read-only, but it
|
|
238 typically includes some @dfn{editable fields} that you can edit. There
|
|
239 are also @dfn{active fields}; this means a field that does something
|
|
240 when you @dfn{invoke} it. To invoke an active field, either click on it
|
|
241 with @kbd{Mouse-1}, or move point to it and type @key{RET}.
|
|
242
|
|
243 For example, the phrase @samp{[Go to Group]} that appears in a
|
|
244 second-level group is an active field. Invoking the @samp{[Go to
|
|
245 Group]} field for a group creates a new customization buffer, which
|
|
246 shows that group and its contents. This field is a kind of hypertext
|
|
247 link to another group.
|
|
248
|
|
249 The @code{Emacs} group does not include any user options itself, but
|
|
250 other groups do. By examining various groups, you will eventually find
|
|
251 the options and faces that belong to the feature you are interested in
|
|
252 customizing. Then you can use the customization buffer to set them.
|
|
253
|
|
254 @findex customize-browse
|
|
255 You can view the structure of customization groups on a larger scale
|
|
256 with @kbd{M-x customize-browse}. This command creates a special kind of
|
|
257 customization buffer which shows only the names of the groups (and
|
|
258 options and faces), and their structure.
|
|
259
|
|
260 In this buffer, you can show the contents of a group by invoking
|
|
261 @samp{[+]}. When the group contents are visible, this button changes to
|
|
262 @samp{[-]}; invoking that hides the group contents.
|
|
263
|
|
264 Each group, option or face name in this buffer has an active field
|
|
265 which says @samp{[Group]}, @samp{[Option]} or @samp{[Face]}. Invoking
|
|
266 that active field creates an ordinary customization buffer showing just
|
|
267 that group and its contents, just that option, or just that face.
|
|
268 This is the way to set values in it.
|
|
269
|
|
270 @node Changing an Option
|
|
271 @subsubsection Changing an Option
|
|
272
|
|
273 Here is an example of what a user option looks like in the
|
|
274 customization buffer:
|
|
275
|
|
276 @smallexample
|
|
277 Kill Ring Max: [Hide] 30
|
|
278 [State]: this option is unchanged from its standard setting.
|
|
279 Maximum length of kill ring before oldest elements are thrown away.
|
|
280 @end smallexample
|
|
281
|
|
282 The text following @samp{[Hide]}, @samp{30} in this case, indicates
|
|
283 the current value of the option. If you see @samp{[Show]} instead of
|
|
284 @samp{[Hide]}, it means that the value is hidden; the customization
|
|
285 buffer initially hides values that take up several lines. Invoke
|
|
286 @samp{[Show]} to show the value.
|
|
287
|
|
288 The line after the option name indicates the @dfn{customization state}
|
|
289 of the option: in the example above, it says you have not changed the
|
|
290 option yet. The word @samp{[State]} at the beginning of this line is
|
|
291 active; you can get a menu of various operations by invoking it with
|
|
292 @kbd{Mouse-1} or @key{RET}. These operations are essential for
|
|
293 customizing the variable.
|
|
294
|
|
295 The line after the @samp{[State]} line displays the beginning of the
|
|
296 option's documentation string. If there are more lines of
|
|
297 documentation, this line ends with @samp{[More]}; invoke this to show
|
|
298 the full documentation string.
|
|
299
|
|
300 To enter a new value for @samp{Kill Ring Max}, move point to the value
|
|
301 and edit it textually. For example, you can type @kbd{M-d}, then insert
|
|
302 another number.
|
|
303
|
|
304 When you begin to alter the text, you will see the @samp{[State]} line
|
|
305 change to say that you have edited the value:
|
|
306
|
|
307 @smallexample
|
|
308 [State]: you have edited the value as text, but not set the option.
|
|
309 @end smallexample
|
|
310
|
|
311 @cindex setting option value
|
|
312 Editing the value does not actually set the option variable. To do
|
|
313 that, you must @dfn{set} the option. To do this, invoke the word
|
|
314 @samp{[State]} and choose @samp{Set for Current Session}.
|
|
315
|
|
316 The state of the option changes visibly when you set it:
|
|
317
|
|
318 @smallexample
|
|
319 [State]: you have set this option, but not saved it for future sessions.
|
|
320 @end smallexample
|
|
321
|
|
322 You don't have to worry about specifying a value that is not valid;
|
|
323 setting the option checks for validity and will not really install an
|
|
324 unacceptable value.
|
|
325
|
|
326 @kindex M-TAB @r{(customization buffer)}
|
|
327 @findex widget-complete
|
|
328 While editing a value or field that is a file name, directory name,
|
|
329 command name, or anything else for which completion is defined, you can
|
|
330 type @kbd{M-@key{TAB}} (@code{widget-complete}) to do completion.
|
|
331
|
|
332 Some options have a small fixed set of possible legitimate values.
|
|
333 These options don't let you edit the value textually. Instead, an
|
|
334 active field @samp{[Value Menu]} appears before the value; invoke this
|
|
335 field to edit the value. For a boolean ``on or off'' value, the active
|
|
336 field says @samp{[Toggle]}, and it changes to the other value.
|
|
337 @samp{[Value Menu]} and @samp{[Toggle]} edit the buffer; the changes
|
|
338 take effect when you use the @samp{Set for Current Session} operation.
|
|
339
|
|
340 Some options have values with complex structure. For example, the
|
|
341 value of @code{load-path} is a list of directories. Here is how it
|
|
342 appears in the customization buffer:
|
|
343
|
|
344 @smallexample
|
|
345 Load Path:
|
|
346 [INS] [DEL] [Current dir?]: /usr/local/share/emacs/19.34.94/site-lisp
|
|
347 [INS] [DEL] [Current dir?]: /usr/local/share/emacs/site-lisp
|
|
348 [INS] [DEL] [Current dir?]: /usr/local/share/emacs/19.34.94/leim
|
|
349 [INS] [DEL] [Current dir?]: /usr/local/share/emacs/19.34.94/lisp
|
|
350 [INS] [DEL] [Current dir?]: /build/emacs/e19/lisp
|
|
351 [INS] [DEL] [Current dir?]: /build/emacs/e19/lisp/gnus
|
|
352 [INS]
|
|
353 [State]: this item has been changed outside the customization buffer.
|
|
354 List of directories to search for files to load....
|
|
355 @end smallexample
|
|
356
|
|
357 @noindent
|
|
358 Each directory in the list appears on a separate line, and each line has
|
|
359 several editable or active fields.
|
|
360
|
|
361 You can edit any of the directory names. To delete a directory from
|
|
362 the list, invoke @samp{[DEL]} on that line. To insert a new directory in
|
|
363 the list, invoke @samp{[INS]} at the point where you want to insert it.
|
|
364
|
|
365 You can also invoke @samp{[Current dir?]} to switch between including
|
|
366 a specific named directory in the path, and including @code{nil} in the
|
|
367 path. (@code{nil} in a search path means ``try the current
|
|
368 directory.'')
|
|
369
|
|
370 @kindex TAB @r{(customization buffer)}
|
|
371 @kindex S-TAB @r{(customization buffer)}
|
|
372 @findex widget-forward
|
|
373 @findex widget-backward
|
|
374 Two special commands, @key{TAB} and @kbd{S-@key{TAB}}, are useful for
|
|
375 moving through the customization buffer. @key{TAB}
|
|
376 (@code{widget-forward}) moves forward to the next active or editable
|
|
377 field; @kbd{S-@key{TAB}} (@code{widget-backward}) moves backward to the
|
|
378 previous active or editable field.
|
|
379
|
|
380 Typing @key{RET} on an editable field also moves forward, just like
|
|
381 @key{TAB}. The reason for this is that people have a tendency to type
|
|
382 @key{RET} when they are finished editing a field. If you have occasion
|
|
383 to insert a newline in an editable field, use @kbd{C-o} or @kbd{C-q
|
|
384 C-j},
|
|
385
|
|
386 @cindex saving option value
|
|
387 Setting the option changes its value in the current Emacs session;
|
|
388 @dfn{saving} the value changes it for future sessions as well. This
|
|
389 works by writing code into your @file{~/.emacs} file so as to set the
|
|
390 option variable again each time you start Emacs. To save the option,
|
|
391 invoke @samp{[State]} and select the @samp{Save for Future Sessions}
|
|
392 operation.
|
|
393
|
|
394 You can also restore the option to its standard value by invoking
|
|
395 @samp{[State]} and selecting the @samp{Reset to Standard Settings}
|
|
396 operation. There are actually three reset operations:
|
|
397
|
|
398 @table @samp
|
|
399 @item Reset
|
|
400 If you have made some modifications and not yet set the option,
|
|
401 this restores the text in the customization buffer to match
|
|
402 the actual value.
|
|
403
|
|
404 @item Reset to Saved
|
|
405 This restores the value of the option to the last saved value,
|
|
406 and updates the text accordingly.
|
|
407
|
|
408 @item Reset to Standard Settings
|
|
409 This sets the option to its standard value, and updates the text
|
|
410 accordingly. This also eliminates any saved value for the option,
|
|
411 so that you will get the standard value in future Emacs sessions.
|
|
412 @end table
|
|
413
|
|
414 The state of a group indicates whether anything in that group has been
|
|
415 edited, set or saved. You can select @samp{Set for Current Session},
|
|
416 @samp{Save for Future Sessions} and the various kinds of @samp{Reset}
|
|
417 operation for the group; these operations on the group apply to all
|
|
418 options in the group and its subgroups.
|
|
419
|
|
420 Near the top of the customization buffer there are two lines
|
|
421 containing several active fields:
|
|
422
|
|
423 @smallexample
|
|
424 [Set] [Save] [Reset] [Reset to Saved] [Reset to Standard] [Done]
|
|
425 @end smallexample
|
|
426
|
|
427 @noindent
|
|
428 Invoking @samp{[Done]} buries this customization buffer. Each of the
|
|
429 other fields performs an operation---set, save or reset---on each of the
|
|
430 items in the buffer that could meaningfully be set, saved or reset.
|
|
431
|
|
432 @node Face Customization
|
|
433 @subsubsection Customizing Faces
|
|
434 @cindex customizing faces
|
|
435 @cindex bold font
|
|
436 @cindex italic font
|
|
437 @cindex fonts and faces
|
|
438
|
|
439 In addition to user options, some customization groups also include
|
|
440 faces. When you show the contents of a group, both the user options and
|
|
441 the faces in the group appear in the customization buffer. Here is an
|
|
442 example of how a face looks:
|
|
443
|
|
444 @smallexample
|
|
445 Custom Changed Face: (sample)
|
|
446 [State]: this face is unchanged from its standard setting.
|
|
447 Face used when the customize item has been changed.
|
|
448 Attributes: [ ] Bold: [toggle] off
|
|
449 [X] Italic: [toggle] on
|
|
450 [ ] Underline: [toggle] off
|
|
451 [ ] Inverse-Video: [toggle] on
|
|
452 [ ] Foreground: black (sample)
|
|
453 [ ] Background: white (sample)
|
|
454 [ ] Stipple:
|
|
455 @end smallexample
|
|
456
|
|
457 Each face attribute has its own line. The @samp{[@var{x}]} field
|
|
458 before the attribute name indicates whether the attribute is
|
|
459 @dfn{enabled}; @samp{X} means that it is. You can enable or disable the
|
|
460 attribute by invoking that field. When the attribute is enabled, you
|
|
461 can change the attribute value in the usual ways.
|
|
462
|
|
463 On a black-and-white display, the colors you can use for the
|
|
464 background are @samp{black}, @samp{white}, @samp{gray}, @samp{gray1},
|
|
465 and @samp{gray3}. Emacs supports these shades of gray by using
|
|
466 background stipple patterns instead of a color.
|
|
467
|
|
468 Setting, saving and resetting a face work like the same operations for
|
|
469 options (@pxref{Changing an Option}).
|
|
470
|
|
471 A face can specify different appearances for different types of
|
|
472 display. For example, a face can make text red on a color display, but
|
|
473 use a bold font on a monochrome display. To specify multiple
|
|
474 appearances for a face, select @samp{Show Display Types} in the menu you
|
|
475 get from invoking @samp{[State]}.
|
|
476
|
|
477 @findex modify-face
|
|
478 Another more basic way to set the attributes of a specific face is
|
|
479 with @kbd{M-x modify-face}. This command reads the name of a face, then
|
|
480 reads the attributes one by one. For the color and stipple attributes,
|
|
481 the attribute's current value is the default---type just @key{RET} if
|
|
482 you don't want to change that attribute. Type @samp{none} if you want
|
|
483 to clear out the attribute.
|
|
484
|
|
485 @node Specific Customization
|
|
486 @subsubsection Customizing Specific Items
|
|
487
|
|
488 Instead of finding the options you want to change by moving down
|
|
489 through the structure of groups, you can specify the particular option,
|
|
490 face or group that you want to customize.
|
|
491
|
|
492 @table @kbd
|
|
493 @item M-x customize-option @key{RET} @var{option} @key{RET}
|
|
494 Set up a customization buffer with just one option, @var{option}.
|
|
495 @item M-x customize-face @key{RET} @var{face} @key{RET}
|
|
496 Set up a customization buffer with just one face, @var{face}.
|
|
497 @item M-x customize-group @key{RET} @var{group} @key{RET}
|
|
498 Set up a customization buffer with just one group, @var{group}.
|
|
499 @item M-x customize-apropos @key{RET} @var{regexp} @key{RET}
|
|
500 Set up a customization buffer with all the options, faces and groups
|
|
501 that match @var{regexp}.
|
|
502 @item M-x customize-saved
|
|
503 Set up a customization buffer containing all options and faces that you
|
|
504 have saved with customization buffers.
|
|
505 @item M-x customize-customized
|
|
506 Set up a customization buffer containing all options and faces that you
|
|
507 have customized but not saved.
|
|
508 @end table
|
|
509
|
|
510 @findex customize-option
|
|
511 If you want to alter a particular user option variable with the
|
|
512 customization buffer, and you know its name, you can use the command
|
|
513 @kbd{M-x customize-option} and specify the option name. This sets up
|
|
514 the customization buffer with just one option---the one that you asked
|
|
515 for. Editing, setting and saving the value work as described above, but
|
|
516 only for the specified option.
|
|
517
|
|
518 @findex customize-face
|
|
519 Likewise, you can modify a specific face, chosen by name, using
|
|
520 @kbd{M-x customize-face}.
|
|
521
|
|
522 @findex customize-group
|
|
523 You can also set up the customization buffer with a specific group,
|
|
524 using @kbd{M-x customize-group}. The immediate contents of the chosen
|
|
525 group, including option variables, faces, and other groups, all appear
|
|
526 as well. However, these subgroups' own contents start out hidden. You
|
|
527 can show their contents in the usual way, by invoking @samp{[Show]}.
|
|
528
|
|
529 @findex customize-apropos
|
|
530 To control more precisely what to customize, you can use @kbd{M-x
|
|
531 customize-apropos}. You specify a regular expression as argument; then
|
|
532 all options, faces and groups whose names match this regular expression
|
|
533 are set up in the customization buffer. If you specify an empty regular
|
|
534 expression, this includes @emph{all} groups, options and faces in the
|
|
535 customization buffer (but that takes a long time).
|
|
536
|
|
537 @findex customize-saved
|
|
538 @findex customize-customized
|
|
539 If you change option values and then decide the change was a mistake,
|
|
540 you can use two special commands to revisit your previous changes. Use
|
|
541 @kbd{customize-saved} to look at the options and faces that you have
|
|
542 saved. Use @kbd{M-x customize-customized} to look at the options and
|
|
543 faces that you have set but not saved.
|
|
544
|
0
|
545 @node Edit Options
|
|
546 @subsection Editing Variable Values
|
|
547
|
|
548 @table @kbd
|
|
549 @item M-x list-options
|
|
550 Display a buffer listing names, values, and documentation of all options.
|
|
551 @item M-x edit-options
|
|
552 Change option values by editing a list of options.
|
|
553 @end table
|
|
554
|
|
555 @findex list-options
|
|
556 @kbd{M-x list-options} displays a list of all Emacs option variables in
|
|
557 an Emacs buffer named @samp{*List Options*}. Each option is shown with its
|
|
558 documentation and its current value. Here is what a portion of it might
|
|
559 look like:
|
|
560
|
|
561 @smallexample
|
|
562 ;; exec-path:
|
|
563 ("." "/usr/local/bin" "/usr/ucb" "/bin" "/usr/bin" "/u2/emacs/etc")
|
|
564 *List of directories to search programs to run in subprocesses.
|
|
565 Each element is a string (directory name)
|
|
566 or nil (try the default directory).
|
|
567 ;;
|
|
568 ;; fill-column:
|
|
569 75
|
|
570 *Column beyond which automatic line-wrapping should happen.
|
|
571 Automatically becomes local when set in any fashion.
|
|
572 ;;
|
|
573 @end smallexample
|
|
574
|
|
575 @findex edit-options
|
|
576 @kbd{M-x edit-options} goes one step further and immediately selects the
|
|
577 @samp{*List Options*} buffer; this buffer uses the major mode Options mode,
|
|
578 which provides commands that allow you to point at an option and change its
|
|
579 value:
|
|
580
|
|
581 @table @kbd
|
|
582 @item s
|
|
583 Set the variable point is in or near to a new value read using the
|
|
584 minibuffer.
|
|
585 @item x
|
|
586 Toggle the variable point is in or near: if the value was @code{nil},
|
|
587 it becomes @code{t}; otherwise it becomes @code{nil}.
|
|
588 @item 1
|
|
589 Set the variable point is in or near to @code{t}.
|
|
590 @item 0
|
|
591 Set the variable point is in or near to @code{nil}.
|
|
592 @item n
|
|
593 @itemx p
|
|
594 Move to the next or previous variable.
|
|
595 @end table
|
|
596
|
|
597 @node Locals
|
|
598 @subsection Local Variables
|
|
599
|
|
600 @table @kbd
|
|
601 @item M-x make-local-variable
|
|
602 Make a variable have a local value in the current buffer.
|
|
603 @item M-x kill-local-variable
|
|
604 Make a variable use its global value in the current buffer.
|
|
605 @item M-x make-variable-buffer-local
|
|
606 Mark a variable so that setting it will make it local to the
|
|
607 buffer that is current at that time.
|
|
608 @end table
|
|
609
|
|
610 @cindex local variables
|
|
611 You can make any variable @dfn{local} to a specific Emacs buffer.
|
|
612 This means that the variable's value in that buffer is independent of
|
|
613 its value in other buffers. A few variables are always local in every
|
|
614 buffer. All other Emacs variables have a @dfn{global} value which is in
|
|
615 effect in all buffers that have not made the variable local.
|
|
616
|
|
617 Major modes always make the variables they set local to the buffer.
|
|
618 This is why changing major modes in one buffer has no effect on other
|
|
619 buffers.
|
|
620
|
|
621 @findex make-local-variable
|
|
622 @kbd{M-x make-local-variable} reads the name of a variable and makes it
|
|
623 local to the current buffer. Further changes in this buffer will not
|
|
624 affect others, and changes in the global value will not affect this
|
|
625 buffer.
|
|
626
|
|
627 @findex make-variable-buffer-local
|
|
628 @cindex per-buffer variables
|
|
629 @kbd{M-x make-variable-buffer-local} reads the name of a variable and
|
|
630 changes the future behavior of the variable so that it automatically
|
|
631 becomes local when it is set. More precisely, once you have marked a
|
|
632 variable in this way, the usual ways of setting the
|
|
633 variable will automatically invoke @code{make-local-variable} first. We
|
|
634 call such variables @dfn{per-buffer} variables.
|
|
635
|
|
636 Some important variables have been marked per-buffer already. They
|
|
637 include @code{abbrev-mode}, @code{auto-fill-function},
|
|
638 @code{case-fold-search}, @code{comment-column}, @code{ctl-arrow},
|
|
639 @code{fill-column}, @code{fill-prefix}, @code{indent-tabs-mode},
|
|
640 @code{left-margin}, @*@code{mode-line-format}, @code{overwrite-mode},
|
|
641 @code{selective-display-ellipses}, @*@code{selective-display},
|
|
642 @code{tab-width}, and @code{truncate-lines}. Some other variables are
|
|
643 always local in every buffer, but they are used for internal
|
|
644 purposes.@refill
|
|
645
|
|
646 Note: the variable @code{auto-fill-function} was formerly named
|
|
647 @code{auto-fill-hook}.
|
|
648
|
|
649 @findex kill-local-variable
|
|
650 If you want a variable to cease to be local to the current buffer,
|
|
651 call @kbd{M-x kill-local-variable} and provide the name of a variable to
|
|
652 the prompt. The global value of the variable
|
|
653 is again in effect in this buffer. Setting the major mode kills all
|
|
654 the local variables of the buffer.
|
|
655
|
|
656 @findex setq-default
|
|
657 To set the global value of a variable, regardless of whether the
|
|
658 variable has a local value in the current buffer, you can use the
|
|
659 Lisp function @code{setq-default}. It works like @code{setq}.
|
|
660 If there is a local value in the current buffer, the local value is
|
|
661 not affected by @code{setq-default}; thus, the new global value may
|
|
662 not be visible until you switch to another buffer, as in the case of:
|
|
663
|
|
664 @example
|
|
665 (setq-default fill-column 75)
|
|
666 @end example
|
|
667
|
|
668 @noindent
|
|
669 @code{setq-default} is the only way to set the global value of a variable
|
|
670 that has been marked with @code{make-variable-buffer-local}.
|
|
671
|
|
672 @findex default-value
|
|
673 Programs can look at a variable's default value with @code{default-value}.
|
|
674 This function takes a symbol as an argument and returns its default value.
|
|
675 The argument is evaluated; usually you must quote it explicitly, as in
|
|
676 the case of:
|
|
677
|
|
678 @example
|
|
679 (default-value 'fill-column)
|
|
680 @end example
|
|
681
|
|
682 @node File Variables
|
|
683 @subsection Local Variables in Files
|
|
684 @cindex local variables in files
|
|
685
|
|
686 A file can contain a @dfn{local variables list}, which specifies the
|
|
687 values to use for certain Emacs variables when that file is edited.
|
|
688 Visiting the file checks for a local variables list and makes each variable
|
|
689 in the list local to the buffer in which the file is visited, with the
|
|
690 value specified in the file.
|
|
691
|
|
692 A local variables list goes near the end of the file, in the last page.
|
|
693 (It is often best to put it on a page by itself.) The local variables list
|
|
694 starts with a line containing the string @samp{Local Variables:}, and ends
|
|
695 with a line containing the string @samp{End:}. In between come the
|
|
696 variable names and values, one set per line, as @samp{@var{variable}:@:
|
|
697 @var{value}}. The @var{value}s are not evaluated; they are used literally.
|
|
698
|
|
699 The line which starts the local variables list does not have to say
|
|
700 just @samp{Local Variables:}. If there is other text before @samp{Local
|
|
701 Variables:}, that text is called the @dfn{prefix}, and if there is other
|
|
702 text after, that is called the @dfn{suffix}. If a prefix or suffix are
|
|
703 present, each entry in the local variables list should have the prefix
|
|
704 before it and the suffix after it. This includes the @samp{End:} line.
|
|
705 The prefix and suffix are included to disguise the local variables list
|
|
706 as a comment so the compiler or text formatter will ignore it.
|
|
707 If you do not need to disguise the local variables list as a comment in
|
|
708 this way, there is no need to include a prefix or a suffix.@refill
|
|
709
|
|
710 Two ``variable'' names are special in a local variables list: a value
|
|
711 for the variable @code{mode} sets the major mode, and a value for the
|
|
712 variable @code{eval} is simply evaluated as an expression and the value
|
|
713 is ignored. These are not real variables; setting them in any other
|
|
714 context does not have the same effect. If @code{mode} is used in a
|
|
715 local variables list, it should be the first entry in the list.
|
|
716
|
|
717 Here is an example of a local variables list:
|
|
718 @example
|
|
719 ;;; Local Variables: ***
|
|
720 ;;; mode:lisp ***
|
|
721 ;;; comment-column:0 ***
|
|
722 ;;; comment-start: ";;; " ***
|
|
723 ;;; comment-end:"***" ***
|
|
724 ;;; End: ***
|
|
725 @end example
|
|
726
|
|
727 Note that the prefix is @samp{;;; } and the suffix is @samp{ ***}.
|
|
728 Note also that comments in the file begin with and end with the same
|
|
729 strings. Presumably the file contains code in a language which is
|
|
730 enough like Lisp for Lisp mode to be useful but in which comments
|
|
731 start and end differently. The prefix and suffix are used in the local
|
|
732 variables list to make the list look like several lines of comments when
|
|
733 the compiler or interpreter for that language reads the file.
|
|
734
|
|
735 The start of the local variables list must be no more than 3000
|
|
736 characters from the end of the file, and must be in the last page if the
|
|
737 file is divided into pages. Otherwise, Emacs will not notice it is
|
|
738 there. The purpose is twofold: a stray @samp{Local Variables:}@: not in
|
|
739 the last page does not confuse Emacs, and Emacs never needs to search a
|
|
740 long file that contains no page markers and has no local variables list.
|
|
741
|
|
742 You may be tempted to turn on Auto Fill mode with a local variable
|
|
743 list. That is inappropriate. Whether you use Auto Fill mode or not is
|
|
744 a matter of personal taste, not a matter of the contents of particular
|
|
745 files. If you want to use Auto Fill, set up major mode hooks with your
|
|
746 @file{.emacs} file to turn it on (when appropriate) for you alone
|
|
747 (@pxref{Init File}). Don't try to use a local variable list that would
|
|
748 impose your taste on everyone working with the file.
|
|
749
|
|
750 XEmacs allows you to specify local variables in the first line
|
|
751 of a file, in addition to specifying them in the @code{Local Variables}
|
|
752 section at the end of a file.
|
|
753
|
2
|
754 If the first line of a file contains two occurrences of @code{`-*-'},
|
|
755 XEmacs uses the information between them to determine what the major
|
|
756 mode and variable settings should be. For example, these are all legal:
|
0
|
757
|
|
758 @example
|
|
759 ;;; -*- mode: emacs-lisp -*-
|
|
760 ;;; -*- mode: postscript; version-control: never -*-
|
|
761 ;;; -*- tags-file-name: "/foo/bar/TAGS" -*-
|
|
762 @end example
|
|
763
|
|
764 For historical reasons, the syntax @code{`-*- modename -*-'} is allowed
|
|
765 as well; for example, you can use:
|
|
766
|
|
767 @example
|
|
768 ;;; -*- emacs-lisp -*-
|
|
769 @end example
|
|
770
|
|
771 @vindex enable-local-variables
|
|
772 The variable @code{enable-local-variables} controls the use of local
|
|
773 variables lists in files you visit. The value can be @code{t},
|
|
774 @code{nil}, or something else. A value of @code{t} means local variables
|
|
775 lists are obeyed; @code{nil} means they are ignored; anything else means
|
|
776 query.
|
|
777
|
|
778 The command @code{M-x normal-mode} always obeys local variables lists
|
|
779 and ignores this variable.
|
|
780
|
|
781 @node Keyboard Macros
|
|
782 @section Keyboard Macros
|
|
783
|
|
784 @cindex keyboard macros
|
|
785 A @dfn{keyboard macro} is a command defined by the user to abbreviate a
|
|
786 sequence of keys. For example, if you discover that you are about to type
|
|
787 @kbd{C-n C-d} forty times, you can speed your work by defining a keyboard
|
|
788 macro to invoke @kbd{C-n C-d} and calling it with a repeat count of forty.
|
|
789
|
|
790 @c widecommands
|
|
791 @table @kbd
|
|
792 @item C-x (
|
|
793 Start defining a keyboard macro (@code{start-kbd-macro}).
|
|
794 @item C-x )
|
|
795 End the definition of a keyboard macro (@code{end-kbd-macro}).
|
|
796 @item C-x e
|
|
797 Execute the most recent keyboard macro (@code{call-last-kbd-macro}).
|
|
798 @item C-u C-x (
|
|
799 Re-execute last keyboard macro, then add more keys to its definition.
|
|
800 @item C-x q
|
|
801 When this point is reached during macro execution, ask for confirmation
|
|
802 (@code{kbd-macro-query}).
|
|
803 @item M-x name-last-kbd-macro
|
|
804 Give a command name (for the duration of the session) to the most
|
|
805 recently defined keyboard macro.
|
|
806 @item M-x insert-kbd-macro
|
|
807 Insert in the buffer a keyboard macro's definition, as Lisp code.
|
|
808 @end table
|
|
809
|
|
810 Keyboard macros differ from other Emacs commands in that they are
|
|
811 written in the Emacs command language rather than in Lisp. This makes it
|
|
812 easier for the novice to write them and makes them more convenient as
|
|
813 temporary hacks. However, the Emacs command language is not powerful
|
|
814 enough as a programming language to be useful for writing anything
|
|
815 general or complex. For such things, Lisp must be used.
|
|
816
|
|
817 You define a keyboard macro by executing the commands which are its
|
|
818 definition. Put differently, as you are defining a keyboard macro, the
|
|
819 definition is being executed for the first time. This way, you see
|
|
820 what the effects of your commands are, and don't have to figure
|
|
821 them out in your head. When you are finished, the keyboard macro is
|
|
822 defined and also has been executed once. You can then execute the same
|
|
823 set of commands again by invoking the macro.
|
|
824
|
|
825 @menu
|
|
826 * Basic Kbd Macro:: Defining and running keyboard macros.
|
|
827 * Save Kbd Macro:: Giving keyboard macros names; saving them in files.
|
|
828 * Kbd Macro Query:: Keyboard macros that do different things each use.
|
|
829 @end menu
|
|
830
|
|
831 @node Basic Kbd Macro
|
|
832 @subsection Basic Use
|
|
833
|
|
834 @kindex C-x (
|
|
835 @kindex C-x )
|
|
836 @kindex C-x e
|
|
837 @findex start-kbd-macro
|
|
838 @findex end-kbd-macro
|
|
839 @findex call-last-kbd-macro
|
|
840 To start defining a keyboard macro, type @kbd{C-x (}
|
|
841 (@code{start-kbd-macro}). From then on, anything you type continues to be
|
|
842 executed, but also becomes part of the definition of the macro. @samp{Def}
|
|
843 appears in the mode line to remind you of what is going on. When you are
|
|
844 finished, the @kbd{C-x )} command (@code{end-kbd-macro}) terminates the
|
|
845 definition, without becoming part of it.
|
|
846
|
|
847 For example,
|
|
848
|
|
849 @example
|
|
850 C-x ( M-f foo C-x )
|
|
851 @end example
|
|
852
|
|
853 @noindent
|
|
854 defines a macro to move forward a word and then insert @samp{foo}.
|
|
855
|
|
856 You can give @kbd{C-x )} a repeat count as an argument, in which case it
|
|
857 repeats the macro that many times right after defining it, but defining
|
|
858 the macro counts as the first repetition (since it is executed as you
|
|
859 define it). If you give @kbd{C-x )} an argument of 4, it executes the
|
|
860 macro immediately 3 additional times. An argument of zero to @kbd{C-x
|
|
861 e} or @kbd{C-x )} means repeat the macro indefinitely (until it gets an
|
|
862 error or you type @kbd{C-g}).
|
|
863
|
|
864 Once you have defined a macro, you can invoke it again with the
|
|
865 @kbd{C-x e} command (@code{call-last-kbd-macro}). You can give the
|
|
866 command a repeat count numeric argument to execute the macro many times.
|
|
867
|
|
868 To repeat an operation at regularly spaced places in the
|
|
869 text, define a macro and include as part of the macro the commands to move
|
|
870 to the next place you want to use it. For example, if you want to change
|
|
871 each line, you should position point at the start of a line, and define a
|
|
872 macro to change that line and leave point at the start of the next line.
|
|
873 Repeating the macro will then operate on successive lines.
|
|
874
|
|
875 After you have terminated the definition of a keyboard macro, you can add
|
|
876 to the end of its definition by typing @kbd{C-u C-x (}. This is equivalent
|
|
877 to plain @kbd{C-x (} followed by retyping the whole definition so far. As
|
|
878 a consequence it re-executes the macro as previously defined.
|
|
879
|
|
880 @node Save Kbd Macro
|
|
881 @subsection Naming and Saving Keyboard Macros
|
|
882
|
|
883 @findex name-last-kbd-macro
|
|
884 To save a keyboard macro for longer than until you define the
|
|
885 next one, you must give it a name using @kbd{M-x name-last-kbd-macro}.
|
|
886 This reads a name as an argument using the minibuffer and defines that name
|
|
887 to execute the macro. The macro name is a Lisp symbol, and defining it in
|
|
888 this way makes it a valid command name for calling with @kbd{M-x} or for
|
|
889 binding a key to with @code{global-set-key} (@pxref{Keymaps}). If you
|
|
890 specify a name that has a prior definition other than another keyboard
|
|
891 macro, Emacs prints an error message and nothing is changed.
|
|
892
|
|
893 @findex insert-kbd-macro
|
|
894 Once a macro has a command name, you can save its definition in a file.
|
|
895 You can then use it in another editing session. First visit the file
|
|
896 you want to save the definition in. Then use the command:
|
|
897
|
|
898 @example
|
|
899 M-x insert-kbd-macro @key{RET} @var{macroname} @key{RET}
|
|
900 @end example
|
|
901
|
|
902 @noindent
|
|
903 This inserts some Lisp code that, when executed later, will define the same
|
|
904 macro with the same definition it has now. You need not understand Lisp
|
|
905 code to do this, because @code{insert-kbd-macro} writes the Lisp code for you.
|
|
906 Then save the file. You can load the file with @code{load-file}
|
|
907 (@pxref{Lisp Libraries}). If the file you save in is your initialization file
|
|
908 @file{~/.emacs} (@pxref{Init File}), then the macro will be defined each
|
|
909 time you run Emacs.
|
|
910
|
|
911 If you give @code{insert-kbd-macro} a prefix argument, it creates
|
|
912 additional Lisp code to record the keys (if any) that you have bound to the
|
|
913 keyboard macro, so that the macro is reassigned the same keys when you
|
|
914 load the file.
|
|
915
|
|
916 @node Kbd Macro Query
|
|
917 @subsection Executing Macros With Variations
|
|
918
|
|
919 @kindex C-x q
|
|
920 @findex kbd-macro-query
|
|
921 You can use @kbd{C-x q} (@code{kbd-macro-query}), to get an effect similar
|
|
922 to that of @code{query-replace}. The macro asks you each time
|
|
923 whether to make a change. When you are defining the macro, type @kbd{C-x
|
|
924 q} at the point where you want the query to occur. During macro
|
|
925 definition, the @kbd{C-x q} does nothing, but when you invoke the macro,
|
|
926 @kbd{C-x q} reads a character from the terminal to decide whether to
|
|
927 continue.
|
|
928
|
|
929 The special answers to a @kbd{C-x q} query are @key{SPC}, @key{DEL},
|
|
930 @kbd{C-d}, @kbd{C-l}, and @kbd{C-r}. Any other character terminates
|
|
931 execution of the keyboard macro and is then read as a command.
|
|
932 @key{SPC} means to continue. @key{DEL} means to skip the remainder of
|
|
933 this repetition of the macro, starting again from the beginning in the
|
|
934 next repetition. @kbd{C-d} means to skip the remainder of this
|
|
935 repetition and cancel further repetition. @kbd{C-l} redraws the frame
|
|
936 and asks you again for a character to specify what to do. @kbd{C-r} enters
|
|
937 a recursive editing level, in which you can perform editing that is not
|
|
938 part of the macro. When you exit the recursive edit using @kbd{C-M-c},
|
|
939 you are asked again how to continue with the keyboard macro. If you
|
|
940 type a @key{SPC} at this time, the rest of the macro definition is
|
|
941 executed. It is up to you to leave point and the text in a state such
|
|
942 that the rest of the macro will do what you want.@refill
|
|
943
|
|
944 @kbd{C-u C-x q}, which is @kbd{C-x q} with a numeric argument, performs a
|
|
945 different function. It enters a recursive edit reading input from the
|
|
946 keyboard, both when you type it during the definition of the macro and
|
|
947 when it is executed from the macro. During definition, the editing you do
|
|
948 inside the recursive edit does not become part of the macro. During macro
|
|
949 execution, the recursive edit gives you a chance to do some particularized
|
|
950 editing. @xref{Recursive Edit}.
|
|
951
|
|
952 @node Key Bindings
|
|
953 @section Customizing Key Bindings
|
|
954
|
|
955 This section deals with the @dfn{keymaps} that define the bindings
|
|
956 between keys and functions, and shows how you can customize these bindings.
|
|
957 @cindex command
|
|
958 @cindex function
|
|
959 @cindex command name
|
|
960
|
|
961 A command is a Lisp function whose definition provides for interactive
|
|
962 use. Like every Lisp function, a command has a function name, which is
|
|
963 a Lisp symbol whose name usually consists of lower case letters and
|
|
964 hyphens.
|
|
965
|
|
966 @menu
|
|
967 * Keymaps:: Definition of the keymap data structure.
|
|
968 Names of Emacs's standard keymaps.
|
|
969 * Rebinding:: How to redefine one key's meaning conveniently.
|
|
970 * Disabling:: Disabling a command means confirmation is required
|
|
971 before it can be executed. This is done to protect
|
|
972 beginners from surprises.
|
|
973 @end menu
|
|
974
|
|
975 @node Keymaps
|
|
976 @subsection Keymaps
|
|
977 @cindex keymap
|
|
978
|
|
979 @cindex global keymap
|
|
980 @vindex global-map
|
|
981 The bindings between characters and command functions are recorded in
|
|
982 data structures called @dfn{keymaps}. Emacs has many of these. One, the
|
|
983 @dfn{global} keymap, defines the meanings of the single-character keys that
|
|
984 are defined regardless of major mode. It is the value of the variable
|
|
985 @code{global-map}.
|
|
986
|
|
987 @cindex local keymap
|
|
988 @vindex c-mode-map
|
|
989 @vindex lisp-mode-map
|
|
990 Each major mode has another keymap, its @dfn{local keymap}, which
|
|
991 contains overriding definitions for the single-character keys that are
|
|
992 redefined in that mode. Each buffer records which local keymap is
|
|
993 installed for it at any time, and the current buffer's local keymap is
|
|
994 the only one that directly affects command execution. The local keymaps
|
|
995 for Lisp mode, C mode, and many other major modes always exist even when
|
|
996 not in use. They are the values of the variables @code{lisp-mode-map},
|
|
997 @code{c-mode-map}, and so on. For less frequently used major modes, the
|
|
998 local keymap is sometimes constructed only when the mode is used for the
|
|
999 first time in a session, to save space.
|
|
1000
|
|
1001 @cindex minibuffer
|
|
1002 @vindex minibuffer-local-map
|
|
1003 @vindex minibuffer-local-ns-map
|
|
1004 @vindex minibuffer-local-completion-map
|
|
1005 @vindex minibuffer-local-must-match-map
|
|
1006 @vindex repeat-complex-command-map
|
|
1007 @vindex isearch-mode-map
|
|
1008 There are local keymaps for the minibuffer, too; they contain various
|
|
1009 completion and exit commands.
|
|
1010
|
|
1011 @itemize @bullet
|
|
1012 @item
|
|
1013 @code{minibuffer-local-map} is used for ordinary input (no completion).
|
|
1014 @item
|
|
1015 @code{minibuffer-local-ns-map} is similar, except that @key{SPC} exits
|
|
1016 just like @key{RET}. This is used mainly for Mocklisp compatibility.
|
|
1017 @item
|
|
1018 @code{minibuffer-local-completion-map} is for permissive completion.
|
|
1019 @item
|
|
1020 @code{minibuffer-local-must-match-map} is for strict completion and
|
|
1021 for cautious completion.
|
|
1022 @item
|
|
1023 @code{repeat-complex-command-map} is for use in @kbd{C-x @key{ESC}}.
|
|
1024 @item
|
|
1025 @code{isearch-mode-map} contains the bindings of the special keys which
|
|
1026 are bound in the pseudo-mode entered with @kbd{C-s} and @kbd{C-r}.
|
|
1027 @end itemize
|
|
1028
|
|
1029 @vindex ctl-x-map
|
|
1030 @vindex help-map
|
|
1031 @vindex esc-map
|
|
1032 Finally, each prefix key has a keymap which defines the key sequences
|
|
1033 that start with it. For example, @code{ctl-x-map} is the keymap used for
|
|
1034 characters following a @kbd{C-x}.
|
|
1035
|
|
1036 @itemize @bullet
|
|
1037 @item
|
|
1038 @code{ctl-x-map} is the variable name for the map used for characters that
|
|
1039 follow @kbd{C-x}.
|
|
1040 @item
|
|
1041 @code{help-map} is used for characters that follow @kbd{C-h}.
|
|
1042 @item
|
|
1043 @code{esc-map} is for characters that follow @key{ESC}. All Meta
|
|
1044 characters are actually defined by this map.
|
|
1045 @item
|
|
1046 @code{ctl-x-4-map} is for characters that follow @kbd{C-x 4}.
|
|
1047 @item
|
|
1048 @code{mode-specific-map} is for characters that follow @kbd{C-c}.
|
|
1049 @end itemize
|
|
1050
|
|
1051 The definition of a prefix key is the keymap to use for looking up
|
|
1052 the following character. Sometimes the definition is actually a Lisp
|
|
1053 symbol whose function definition is the following character keymap. The
|
|
1054 effect is the same, but it provides a command name for the prefix key that
|
|
1055 you can use as a description of what the prefix key is for. Thus the
|
|
1056 binding of @kbd{C-x} is the symbol @code{Ctl-X-Prefix}, whose function
|
|
1057 definition is the keymap for @kbd{C-x} commands, the value of
|
|
1058 @code{ctl-x-map}.@refill
|
|
1059
|
|
1060 Prefix key definitions can appear in either the global
|
|
1061 map or a local map. The definitions of @kbd{C-c}, @kbd{C-x}, @kbd{C-h},
|
|
1062 and @key{ESC} as prefix keys appear in the global map, so these prefix
|
|
1063 keys are always available. Major modes can locally redefine a key as a
|
|
1064 prefix by putting a prefix key definition for it in the local
|
|
1065 map.@refill
|
|
1066
|
|
1067 A mode can also put a prefix definition of a global prefix character such
|
|
1068 as @kbd{C-x} into its local map. This is how major modes override the
|
|
1069 definitions of certain keys that start with @kbd{C-x}. This case is
|
|
1070 special, because the local definition does not entirely replace the global
|
|
1071 one. When both the global and local definitions of a key are other
|
|
1072 keymaps, the next character is looked up in both keymaps, with the local
|
|
1073 definition overriding the global one. The character after the
|
|
1074 @kbd{C-x} is looked up in both the major mode's own keymap for redefined
|
|
1075 @kbd{C-x} commands and in @code{ctl-x-map}. If the major mode's own keymap
|
|
1076 for @kbd{C-x} commands contains @code{nil}, the definition from the global
|
|
1077 keymap for @kbd{C-x} commands is used.@refill
|
|
1078
|
|
1079 @node Rebinding
|
|
1080 @subsection Changing Key Bindings
|
|
1081 @cindex key rebinding, this session
|
|
1082 @cindex rebinding keys, this session
|
|
1083
|
|
1084 You can redefine an Emacs key by changing its entry in a keymap.
|
|
1085 You can change the global keymap, in which case the change is effective in
|
|
1086 all major modes except those that have their own overriding local
|
|
1087 definitions for the same key. Or you can change the current buffer's
|
|
1088 local map, which affects all buffers using the same major mode.
|
|
1089
|
|
1090 @menu
|
|
1091 * Interactive Rebinding:: Changing Key Bindings Interactively
|
|
1092 * Programmatic Rebinding:: Changing Key Bindings Programmatically
|
|
1093 * Key Bindings Using Strings::Using Strings for Changing Key Bindings
|
|
1094 @end menu
|
|
1095
|
|
1096 @node Interactive Rebinding
|
|
1097 @subsubsection Changing Key Bindings Interactively
|
|
1098 @findex global-set-key
|
|
1099 @findex local-set-key
|
|
1100 @findex local-unset-key
|
|
1101
|
|
1102 @table @kbd
|
|
1103 @item M-x global-set-key @key{RET} @var{key} @var{cmd} @key{RET}
|
|
1104 Defines @var{key} globally to run @var{cmd}.
|
|
1105 @item M-x local-set-key @key{RET} @var{keys} @var{cmd} @key{RET}
|
|
1106 Defines @var{key} locally (in the major mode now in effect) to run
|
|
1107 @var{cmd}.
|
|
1108 @item M-x local-unset-key @key{RET} @var{keys} @key{RET}
|
|
1109 Removes the local binding of @var{key}.
|
|
1110 @end table
|
|
1111
|
|
1112 @var{cmd} is a symbol naming an interactively-callable function.
|
|
1113
|
|
1114 When called interactively, @var{key} is the next complete key sequence
|
|
1115 that you type. When called as a function, @var{key} is a string, a
|
|
1116 vector of events, or a vector of key-description lists as described in
|
|
1117 the @code{define-key} function description. The binding goes in
|
|
1118 the current buffer's local map, which is shared with other buffers in
|
|
1119 the same major mode.
|
|
1120
|
|
1121 The following example:
|
|
1122
|
|
1123 @example
|
|
1124 M-x global-set-key @key{RET} C-f next-line @key{RET}
|
|
1125 @end example
|
|
1126
|
|
1127 @noindent
|
|
1128 redefines @kbd{C-f} to move down a line. The fact that @var{cmd} is
|
|
1129 read second makes it serve as a kind of confirmation for @var{key}.
|
|
1130
|
|
1131 These functions offer no way to specify a particular prefix keymap as
|
|
1132 the one to redefine in, but that is not necessary, as you can include
|
|
1133 prefixes in @var{key}. @var{key} is read by reading characters one by
|
|
1134 one until they amount to a complete key (that is, not a prefix key).
|
|
1135 Thus, if you type @kbd{C-f} for @var{key}, Emacs enters
|
|
1136 the minibuffer immediately to read @var{cmd}. But if you type
|
|
1137 @kbd{C-x}, another character is read; if that character is @kbd{4},
|
|
1138 another character is read, and so on. For example,@refill
|
|
1139
|
|
1140 @example
|
|
1141 M-x global-set-key @key{RET} C-x 4 $ spell-other-window @key{RET}
|
|
1142 @end example
|
|
1143
|
|
1144 @noindent
|
|
1145 redefines @kbd{C-x 4 $} to run the (fictitious) command
|
|
1146 @code{spell-other-window}.
|
|
1147
|
|
1148 @findex define-key
|
|
1149 @findex substitute-key-definition
|
|
1150 The most general way to modify a keymap is the function
|
|
1151 @code{define-key}, used in Lisp code (such as your @file{.emacs} file).
|
|
1152 @code{define-key} takes three arguments: the keymap, the key to modify
|
|
1153 in it, and the new definition. @xref{Init File}, for an example.
|
|
1154 @code{substitute-key-definition} is used similarly; it takes three
|
|
1155 arguments, an old definition, a new definition, and a keymap, and
|
|
1156 redefines in that keymap all keys that were previously defined with the
|
|
1157 old definition to have the new definition instead.
|
|
1158
|
|
1159 @node Programmatic Rebinding
|
|
1160 @subsubsection Changing Key Bindings Programmatically
|
|
1161
|
|
1162 You can use the functions @code{global-set-key} and @code{define-key}
|
|
1163 to rebind keys under program control.
|
|
1164
|
|
1165 @findex define-key
|
|
1166 @findex global-set-key
|
|
1167
|
|
1168 @table @kbd
|
|
1169 @item @code{(global-set-key @var{keys} @var{cmd})}
|
|
1170 Defines @var{keys} globally to run @var{cmd}.
|
|
1171 @item @code{(define-key @var{keymap} @var{keys} @var{def})}
|
|
1172 Defines @var{keys} to run @var{def} in the keymap @var{keymap}.
|
|
1173 @end table
|
|
1174
|
|
1175 @var{keymap} is a keymap object.
|
|
1176
|
|
1177 @var{keys} is the sequence of keystrokes to bind.
|
|
1178
|
|
1179 @var{def} is anything that can be a key's definition:
|
|
1180
|
|
1181 @itemize @bullet
|
|
1182 @item
|
|
1183 @code{nil}, meaning key is undefined in this keymap
|
|
1184 @item
|
|
1185 A command, that is, a Lisp function suitable for interactive calling
|
|
1186 @item
|
|
1187 A string or key sequence vector, which is treated as a keyboard macro
|
|
1188 @item
|
|
1189 A keymap to define a prefix key
|
|
1190 @item
|
|
1191 A symbol so that when the key is looked up, the symbol stands for its
|
|
1192 function definition, which should at that time be one of the above,
|
|
1193 or another symbol whose function definition is used, and so on
|
|
1194 @item
|
|
1195 A cons, @code{(string . defn)}, meaning that @var{defn} is the definition
|
|
1196 (@var{defn} should be a valid definition in its own right)
|
|
1197 @item
|
|
1198 A cons, @code{(keymap . char)}, meaning use the definition of
|
|
1199 @var{char} in map @var{keymap}
|
|
1200 @end itemize
|
|
1201
|
|
1202 For backward compatibility, XEmacs allows you to specify key
|
|
1203 sequences as strings. However, the preferred method is to use the
|
|
1204 representations of key sequences as vectors of keystrokes.
|
|
1205 @xref{Keystrokes}, for more information about the rules for constructing
|
|
1206 key sequences.
|
|
1207
|
|
1208 Emacs allows you to abbreviate representations for key sequences in
|
|
1209 most places where there is no ambiguity.
|
|
1210 Here are some rules for abbreviation:
|
|
1211
|
|
1212 @itemize @bullet
|
|
1213 @item
|
|
1214 The keysym by itself is equivalent to a list of just that keysym, i.e.,
|
|
1215 @code{f1} is equivalent to @code{(f1)}.
|
|
1216 @item
|
|
1217 A keystroke by itself is equivalent to a vector containing just that
|
|
1218 keystroke, i.e., @code{(control a)} is equivalent to @code{[(control a)]}.
|
|
1219 @item
|
|
1220 You can use ASCII codes for keysyms that have them. i.e.,
|
|
1221 @code{65} is equivalent to @code{A}. (This is not so much an
|
|
1222 abbreviation as an alternate representation.)
|
|
1223 @end itemize
|
|
1224
|
|
1225 Here are some examples of programmatically binding keys:
|
|
1226
|
|
1227 @example
|
|
1228
|
|
1229 ;;; Bind @code{my-command} to @key{f1}
|
|
1230 (global-set-key 'f1 'my-command)
|
|
1231
|
|
1232 ;;; Bind @code{my-command} to @kbd{Shift-f1}
|
|
1233 (global-set-key '(shift f1) 'my-command)
|
|
1234
|
|
1235 ;;; Bind @code{my-command} to @kbd{C-c Shift-f1}
|
|
1236 (global-set-key '[(control c) (shift f1)] 'my-command)
|
|
1237
|
|
1238 ;;; Bind @code{my-command} to the middle mouse button.
|
|
1239 (global-set-key 'button2 'my-command)
|
|
1240
|
|
1241 ;;; Bind @code{my-command} to @kbd{@key{META} @key{CTL} @key{Right Mouse Button}}
|
|
1242 ;;; in the keymap that is in force when you are running @code{dired}.
|
|
1243 (define-key dired-mode-map '(meta control button3) 'my-command)
|
|
1244
|
|
1245 @end example
|
|
1246
|
|
1247 @comment ;; note that these next four lines are not synonymous:
|
|
1248 @comment ;;
|
|
1249 @comment (global-set-key '(meta control delete) 'my-command)
|
|
1250 @comment (global-set-key '(meta control backspace) 'my-command)
|
|
1251 @comment (global-set-key '(meta control h) 'my-command)
|
|
1252 @comment (global-set-key '(meta control H) 'my-command)
|
|
1253 @comment
|
|
1254 @comment ;; note that this binds two key sequences: ``control-j'' and ``linefeed''.
|
|
1255 @comment ;;
|
|
1256 @comment (global-set-key "\^J" 'my-command)
|
|
1257
|
|
1258 @node Key Bindings Using Strings
|
|
1259 @subsubsection Using Strings for Changing Key Bindings
|
|
1260
|
|
1261 For backward compatibility, you can still use strings to represent
|
108
|
1262 key sequences. Thus you can use commands like the following:
|
0
|
1263
|
|
1264 @example
|
|
1265 ;;; Bind @code{end-of-line} to @kbd{C-f}
|
|
1266 (global-set-key "\C-f" 'end-of-line)
|
|
1267 @end example
|
|
1268
|
|
1269 Note, however, that in some cases you may be binding more than one
|
|
1270 key sequence by using a single command. This situation can
|
|
1271 arise because in ASCII, @kbd{C-i} and @key{TAB} have
|
|
1272 the same representation. Therefore, when Emacs sees:
|
|
1273
|
|
1274 @example
|
|
1275 (global-set-key "\C-i" 'end-of-line)
|
|
1276 @end example
|
|
1277
|
|
1278 it is unclear whether the user intended to bind @kbd{C-i} or @key{TAB}.
|
|
1279 The solution XEmacs adopts is to bind both of these key
|
|
1280 sequences.
|
|
1281
|
|
1282 @cindex redefining keys
|
|
1283 After binding a command to two key sequences with a form like:
|
|
1284
|
|
1285 @example
|
|
1286 (define-key global-map "\^X\^I" 'command-1)
|
|
1287 @end example
|
|
1288
|
|
1289 it is possible to redefine only one of those sequences like so:
|
|
1290
|
|
1291 @example
|
|
1292 (define-key global-map [(control x) (control i)] 'command-2)
|
|
1293 (define-key global-map [(control x) tab] 'command-3)
|
|
1294 @end example
|
|
1295
|
|
1296 This applies only when running under a window system. If you are
|
|
1297 talking to Emacs through an ASCII-only channel, you do not get any of
|
|
1298 these features.
|
|
1299
|
|
1300 Here is a table of pairs of key sequences that behave in a
|
|
1301 similar fashion:
|
|
1302
|
|
1303 @example
|
|
1304 control h backspace
|
|
1305 control l clear
|
|
1306 control i tab
|
|
1307 control m return
|
|
1308 control j linefeed
|
|
1309 control [ escape
|
|
1310 control @@ control space
|
|
1311 @end example
|
|
1312
|
|
1313 @node Disabling
|
|
1314 @subsection Disabling Commands
|
|
1315 @cindex disabled command
|
|
1316
|
|
1317 Disabling a command marks it as requiring confirmation before it
|
|
1318 can be executed. The purpose of disabling a command is to prevent
|
|
1319 beginning users from executing it by accident and being confused.
|
|
1320
|
|
1321 The direct mechanism for disabling a command is to have a non-@code{nil}
|
|
1322 @code{disabled} property on the Lisp symbol for the command. These
|
|
1323 properties are normally set by the user's @file{.emacs} file with
|
|
1324 Lisp expressions such as:
|
|
1325
|
|
1326 @example
|
|
1327 (put 'delete-region 'disabled t)
|
|
1328 @end example
|
|
1329
|
|
1330 If the value of the @code{disabled} property is a string, that string
|
|
1331 is included in the message printed when the command is used:
|
|
1332
|
|
1333 @example
|
|
1334 (put 'delete-region 'disabled
|
|
1335 "Text deleted this way cannot be yanked back!\n")
|
|
1336 @end example
|
|
1337
|
|
1338 @findex disable-command
|
|
1339 @findex enable-command
|
|
1340 You can disable a command either by editing the @file{.emacs} file
|
|
1341 directly or with the command @kbd{M-x disable-command}, which edits the
|
|
1342 @file{.emacs} file for you. @xref{Init File}.
|
|
1343
|
|
1344 When you attempt to invoke a disabled command interactively in Emacs,
|
|
1345 a window is displayed containing the command's name, its
|
|
1346 documentation, and some instructions on what to do next; then
|
|
1347 Emacs asks for input saying whether to execute the command as requested,
|
|
1348 enable it and execute, or cancel it. If you decide to enable the
|
|
1349 command, you are asked whether to do this permanently or just for the
|
|
1350 current session. Enabling permanently works by automatically editing
|
|
1351 your @file{.emacs} file. You can use @kbd{M-x enable-command} at any
|
|
1352 time to enable any command permanently.
|
|
1353
|
|
1354 Whether a command is disabled is independent of what key is used to
|
|
1355 invoke it; it also applies if the command is invoked using @kbd{M-x}.
|
|
1356 Disabling a command has no effect on calling it as a function from Lisp
|
|
1357 programs.
|
|
1358
|
|
1359 @node Syntax
|
|
1360 @section The Syntax Table
|
|
1361 @cindex syntax table
|
|
1362
|
|
1363 All the Emacs commands which parse words or balance parentheses are
|
|
1364 controlled by the @dfn{syntax table}. The syntax table specifies which
|
|
1365 characters are opening delimiters, which are parts of words, which are
|
|
1366 string quotes, and so on. Actually, each major mode has its own syntax
|
|
1367 table (though sometimes related major modes use the same one) which it
|
|
1368 installs in each buffer that uses that major mode. The syntax table
|
|
1369 installed in the current buffer is the one that all commands use, so we
|
|
1370 call it ``the'' syntax table. A syntax table is a Lisp object, a vector of
|
|
1371 length 256 whose elements are numbers.
|
|
1372
|
|
1373 @menu
|
|
1374 * Entry: Syntax Entry. What the syntax table records for each character.
|
|
1375 * Change: Syntax Change. How to change the information.
|
|
1376 @end menu
|
|
1377
|
|
1378 @node Syntax Entry
|
|
1379 @subsection Information About Each Character
|
|
1380
|
|
1381 The syntax table entry for a character is a number that encodes six
|
|
1382 pieces of information:
|
|
1383
|
|
1384 @itemize @bullet
|
|
1385 @item
|
|
1386 The syntactic class of the character, represented as a small integer
|
|
1387 @item
|
|
1388 The matching delimiter, for delimiter characters only
|
|
1389 (the matching delimiter of @samp{(} is @samp{)}, and vice versa)
|
|
1390 @item
|
|
1391 A flag saying whether the character is the first character of a
|
|
1392 two-character comment starting sequence
|
|
1393 @item
|
|
1394 A flag saying whether the character is the second character of a
|
|
1395 two-character comment starting sequence
|
|
1396 @item
|
|
1397 A flag saying whether the character is the first character of a
|
|
1398 two-character comment ending sequence
|
|
1399 @item
|
|
1400 A flag saying whether the character is the second character of a
|
|
1401 two-character comment ending sequence
|
|
1402 @end itemize
|
|
1403
|
|
1404 The syntactic classes are stored internally as small integers, but are
|
|
1405 usually described to or by the user with characters. For example, @samp{(}
|
|
1406 is used to specify the syntactic class of opening delimiters. Here is a
|
|
1407 table of syntactic classes, with the characters that specify them.
|
|
1408
|
|
1409 @table @samp
|
|
1410 @item @w{ }
|
|
1411 The class of whitespace characters.
|
|
1412 @item w
|
|
1413 The class of word-constituent characters.
|
|
1414 @item _
|
|
1415 The class of characters that are part of symbol names but not words.
|
|
1416 This class is represented by @samp{_} because the character @samp{_}
|
|
1417 has this class in both C and Lisp.
|
|
1418 @item .
|
|
1419 The class of punctuation characters that do not fit into any other
|
|
1420 special class.
|
|
1421 @item (
|
|
1422 The class of opening delimiters.
|
|
1423 @item )
|
|
1424 The class of closing delimiters.
|
|
1425 @item '
|
|
1426 The class of expression-adhering characters. These characters are
|
|
1427 part of a symbol if found within or adjacent to one, and are part
|
|
1428 of a following expression if immediately preceding one, but are like
|
|
1429 whitespace if surrounded by whitespace.
|
|
1430 @item "
|
|
1431 The class of string-quote characters. They match each other in pairs,
|
|
1432 and the characters within the pair all lose their syntactic
|
|
1433 significance except for the @samp{\} and @samp{/} classes of escape
|
|
1434 characters, which can be used to include a string-quote inside the
|
|
1435 string.
|
|
1436 @item $
|
|
1437 The class of self-matching delimiters. This is intended for @TeX{}'s
|
|
1438 @samp{$}, which is used both to enter and leave math mode. Thus,
|
|
1439 a pair of matching @samp{$} characters surround each piece of math mode
|
|
1440 @TeX{} input. A pair of adjacent @samp{$} characters act like a single
|
|
1441 one for purposes of matching.
|
|
1442
|
|
1443 @item /
|
|
1444 The class of escape characters that always just deny the following
|
|
1445 character its special syntactic significance. The character after one
|
|
1446 of these escapes is always treated as alphabetic.
|
|
1447 @item \
|
|
1448 The class of C-style escape characters. In practice, these are
|
|
1449 treated just like @samp{/}-class characters, because the extra
|
|
1450 possibilities for C escapes (such as being followed by digits) have no
|
|
1451 effect on where the containing expression ends.
|
|
1452 @item <
|
|
1453 The class of comment-starting characters. Only single-character
|
|
1454 comment starters (such as @samp{;} in Lisp mode) are represented this
|
|
1455 way.
|
|
1456 @item >
|
|
1457 The class of comment-ending characters. Newline has this syntax in
|
|
1458 Lisp mode.
|
|
1459 @end table
|
|
1460
|
|
1461 @vindex parse-sexp-ignore-comments
|
|
1462 The characters flagged as part of two-character comment delimiters can
|
|
1463 have other syntactic functions most of the time. For example, @samp{/} and
|
|
1464 @samp{*} in C code, when found separately, have nothing to do with
|
|
1465 comments. The comment-delimiter significance overrides when the pair of
|
|
1466 characters occur together in the proper order. Only the list and sexp
|
|
1467 commands use the syntax table to find comments; the commands specifically
|
|
1468 for comments have other variables that tell them where to find comments.
|
|
1469 Moreover, the list and sexp commands notice comments only if
|
|
1470 @code{parse-sexp-ignore-comments} is non-@code{nil}. This variable is set
|
|
1471 to @code{nil} in modes where comment-terminator sequences are liable to
|
|
1472 appear where there is no comment, for example, in Lisp mode where the
|
|
1473 comment terminator is a newline but not every newline ends a comment.
|
|
1474
|
|
1475 @node Syntax Change
|
|
1476 @subsection Altering Syntax Information
|
|
1477
|
|
1478 It is possible to alter a character's syntax table entry by storing a new
|
|
1479 number in the appropriate element of the syntax table, but it would be hard
|
|
1480 to determine what number to use. Emacs therefore provides a command that
|
|
1481 allows you to specify the syntactic properties of a character in a
|
|
1482 convenient way.
|
|
1483
|
|
1484 @findex modify-syntax-entry
|
|
1485 @kbd{M-x modify-syntax-entry} is the command to change a character's
|
|
1486 syntax. It can be used interactively and is also used by major
|
|
1487 modes to initialize their own syntax tables. Its first argument is the
|
|
1488 character to change. The second argument is a string that specifies the
|
|
1489 new syntax. When called from Lisp code, there is a third, optional
|
|
1490 argument, which specifies the syntax table in which to make the change. If
|
|
1491 not supplied, or if this command is called interactively, the third
|
|
1492 argument defaults to the current buffer's syntax table.
|
|
1493
|
|
1494 @enumerate
|
|
1495 @item
|
|
1496 The first character in the string specifies the syntactic class. It
|
|
1497 is one of the characters in the previous table (@pxref{Syntax Entry}).
|
|
1498
|
|
1499 @item
|
|
1500 The second character is the matching delimiter. For a character that
|
|
1501 is not an opening or closing delimiter, this should be a space, and may
|
|
1502 be omitted if no following characters are needed.
|
|
1503
|
|
1504 @item
|
|
1505 The remaining characters are flags. The flag characters allowed are:
|
|
1506
|
|
1507 @table @samp
|
|
1508 @item 1
|
|
1509 Flag this character as the first of a two-character comment starting sequence.
|
|
1510 @item 2
|
|
1511 Flag this character as the second of a two-character comment starting sequence.
|
|
1512 @item 3
|
|
1513 Flag this character as the first of a two-character comment ending sequence.
|
|
1514 @item 4
|
|
1515 Flag this character as the second of a two-character comment ending sequence.
|
|
1516 @end table
|
|
1517 @end enumerate
|
|
1518
|
|
1519 @kindex C-h s
|
|
1520 @findex describe-syntax
|
|
1521 Use @kbd{C-h s} (@code{describe-syntax}) to display a description of
|
|
1522 the contents of the current syntax table. The description of each
|
|
1523 character includes both the string you have to pass to
|
|
1524 @code{modify-syntax-entry} to set up that character's current syntax,
|
|
1525 and some English to explain that string if necessary.
|
|
1526
|
|
1527 @node Init File
|
|
1528 @section The Init File, .emacs
|
|
1529 @cindex init file
|
|
1530 @cindex Emacs initialization file
|
|
1531 @cindex key rebinding, permanent
|
|
1532 @cindex rebinding keys, permanently
|
|
1533
|
|
1534 When you start Emacs, it normally loads the file @file{.emacs} in your
|
|
1535 home directory. This file, if it exists, should contain Lisp code. It
|
|
1536 is called your initialization file or @dfn{init file}. Use the command
|
|
1537 line switches @samp{-q} and @samp{-u} to tell Emacs whether to load an
|
|
1538 init file (@pxref{Entering Emacs}).
|
|
1539
|
|
1540 @vindex init-file-user
|
|
1541 When the @file{.emacs} file is read, the variable @code{init-file-user}
|
|
1542 says which user's init file it is. The value may be the null string or a
|
|
1543 string containing a user's name. If the value is a null string, it means
|
|
1544 that the init file was taken from the user that originally logged in.
|
|
1545
|
|
1546 In all cases, @code{(concat "~" init-file-user "/")} evaluates to the
|
|
1547 directory name of the directory where the @file{.emacs} file was looked
|
|
1548 for.
|
|
1549
|
|
1550 At some sites there is a @dfn{default init file}, which is the
|
|
1551 library named @file{default.el}, found via the standard search path for
|
|
1552 libraries. The Emacs distribution contains no such library; your site
|
|
1553 may create one for local customizations. If this library exists, it is
|
|
1554 loaded whenever you start Emacs. But your init file, if any, is loaded
|
|
1555 first; if it sets @code{inhibit-default-init} non-@code{nil}, then
|
|
1556 @file{default} is not loaded.
|
|
1557
|
|
1558 If you have a large amount of code in your @file{.emacs} file, you
|
|
1559 should move it into another file named @file{@var{something}.el},
|
|
1560 byte-compile it (@pxref{Lisp Libraries}), and load that file from your
|
|
1561 @file{.emacs} file using @code{load}.
|
|
1562
|
|
1563 @menu
|
|
1564 * Init Syntax:: Syntax of constants in Emacs Lisp.
|
|
1565 * Init Examples:: How to do some things with an init file.
|
|
1566 * Terminal Init:: Each terminal type can have an init file.
|
|
1567 @end menu
|
|
1568
|
|
1569 @node Init Syntax
|
|
1570 @subsection Init File Syntax
|
|
1571
|
|
1572 The @file{.emacs} file contains one or more Lisp function call
|
|
1573 expressions. Each consists of a function name followed by
|
|
1574 arguments, all surrounded by parentheses. For example, @code{(setq
|
|
1575 fill-column 60)} represents a call to the function @code{setq} which is
|
|
1576 used to set the variable @code{fill-column} (@pxref{Filling}) to 60.
|
|
1577
|
|
1578 The second argument to @code{setq} is an expression for the new value
|
|
1579 of the variable. This can be a constant, a variable, or a function call
|
|
1580 expression. In @file{.emacs}, constants are used most of the time.
|
|
1581 They can be:
|
|
1582
|
|
1583 @table @asis
|
|
1584 @item Numbers
|
|
1585 Integers are written in decimal, with an optional initial minus sign.
|
|
1586
|
|
1587 If a sequence of digits is followed by a period and another sequence
|
|
1588 of digits, it is interpreted as a floating point number.
|
|
1589
|
|
1590 @item Strings
|
|
1591 Lisp string syntax is the same as C string syntax with a few extra
|
|
1592 features. Use a double-quote character to begin and end a string constant.
|
|
1593
|
|
1594 Newlines and special characters may be present literally in strings. They
|
|
1595 can also be represented as backslash sequences: @samp{\n} for newline,
|
|
1596 @samp{\b} for backspace, @samp{\r} for return, @samp{\t} for tab,
|
|
1597 @samp{\f} for formfeed (control-l), @samp{\e} for escape, @samp{\\} for a
|
|
1598 backslash, @samp{\"} for a double-quote, or @samp{\@var{ooo}} for the
|
|
1599 character whose octal code is @var{ooo}. Backslash and double-quote are
|
|
1600 the only characters for which backslash sequences are mandatory.
|
|
1601
|
|
1602 You can use @samp{\C-} as a prefix for a control character, as in
|
|
1603 @samp{\C-s} for ASCII Control-S, and @samp{\M-} as a prefix for
|
|
1604 a Meta character, as in @samp{\M-a} for Meta-A or @samp{\M-\C-a} for
|
|
1605 Control-Meta-A.@refill
|
|
1606
|
|
1607 @item Characters
|
|
1608 Lisp character constant syntax consists of a @samp{?} followed by
|
|
1609 either a character or an escape sequence starting with @samp{\}.
|
|
1610 Examples: @code{?x}, @code{?\n}, @code{?\"}, @code{?\)}. Note that
|
|
1611 strings and characters are not interchangeable in Lisp; some contexts
|
|
1612 require one and some contexts require the other.
|
|
1613
|
|
1614 @item True
|
|
1615 @code{t} stands for `true'.
|
|
1616
|
|
1617 @item False
|
|
1618 @code{nil} stands for `false'.
|
|
1619
|
|
1620 @item Other Lisp objects
|
|
1621 Write a single-quote (') followed by the Lisp object you want.
|
|
1622 @end table
|
|
1623
|
|
1624 @node Init Examples
|
|
1625 @subsection Init File Examples
|
|
1626
|
|
1627 Here are some examples of doing certain commonly desired things with
|
|
1628 Lisp expressions:
|
|
1629
|
|
1630 @itemize @bullet
|
|
1631 @item
|
|
1632 Make @key{TAB} in C mode just insert a tab if point is in the middle of a
|
|
1633 line.
|
|
1634
|
|
1635 @example
|
|
1636 (setq c-tab-always-indent nil)
|
|
1637 @end example
|
|
1638
|
|
1639 Here we have a variable whose value is normally @code{t} for `true'
|
|
1640 and the alternative is @code{nil} for `false'.
|
|
1641
|
|
1642 @item
|
|
1643 Make searches case sensitive by default (in all buffers that do not
|
|
1644 override this).
|
|
1645
|
|
1646 @example
|
|
1647 (setq-default case-fold-search nil)
|
|
1648 @end example
|
|
1649
|
|
1650 This sets the default value, which is effective in all buffers that do
|
|
1651 not have local values for the variable. Setting @code{case-fold-search}
|
|
1652 with @code{setq} affects only the current buffer's local value, which
|
|
1653 is probably not what you want to do in an init file.
|
|
1654
|
|
1655 @item
|
|
1656 Make Text mode the default mode for new buffers.
|
|
1657
|
|
1658 @example
|
|
1659 (setq default-major-mode 'text-mode)
|
|
1660 @end example
|
|
1661
|
|
1662 Note that @code{text-mode} is used because it is the command for entering
|
|
1663 the mode we want. A single-quote is written before it to make a symbol
|
|
1664 constant; otherwise, @code{text-mode} would be treated as a variable name.
|
|
1665
|
|
1666 @item
|
|
1667 Turn on Auto Fill mode automatically in Text mode and related modes.
|
|
1668
|
|
1669 @example
|
|
1670 (setq text-mode-hook
|
|
1671 '(lambda () (auto-fill-mode 1)))
|
|
1672 @end example
|
|
1673
|
|
1674 Here we have a variable whose value should be a Lisp function. The
|
|
1675 function we supply is a list starting with @code{lambda}, and a single
|
|
1676 quote is written in front of it to make it (for the purpose of this
|
|
1677 @code{setq}) a list constant rather than an expression. Lisp functions
|
|
1678 are not explained here; for mode hooks it is enough to know that
|
|
1679 @code{(auto-fill-mode 1)} is an expression that will be executed when
|
|
1680 Text mode is entered. You could replace it with any other expression
|
|
1681 that you like, or with several expressions in a row.
|
|
1682
|
|
1683 @example
|
|
1684 (setq text-mode-hook 'turn-on-auto-fill)
|
|
1685 @end example
|
|
1686
|
|
1687 This is another way to accomplish the same result.
|
|
1688 @code{turn-on-auto-fill} is a symbol whose function definition is
|
|
1689 @code{(lambda () (auto-fill-mode 1))}.
|
|
1690
|
|
1691 @item
|
|
1692 Load the installed Lisp library named @file{foo} (actually a file
|
|
1693 @file{foo.elc} or @file{foo.el} in a standard Emacs directory).
|
|
1694
|
|
1695 @example
|
|
1696 (load "foo")
|
|
1697 @end example
|
|
1698
|
|
1699 When the argument to @code{load} is a relative pathname, not starting
|
|
1700 with @samp{/} or @samp{~}, @code{load} searches the directories in
|
|
1701 @code{load-path} (@pxref{Loading}).
|
|
1702
|
|
1703 @item
|
|
1704 Load the compiled Lisp file @file{foo.elc} from your home directory.
|
|
1705
|
|
1706 @example
|
|
1707 (load "~/foo.elc")
|
|
1708 @end example
|
|
1709
|
|
1710 Here an absolute file name is used, so no searching is done.
|
|
1711
|
|
1712 @item
|
|
1713 Rebind the key @kbd{C-x l} to run the function @code{make-symbolic-link}.
|
|
1714
|
|
1715 @example
|
|
1716 (global-set-key "\C-xl" 'make-symbolic-link)
|
|
1717 @end example
|
|
1718
|
|
1719 or
|
|
1720
|
|
1721 @example
|
|
1722 (define-key global-map "\C-xl" 'make-symbolic-link)
|
|
1723 @end example
|
|
1724
|
|
1725 Note once again the single-quote used to refer to the symbol
|
|
1726 @code{make-symbolic-link} instead of its value as a variable.
|
|
1727
|
|
1728 @item
|
|
1729 Do the same thing for C mode only.
|
|
1730
|
|
1731 @example
|
|
1732 (define-key c-mode-map "\C-xl" 'make-symbolic-link)
|
|
1733 @end example
|
|
1734
|
|
1735 @item
|
|
1736 Bind the function key @key{F1} to a command in C mode.
|
|
1737 Note that the names of function keys must be lower case.
|
|
1738
|
|
1739 @example
|
|
1740 (define-key c-mode-map 'f1 'make-symbolic-link)
|
|
1741 @end example
|
|
1742
|
|
1743 @item
|
|
1744 Bind the shifted version of @key{F1} to a command.
|
|
1745
|
|
1746 @example
|
|
1747 (define-key c-mode-map '(shift f1) 'make-symbolic-link)
|
|
1748 @end example
|
|
1749
|
|
1750 @item
|
|
1751 Redefine all keys which now run @code{next-line} in Fundamental mode
|
|
1752 to run @code{forward-line} instead.
|
|
1753
|
|
1754 @example
|
|
1755 (substitute-key-definition 'next-line 'forward-line
|
|
1756 global-map)
|
|
1757 @end example
|
|
1758
|
|
1759 @item
|
|
1760 Make @kbd{C-x C-v} undefined.
|
|
1761
|
|
1762 @example
|
|
1763 (global-unset-key "\C-x\C-v")
|
|
1764 @end example
|
|
1765
|
|
1766 One reason to undefine a key is so that you can make it a prefix.
|
|
1767 Simply defining @kbd{C-x C-v @var{anything}} would make @kbd{C-x C-v}
|
|
1768 a prefix, but @kbd{C-x C-v} must be freed of any non-prefix definition
|
|
1769 first.
|
|
1770
|
|
1771 @item
|
|
1772 Make @samp{$} have the syntax of punctuation in Text mode.
|
|
1773 Note the use of a character constant for @samp{$}.
|
|
1774
|
|
1775 @example
|
|
1776 (modify-syntax-entry ?\$ "." text-mode-syntax-table)
|
|
1777 @end example
|
|
1778
|
|
1779 @item
|
|
1780 Enable the use of the command @code{eval-expression} without confirmation.
|
|
1781
|
|
1782 @example
|
|
1783 (put 'eval-expression 'disabled nil)
|
|
1784 @end example
|
|
1785 @end itemize
|
|
1786
|
|
1787 @node Terminal Init
|
|
1788 @subsection Terminal-Specific Initialization
|
|
1789
|
|
1790 Each terminal type can have a Lisp library to be loaded into Emacs when
|
|
1791 it is run on that type of terminal. For a terminal type named
|
|
1792 @var{termtype}, the library is called @file{term/@var{termtype}} and it is
|
|
1793 found by searching the directories @code{load-path} as usual and trying the
|
|
1794 suffixes @samp{.elc} and @samp{.el}. Normally it appears in the
|
|
1795 subdirectory @file{term} of the directory where most Emacs libraries are
|
|
1796 kept.@refill
|
|
1797
|
|
1798 The usual purpose of the terminal-specific library is to define the
|
|
1799 escape sequences used by the terminal's function keys using the library
|
|
1800 @file{keypad.el}. See the file
|
|
1801 @file{term/vt100.el} for an example of how this is done.@refill
|
|
1802
|
|
1803 When the terminal type contains a hyphen, only the part of the name
|
|
1804 before the first hyphen is significant in choosing the library name.
|
|
1805 Thus, terminal types @samp{aaa-48} and @samp{aaa-30-rv} both use
|
|
1806 the library @file{term/aaa}. The code in the library can use
|
|
1807 @code{(getenv "TERM")} to find the full terminal type name.@refill
|
|
1808
|
|
1809 @vindex term-file-prefix
|
|
1810 The library's name is constructed by concatenating the value of the
|
|
1811 variable @code{term-file-prefix} and the terminal type. Your @file{.emacs}
|
|
1812 file can prevent the loading of the terminal-specific library by setting
|
|
1813 @code{term-file-prefix} to @code{nil}.
|
|
1814
|
|
1815 @vindex term-setup-hook
|
|
1816 The value of the variable @code{term-setup-hook}, if not @code{nil}, is
|
|
1817 called as a function of no arguments at the end of Emacs initialization,
|
|
1818 after both your @file{.emacs} file and any terminal-specific library have
|
|
1819 been read. You can set the value in the @file{.emacs} file to override
|
|
1820 part of any of the terminal-specific libraries and to define
|
|
1821 initializations for terminals that do not have a library.@refill
|
|
1822
|
|
1823 @node Audible Bell
|
|
1824 @section Changing the Bell Sound
|
|
1825 @cindex audible bell, changing
|
|
1826 @cindex bell, changing
|
|
1827 @vindex sound-alist
|
|
1828 @findex load-default-sounds
|
|
1829 @findex play-sound
|
|
1830
|
|
1831 You can now change how the audible bell sounds using the variable
|
|
1832 @code{sound-alist}.
|
|
1833
|
|
1834 @code{sound-alist}'s value is an list associating symbols with, among
|
|
1835 other things, strings of audio-data. When @code{ding} is called with
|
|
1836 one of the symbols, the associated sound data is played instead of the
|
|
1837 standard beep. This only works if you are logged in on the console of a
|
|
1838 machine with audio hardware. To listen to a sound of the provided type,
|
|
1839 call the function @code{play-sound} with the argument @var{sound}. You
|
|
1840 can also set the volume of the sound with the optional argument
|
|
1841 @var{volume}.@refill
|
|
1842 @cindex ding
|
|
1843
|
|
1844 Each element of @code{sound-alist} is a list describing a sound.
|
|
1845 The first element of the list is the name of the sound being defined.
|
|
1846 Subsequent elements of the list are alternating keyword/value pairs:
|
|
1847
|
|
1848 @table @code
|
|
1849 @item sound
|
|
1850 A string of raw sound data, or the name of another sound to play.
|
|
1851 The symbol @code{t} here means use the default X beep.
|
|
1852
|
|
1853 @item volume
|
|
1854 An integer from 0-100, defaulting to @code{bell-volume}.
|
|
1855
|
|
1856 @item pitch
|
|
1857 If using the default X beep, the pitch (Hz) to generate.
|
|
1858
|
|
1859 @item duration
|
|
1860 If using the default X beep, the duration (milliseconds).
|
|
1861 @end table
|
|
1862
|
|
1863 For compatibility, elements of `sound-alist' may also be of the form:
|
|
1864
|
|
1865 @example
|
|
1866 ( @var{sound-name} . @var{<sound>} )
|
|
1867 ( @var{sound-name} @var{<volume>} @var{<sound>} )
|
|
1868 @end example
|
|
1869
|
|
1870 You should probably add things to this list by calling the function
|
|
1871 @code{load-sound-file}.
|
|
1872
|
|
1873 Note that you can only play audio data if running on the console screen
|
|
1874 of a machine with audio hardware which emacs understands, which at this
|
|
1875 time means a Sun SparcStation, SGI, or HP9000s700.
|
|
1876
|
|
1877 Also note that the pitch, duration, and volume options are available
|
|
1878 everywhere, but most X servers ignore the `pitch' option.
|
|
1879
|
|
1880 @vindex bell-volume
|
|
1881 The variable @code{bell-volume} should be an integer from 0 to 100,
|
|
1882 with 100 being loudest, which controls how loud the sounds emacs makes
|
|
1883 should be. Elements of the @code{sound-alist} may override this value.
|
|
1884 This variable applies to the standard X bell sound as well as sound files.
|
|
1885
|
|
1886 If the symbol @code{t} is in place of a sound-string, Emacs uses the
|
|
1887 default X beep. This allows you to define beep-types of
|
|
1888 different volumes even when not running on the console.
|
|
1889
|
|
1890 @findex load-sound-file
|
|
1891 You can add things to this list by calling the function
|
|
1892 @code{load-sound-file}, which reads in an audio-file and adds its data to
|
|
1893 the sound-alist. You can specify the sound with the @var{sound-name}
|
|
1894 argument and the file into which the sounds are loaded with the
|
|
1895 @var{filename} argument. The optional @var{volume} argument sets the
|
|
1896 volume.
|
|
1897
|
|
1898 @code{load-sound-file (@var{filename sound-name} &optional @var{volume})}
|
|
1899
|
|
1900 To load and install some sound files as beep-types, use the function
|
|
1901 @code{load-default-sounds} (note that this only works if you are on
|
|
1902 display 0 of a machine with audio hardware).
|
|
1903
|
|
1904 The following beep-types are used by Emacs itself. Other Lisp
|
|
1905 packages may use other beep types, but these are the ones that the C
|
|
1906 kernel of Emacs uses.
|
|
1907
|
|
1908 @table @code
|
|
1909 @item auto-save-error
|
|
1910 An auto-save does not succeed
|
|
1911
|
|
1912 @item command-error
|
|
1913 The Emacs command loop catches an error
|
|
1914
|
|
1915 @item undefined-key
|
|
1916 You type a key that is undefined
|
|
1917
|
|
1918 @item undefined-click
|
|
1919 You use an undefined mouse-click combination
|
|
1920
|
|
1921 @item no-completion
|
|
1922 Completion was not possible
|
|
1923
|
|
1924 @item y-or-n-p
|
|
1925 You type something other than the required @code{y} or @code{n}
|
|
1926
|
|
1927 @item yes-or-no-p
|
|
1928 You type something other than @code{yes} or @code{no}
|
|
1929 @end table
|
|
1930
|
|
1931 @comment node-name, next, previous, up
|
|
1932 @node Faces
|
|
1933 @section Faces
|
|
1934
|
|
1935 XEmacs has objects called extents and faces. An @dfn{extent}
|
|
1936 is a region of text and a @dfn{face} is a collection of textual
|
|
1937 attributes, such as fonts and colors. Every extent is displayed in some
|
|
1938 face; therefore, changing the properties of a face immediately updates the
|
|
1939 display of all associated extents. Faces can be frame-local: you can
|
|
1940 have a region of text that displays with completely different
|
|
1941 attributes when its buffer is viewed from a different X window.
|
|
1942
|
|
1943 The display attributes of faces may be specified either in Lisp or through
|
|
1944 the X resource manager.
|
|
1945
|
|
1946 @subsection Customizing Faces
|
|
1947
|
|
1948 You can change the face of an extent with the functions in
|
|
1949 this section. All the functions prompt for a @var{face} as an
|
|
1950 argument; use completion for a list of possible values.
|
|
1951
|
|
1952 @table @kbd
|
|
1953 @item M-x invert-face
|
|
1954 Swap the foreground and background colors of the given @var{face}.
|
|
1955 @item M-x make-face-bold
|
|
1956 Make the font of the given @var{face} bold. When called from a
|
|
1957 program, returns @code{nil} if this is not possible.
|
|
1958 @item M-x make-face-bold-italic
|
|
1959 Make the font of the given @var{face} bold italic.
|
|
1960 When called from a program, returns @code{nil} if not possible.
|
|
1961 @item M-x make-face-italic
|
|
1962 Make the font of the given @var{face} italic.
|
|
1963 When called from a program, returns @code{nil} if not possible.
|
|
1964 @item M-x make-face-unbold
|
|
1965 Make the font of the given @var{face} non-bold.
|
|
1966 When called from a program, returns @code{nil} if not possible.
|
|
1967 @item M-x make-face-unitalic
|
|
1968 Make the font of the given @var{face} non-italic.
|
|
1969 When called from a program, returns @code{nil} if not possible.
|
|
1970 @item M-x make-face-larger
|
|
1971 Make the font of the given @var{face} a little larger.
|
|
1972 When called from a program, returns @code{nil} if not possible.
|
|
1973 @item M-x make-face-smaller
|
|
1974 Make the font of the given @var{face} a little smaller.
|
|
1975 When called from a program, returns @code{nil} if not possible.
|
|
1976 @item M-x set-face-background
|
|
1977 Change the background color of the given @var{face}.
|
|
1978 @item M-x set-face-background-pixmap
|
|
1979 Change the background pixmap of the given @var{face}.
|
|
1980 @item M-x set-face-font
|
|
1981 Change the font of the given @var{face}.
|
|
1982 @item M-x set-face-foreground
|
|
1983 Change the foreground color of the given @var{face}.
|
|
1984 @item M-x set-face-underline-p
|
|
1985 Change whether the given @var{face} is underlined.
|
|
1986 @end table
|
|
1987
|
|
1988 @findex make-face-bold
|
|
1989 @findex make-face-bold-italic
|
|
1990 @findex make-face-italic
|
|
1991 @findex make-face-unbold
|
|
1992 @findex make-face-unitalic
|
|
1993 @findex make-face-larger
|
|
1994 @findex make-face-smaller
|
|
1995
|
|
1996 @findex invert-face
|
|
1997 You can exchange the foreground and background color of the selected
|
|
1998 @var{face} with the function @code{invert-face}. If the face does not
|
|
1999 specify both foreground and background, then its foreground and
|
|
2000 background are set to the background and foreground of the default face.
|
|
2001 When calling this from a program, you can supply the optional argument
|
|
2002 @var{frame} to specify which frame is affected; otherwise, all frames
|
|
2003 are affected.
|
|
2004
|
|
2005 @findex set-face-background
|
|
2006 You can set the background color of the specified @var{face} with the
|
|
2007 function @code{set-face-background}. The argument @code{color} should
|
|
2008 be a string, the name of a color. When called from a program, if the
|
|
2009 optional @var{frame} argument is provided, the face is changed only
|
|
2010 in that frame; otherwise, it is changed in all frames.
|
|
2011
|
|
2012 @findex set-face-background-pixmap
|
|
2013 You can set the background pixmap of the specified @var{face} with the
|
|
2014 function @code{set-face-background-pixmap}. The pixmap argument
|
|
2015 @var{name} should be a string, the name of a file of pixmap data. The
|
|
2016 directories listed in the @code{x-bitmap-file-path} variable are
|
|
2017 searched. The bitmap may also be a list of the form @code{(@var{width
|
|
2018 height data})}, where @var{width} and @var{height} are the size in
|
|
2019 pixels, and @var{data} is a string containing the raw bits of the
|
|
2020 bitmap. If the optional @var{frame} argument is provided, the face is
|
|
2021 changed only in that frame; otherwise, it is changed in all frames.
|
|
2022
|
|
2023 The variable @code{x-bitmap-file-path} takes as a value a list of the
|
|
2024 directories in which X bitmap files may be found. If the value is
|
|
2025 @code{nil}, the list is initialized from the @code{*bitmapFilePath}
|
|
2026 resource.
|
|
2027
|
|
2028 If the environment variable @b{XBMLANGPATH} is set, then it is consulted
|
|
2029 before the @code{x-bitmap-file-path} variable.
|
|
2030
|
|
2031 @findex set-face-font
|
|
2032 You can set the font of the specified @var{face} with the function
|
|
2033 @code{set-face-font}. The @var{font} argument should be a string, the
|
|
2034 name of a font. When called from a program, if the
|
|
2035 optional @var{frame} argument is provided, the face is changed only
|
|
2036 in that frame; otherwise, it is changed in all frames.
|
|
2037
|
|
2038 @findex set-face-foreground
|
|
2039 You can set the foreground color of the specified @var{face} with the
|
|
2040 function @code{set-face-foreground}. The argument @var{color} should be
|
|
2041 a string, the name of a color. If the optional @var{frame} argument is
|
|
2042 provided, the face is changed only in that frame; otherwise, it is
|
|
2043 changed in all frames.
|
|
2044
|
|
2045 @findex set-face-underline-p
|
|
2046 You can set underline the specified @var{face} with the function
|
|
2047 @code{set-face-underline-p}. The argument @var{underline-p} can be used
|
|
2048 to make underlining an attribute of the face or not. If the optional
|
|
2049 @var{frame} argument is provided, the face is changed only in that
|
|
2050 frame; otherwise, it is changed in all frames.
|
|
2051
|
|
2052 @node X Resources
|
|
2053 @section X Resources
|
|
2054 @cindex X resources
|
|
2055 @findex x-create-frame
|
|
2056
|
|
2057 The Emacs resources are generally set per-frame. Each Emacs frame can have
|
|
2058 its own name or the same name as another, depending on the name passed to the
|
|
2059 @code{make-frame} function.
|
|
2060
|
|
2061 You can specify resources for all frames with the syntax:
|
|
2062
|
|
2063 @example
|
|
2064 Emacs*parameter: value
|
|
2065 @end example
|
|
2066 @noindent
|
|
2067
|
|
2068 or
|
|
2069
|
|
2070 @example
|
|
2071 Emacs*EmacsFrame.parameter:value
|
|
2072 @end example
|
|
2073 @noindent
|
|
2074
|
|
2075 You can specify resources for a particular frame with the syntax:
|
|
2076
|
|
2077 @example
|
|
2078 Emacs*FRAME-NAME.parameter: value
|
|
2079 @end example
|
|
2080 @noindent
|
|
2081
|
|
2082 @menu
|
|
2083 * Geometry Resources:: Controlling the size and position of frames.
|
|
2084 * Iconic Resources:: Controlling whether frames come up iconic.
|
|
2085 * Resource List:: List of resources settable on a frame or device.
|
|
2086 * Face Resources:: Controlling faces using resources.
|
|
2087 * Widgets:: The widget hierarchy for XEmacs.
|
|
2088 * Menubar Resources:: Specifying resources for the menubar.
|
|
2089 @end menu
|
|
2090
|
|
2091 @node Geometry Resources
|
|
2092 @subsection Geometry Resources
|
|
2093
|
|
2094 To make the default size of all Emacs frames be 80 columns by 55 lines,
|
|
2095 do this:
|
|
2096
|
|
2097 @example
|
|
2098 Emacs*EmacsFrame.geometry: 80x55
|
|
2099 @end example
|
|
2100 @noindent
|
|
2101
|
|
2102 To set the geometry of a particular frame named @samp{fred}, do this:
|
|
2103
|
|
2104 @example
|
|
2105 Emacs*fred.geometry: 80x55
|
|
2106 @end example
|
|
2107 @noindent
|
|
2108
|
|
2109 Important! Do not use the following syntax:
|
|
2110
|
|
2111 @example
|
|
2112 Emacs*geometry: 80x55
|
|
2113 @end example
|
|
2114 @noindent
|
|
2115
|
|
2116 You should never use @code{*geometry} with any X application. It does
|
|
2117 not say "make the geometry of Emacs be 80 columns by 55 lines." It
|
|
2118 really says, "make Emacs and all subwindows thereof be 80x55 in whatever
|
|
2119 units they care to measure in." In particular, that is both telling the
|
|
2120 Emacs text pane to be 80x55 in characters, and telling the menubar pane
|
|
2121 to be 80x55 pixels, which is surely not what you want.
|
|
2122
|
|
2123 As a special case, this geometry specification also works (and sets the
|
|
2124 default size of all Emacs frames to 80 columns by 55 lines):
|
|
2125
|
|
2126 @example
|
|
2127 Emacs.geometry: 80x55
|
|
2128 @end example
|
|
2129 @noindent
|
|
2130
|
|
2131 since that is the syntax used with most other applications (since most
|
|
2132 other applications have only one top-level window, unlike Emacs). In
|
|
2133 general, however, the top-level shell (the unmapped ApplicationShell
|
|
2134 widget named @samp{Emacs} that is the parent of the shell widgets that
|
|
2135 actually manage the individual frames) does not have any interesting
|
|
2136 resources on it, and you should set the resources on the frames instead.
|
|
2137
|
|
2138 The @code{-geometry} command-line argument sets only the geometry of the
|
|
2139 initial frame created by Emacs.
|
|
2140
|
|
2141 A more complete explanation of geometry-handling is
|
|
2142
|
|
2143 @itemize @bullet
|
|
2144 @item
|
|
2145 The @code{-geometry} command-line option sets the @code{Emacs.geometry}
|
|
2146 resource, that is, the geometry of the ApplicationShell.
|
|
2147
|
|
2148 @item
|
|
2149 For the first frame created, the size of the frame is taken from the
|
|
2150 ApplicationShell if it is specified, otherwise from the geometry of the
|
|
2151 frame.
|
|
2152
|
|
2153 @item
|
|
2154 For subsequent frames, the order is reversed: First the frame, and then
|
|
2155 the ApplicationShell.
|
|
2156
|
|
2157 @item
|
|
2158 For the first frame created, the position of the frame is taken from the
|
|
2159 ApplicationShell (@code{Emacs.geometry}) if it is specified, otherwise
|
|
2160 from the geometry of the frame.
|
|
2161
|
|
2162 @item
|
|
2163 For subsequent frames, the position is taken only from the frame, and
|
|
2164 never from the ApplicationShell.
|
|
2165 @end itemize
|
|
2166
|
|
2167 This is rather complicated, but it does seem to provide the most
|
|
2168 intuitive behavior with respect to the default sizes and positions of
|
|
2169 frames created in various ways.
|
|
2170
|
|
2171 @node Iconic Resources
|
|
2172 @subsection Iconic Resources
|
|
2173
|
|
2174 Analogous to @code{-geometry}, the @code{-iconic} command-line option
|
|
2175 sets the iconic flag of the ApplicationShell (@code{Emacs.iconic}) and
|
|
2176 always applies to the first frame created regardless of its name.
|
|
2177 However, it is possible to set the iconic flag on particular frames (by
|
|
2178 name) by using the @code{Emacs*FRAME-NAME.iconic} resource.
|
|
2179
|
|
2180 @node Resource List
|
|
2181 @subsection Resource List
|
|
2182
|
|
2183 Emacs frames accept the following resources:
|
|
2184
|
|
2185 @table @asis
|
|
2186 @item @code{geometry} (class @code{Geometry}): string
|
|
2187 Initial geometry for the frame. @xref{Geometry Resources} for a
|
|
2188 complete discussion of how this works.
|
|
2189
|
|
2190 @item @code{iconic} (class @code{Iconic}): boolean
|
|
2191 Whether this frame should appear in the iconified state.
|
|
2192
|
|
2193 @item @code{internalBorderWidth} (class @code{InternalBorderWidth}): int
|
|
2194 How many blank pixels to leave between the text and the edge of the
|
|
2195 window.
|
|
2196
|
|
2197 @item @code{interline} (class @code{Interline}): int
|
|
2198 How many pixels to leave between each line (may not be implemented).
|
|
2199
|
|
2200 @item @code{menubar} (class @code{Menubar}): boolean
|
|
2201 Whether newly-created frames should initially have a menubar. Set to
|
|
2202 true by default.
|
|
2203
|
|
2204 @item @code{initiallyUnmapped} (class @code{InitiallyUnmapped}): boolean
|
|
2205 Whether XEmacs should leave the initial frame unmapped when it starts
|
|
2206 up. This is useful if you are starting XEmacs as a server (e.g. in
|
|
2207 conjunction with gnuserv or the external client widget). You can also
|
|
2208 control this with the @code{-unmapped} command-line option.
|
|
2209
|
|
2210 @item @code{barCursor} (class @code{BarColor}): boolean
|
|
2211 Whether the cursor should be displayed as a bar, or the traditional box.
|
|
2212
|
|
2213 @item @code{cursorColor} (class @code{CursorColor}): color-name
|
|
2214 The color of the text cursor.
|
|
2215
|
|
2216 @item @code{scrollBarWidth} (class @code{ScrollBarWidth}): integer
|
|
2217 How wide the vertical scrollbars should be, in pixels; 0 means no
|
|
2218 vertical scrollbars. You can also use a resource specification of the
|
|
2219 form @code{*scrollbar.width}, or the usual toolkit scrollbar resources:
|
|
2220 @code{*XmScrollBar.width} (Motif), @code{*XlwScrollBar.width} (Lucid),
|
|
2221 or @code{*Scrollbar.thickness} (Athena). We don't recommend that you
|
|
2222 use the toolkit resources, though, because they're dependent on how
|
|
2223 exactly your particular build of XEmacs was configured.
|
|
2224
|
|
2225 @item @code{scrollBarHeight} (class @code{ScrollBarHeight}): integer
|
|
2226 How high the horizontal scrollbars should be, in pixels; 0 means no
|
|
2227 horizontal scrollbars. You can also use a resource specification of the
|
|
2228 form @code{*scrollbar.height}, or the usual toolkit scrollbar resources:
|
|
2229 @code{*XmScrollBar.height} (Motif), @code{*XlwScrollBar.height} (Lucid),
|
|
2230 or @code{*Scrollbar.thickness} (Athena). We don't recommend that you use
|
|
2231 the toolkit resources, though, because they're dependent on how exactly
|
|
2232 your particular build of XEmacs was configured.
|
|
2233
|
|
2234 @item @code{scrollBarPlacement} (class @code{ScrollBarPlacement}): string
|
|
2235 Where the horizontal and vertical scrollbars should be positioned. This
|
2
|
2236 should be one of the four strings @samp{BOTTOM_LEFT},
|
|
2237 @samp{BOTTOM_RIGHT}, @samp{TOP_LEFT}, and @samp{TOP_RIGHT}. Default is
|
|
2238 @samp{BOTTOM_RIGHT} for the Motif and Lucid scrollbars and
|
|
2239 @samp{BOTTOM_LEFT} for the Athena scrollbars.
|
0
|
2240
|
|
2241 @item @code{topToolBarHeight} (class @code{TopToolBarHeight}): integer
|
|
2242 @itemx @code{bottomToolBarHeight} (class @code{BottomToolBarHeight}): integer
|
|
2243 @itemx @code{leftToolBarWidth} (class @code{LeftToolBarWidth}): integer
|
|
2244 @itemx @code{rightToolBarWidth} (class @code{RightToolBarWidth}): integer
|
|
2245 Height and width of the four possible toolbars.
|
|
2246
|
|
2247 @item @code{topToolBarShadowColor} (class @code{TopToolBarShadowColor}): color-name
|
|
2248 @itemx @code{bottomToolBarShadowColor} (class @code{BottomToolBarShadowColor}): color-name
|
|
2249 Color of the top and bottom shadows for the toolbars. NOTE: These resources
|
|
2250 do @emph{not} have anything to do with the top and bottom toolbars (i.e. the
|
|
2251 toolbars at the top and bottom of the frame)! Rather, they affect the top
|
|
2252 and bottom shadows around the edges of all four kinds of toolbars.
|
|
2253
|
|
2254 @item @code{topToolBarShadowPixmap} (class @code{TopToolBarShadowPixmap}): pixmap-name
|
|
2255 @itemx @code{bottomToolBarShadowPixmap} (class @code{BottomToolBarShadowPixmap}): pixmap-name
|
|
2256 Pixmap of the top and bottom shadows for the toolbars. If set, these
|
|
2257 resources override the corresponding color resources. NOTE: These
|
|
2258 resources do @emph{not} have anything to do with the top and bottom
|
|
2259 toolbars (i.e. the toolbars at the top and bottom of the frame)!
|
|
2260 Rather, they affect the top and bottom shadows around the edges of all
|
|
2261 four kinds of toolbars.
|
|
2262
|
|
2263 @item @code{toolBarShadowThickness} (class @code{ToolBarShadowThickness}): integer
|
|
2264 Thickness of the shadows around the toolbars, in pixels.
|
|
2265
|
|
2266 @item @code{visualBell} (class @code{VisualBell}): boolean
|
|
2267 Whether XEmacs should flash the screen rather than making an audible beep.
|
|
2268
|
|
2269 @item @code{bellVolume} (class @code{BellVolume}): integer
|
|
2270 Volume of the audible beep.
|
|
2271
|
|
2272 @item @code{useBackingStore} (class @code{UseBackingStore}): boolean
|
|
2273 Whether XEmacs should set the backing-store attribute of the X windows
|
|
2274 it creates. This increases the memory usage of the X server but decreases
|
|
2275 the amount of X traffic necessary to update the screen, and is useful
|
|
2276 when the connection to the X server goes over a low-bandwidth line
|
|
2277 such as a modem connection.
|
|
2278 @end table
|
|
2279
|
|
2280 Emacs devices accept the following resources:
|
|
2281
|
|
2282 @table @asis
|
|
2283 @item @code{textPointer} (class @code{Cursor}): cursor-name
|
|
2284 The cursor to use when the mouse is over text. This resource is used to
|
|
2285 initialize the variable @code{x-pointer-shape}.
|
|
2286
|
|
2287 @item @code{selectionPointer} (class @code{Cursor}): cursor-name
|
|
2288 The cursor to use when the mouse is over a selectable text region (an
|
|
2289 extent with the @samp{highlight} property; for example, an Info
|
|
2290 cross-reference). This resource is used to initialize the variable
|
|
2291 @code{x-selection-pointer-shape}.
|
|
2292
|
|
2293 @item @code{spacePointer} (class @code{Cursor}): cursor-name
|
|
2294 The cursor to use when the mouse is over a blank space in a buffer (that
|
|
2295 is, after the end of a line or after the end-of-file). This resource is
|
|
2296 used to initialize the variable @code{x-nontext-pointer-shape}.
|
|
2297
|
|
2298 @item @code{modeLinePointer} (class @code{Cursor}): cursor-name
|
|
2299 The cursor to use when the mouse is over a modeline. This resource is
|
|
2300 used to initialize the variable @code{x-mode-pointer-shape}.
|
|
2301
|
|
2302 @item @code{gcPointer} (class @code{Cursor}): cursor-name
|
|
2303 The cursor to display when a garbage-collection is in progress. This
|
|
2304 resource is used to initialize the variable @code{x-gc-pointer-shape}.
|
|
2305
|
|
2306 @item @code{scrollbarPointer} (class @code{Cursor}): cursor-name
|
|
2307 The cursor to use when the mouse is over the scrollbar. This resource
|
|
2308 is used to initialize the variable @code{x-scrollbar-pointer-shape}.
|
|
2309
|
|
2310 @item @code{pointerColor} (class @code{Foreground}): color-name
|
|
2311 @itemx @code{pointerBackground} (class @code{Background}): color-name
|
|
2312 The foreground and background colors of the mouse cursor. These
|
|
2313 resources are used to initialize the variables
|
|
2314 @code{x-pointer-foreground-color} and @code{x-pointer-background-color}.
|
|
2315 @end table
|
|
2316
|
|
2317 @node Face Resources
|
|
2318 @subsection Face Resources
|
|
2319
|
|
2320 The attributes of faces are also per-frame. They can be specified as:
|
|
2321
|
|
2322 @example
|
|
2323 Emacs.FACE_NAME.parameter: value
|
|
2324 @end example
|
|
2325 @noindent
|
|
2326
|
|
2327 or
|
|
2328
|
|
2329 @example
|
|
2330 Emacs*FRAME_NAME.FACE_NAME.parameter: value
|
|
2331 @end example
|
|
2332 @noindent
|
|
2333
|
|
2334 Faces accept the following resources:
|
|
2335
|
|
2336 @table @asis
|
|
2337 @item @code{attributeFont} (class @code{AttributeFont}): font-name
|
|
2338 The font of this face.
|
|
2339
|
|
2340 @item @code{attributeForeground} (class @code{AttributeForeground}): color-name
|
|
2341 @itemx @code{attributeBackground} (class @code{AttributeBackground}): color-name
|
|
2342 The foreground and background colors of this face.
|
|
2343
|
|
2344 @item @code{attributeBackgroundPixmap} (class @code{AttributeBackgroundPixmap}): file-name
|
|
2345 The name of an @sc{XBM} file (or @sc{XPM} file, if your version of Emacs
|
|
2346 supports @sc{XPM}), to use as a background stipple.
|
|
2347
|
|
2348 @item @code{attributeUnderline} (class @code{AttributeUnderline}): boolean
|
|
2349 Whether text in this face should be underlined.
|
|
2350 @end table
|
|
2351
|
|
2352 All text is displayed in some face, defaulting to the face named
|
|
2353 @code{default}. To set the font of normal text, use
|
|
2354 @code{Emacs*default.attributeFont}. To set it in the frame named
|
|
2355 @code{fred}, use @code{Emacs*fred.default.attributeFont}.
|
|
2356
|
|
2357 These are the names of the predefined faces:
|
|
2358
|
|
2359 @table @code
|
|
2360 @item default
|
|
2361 Everything inherits from this.
|
|
2362
|
|
2363 @item bold
|
|
2364 If this is not specified in the resource database, Emacs tries to find a
|
|
2365 bold version of the font of the default face.
|
|
2366
|
|
2367 @item italic
|
|
2368 If this is not specified in the resource database, Emacs tries to find
|
|
2369 an italic version of the font of the default face.
|
|
2370
|
|
2371 @item bold-italic
|
|
2372 If this is not specified in the resource database, Emacs tries to find a
|
|
2373 bold-italic version of the font of the default face.
|
|
2374
|
|
2375 @item modeline
|
|
2376 This is the face that the modeline is displayed in. If not specified in
|
|
2377 the resource database, it is determined from the default face by
|
|
2378 reversing the foreground and background colors.
|
|
2379
|
|
2380 @item highlight
|
|
2381 This is the face that highlighted extents (for example, Info
|
|
2382 cross-references and possible completions, when the mouse passes over
|
|
2383 them) are displayed in.
|
|
2384
|
|
2385 @item left-margin
|
|
2386 @itemx right-margin
|
|
2387 These are the faces that the left and right annotation margins are
|
|
2388 displayed in.
|
|
2389
|
|
2390 @item zmacs-region
|
|
2391 This is the face that mouse selections are displayed in.
|
|
2392
|
|
2393 @item isearch
|
|
2394 This is the face that the matched text being searched for is displayed
|
|
2395 in.
|
|
2396
|
|
2397 @item info-node
|
|
2398 This is the face of info menu items. If unspecified, it is copied from
|
|
2399 @code{bold-italic}.
|
|
2400
|
|
2401 @item info-xref
|
|
2402 This is the face of info cross-references. If unspecified, it is copied
|
|
2403 from @code{bold}. (Note that, when the mouse passes over a
|
|
2404 cross-reference, the cross-reference's face is determined from a
|
|
2405 combination of the @code{info-xref} and @code{highlight} faces.)
|
|
2406 @end table
|
|
2407
|
|
2408 Other packages might define their own faces; to see a list of all faces,
|
|
2409 use any of the interactive face-manipulation commands such as
|
|
2410 @code{set-face-font} and type @samp{?} when you are prompted for the
|
|
2411 name of a face.
|
|
2412
|
|
2413 If the @code{bold}, @code{italic}, and @code{bold-italic} faces are not
|
|
2414 specified in the resource database, then XEmacs attempts to derive them
|
|
2415 from the font of the default face. It can only succeed at this if you
|
|
2416 have specified the default font using the XLFD (X Logical Font
|
|
2417 Description) format, which looks like
|
|
2418
|
|
2419 @example
|
|
2420 *-courier-medium-r-*-*-*-120-*-*-*-*-*-*
|
|
2421 @end example
|
|
2422 @noindent
|
|
2423
|
|
2424 If you use any of the other, less strict font name formats, some of which
|
|
2425 look like
|
|
2426
|
|
2427 @example
|
|
2428 lucidasanstypewriter-12
|
|
2429 fixed
|
|
2430 9x13
|
|
2431 @end example
|
|
2432
|
|
2433 then XEmacs won't be able to guess the names of the bold and italic
|
|
2434 versions. All X fonts can be referred to via XLFD-style names, so you
|
|
2435 should use those forms. See the man pages for @samp{X(1)},
|
|
2436 @samp{xlsfonts(1)}, and @samp{xfontsel(1)}.
|
|
2437
|
|
2438 @node Widgets
|
|
2439 @subsection Widgets
|
|
2440
|
|
2441 There are several structural widgets between the terminal EmacsFrame
|
|
2442 widget and the top level ApplicationShell; the exact names and types of
|
|
2443 these widgets change from release to release (for example, they changed
|
|
2444 between 19.8 and 19.9, 19.9 and 19.10, and 19.10 and 19.12) and are
|
|
2445 subject to further change in the future, so you should avoid mentioning
|
|
2446 them in your resource database. The above-mentioned syntaxes should be
|
|
2447 forward- compatible. As of 19.13, the exact widget hierarchy is as
|
|
2448 follows:
|
|
2449
|
|
2450 @example
|
|
2451 INVOCATION-NAME "shell" "container" FRAME-NAME
|
|
2452 x-emacs-application-class "EmacsShell" "EmacsManager" "EmacsFrame"
|
|
2453 @end example
|
|
2454
|
|
2455 where INVOCATION-NAME is the terminal component of the name of the
|
|
2456 XEmacs executable (usually @samp{xemacs}), and
|
|
2457 @samp{x-emacs-application-class} is generally @samp{Emacs}.
|
|
2458
|
|
2459 @node Menubar Resources
|
|
2460 @subsection Menubar Resources
|
|
2461
|
|
2462 As the menubar is implemented as a widget which is not a part of XEacs
|
|
2463 proper, it does not use the fac" mechanism for specifying fonts and
|
|
2464 colors: It uses whatever resources are appropriate to the type of widget
|
|
2465 which is used to implement it.
|
|
2466
|
|
2467 If Emacs was compiled to use only the Motif-lookalike menu widgets, then one
|
|
2468 way to specify the font of the menubar would be
|
|
2469
|
|
2470 @example
|
|
2471 Emacs*menubar*font: *-courier-medium-r-*-*-*-120-*-*-*-*-*-*
|
|
2472 @end example
|
|
2473
|
|
2474 If the Motif library is being used, then one would have to use
|
|
2475
|
|
2476 @example
|
|
2477 Emacs*menubar*fontList: *-courier-medium-r-*-*-*-120-*-*-*-*-*-*
|
|
2478 @end example
|
|
2479
|
|
2480 because the Motif library uses the @code{fontList} resource name instead
|
|
2481 of @code{font}, which has subtly different semantics.
|
|
2482
|
|
2483 The same is true of the scrollbars: They accept whichever resources are
|
|
2484 appropriate for the toolkit in use.
|