(M-28907): Unify M028907.
[chise/xemacs-chise.git] / info / xemacs.info-17
1 This is ../info/xemacs.info, produced by makeinfo version 4.0 from
2 xemacs/xemacs.texi.
3
4 INFO-DIR-SECTION XEmacs Editor
5 START-INFO-DIR-ENTRY
6 * XEmacs: (xemacs).             XEmacs Editor.
7 END-INFO-DIR-ENTRY
8
9    This file documents the XEmacs editor.
10
11    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
12 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
13 Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
14
15    Permission is granted to make and distribute verbatim copies of this
16 manual provided the copyright notice and this permission notice are
17 preserved on all copies.
18
19    Permission is granted to copy and distribute modified versions of
20 this manual under the conditions for verbatim copying, provided also
21 that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
22 General Public License" are included exactly as in the original, and
23 provided that the entire resulting derived work is distributed under the
24 terms of a permission notice identical to this one.
25
26    Permission is granted to copy and distribute translations of this
27 manual into another language, under the above conditions for modified
28 versions, except that the sections entitled "The GNU Manifesto",
29 "Distribution" and "GNU General Public License" may be included in a
30 translation approved by the author instead of in the original English.
31
32 \1f
33 File: xemacs.info,  Node: File Variables,  Prev: Locals,  Up: Variables
34
35 Local Variables in Files
36 ------------------------
37
38    A file can contain a "local variables list", which specifies the
39 values to use for certain Emacs variables when that file is edited.
40 Visiting the file checks for a local variables list and makes each
41 variable in the list local to the buffer in which the file is visited,
42 with the value specified in the file.
43
44    A local variables list goes near the end of the file, in the last
45 page.  (It is often best to put it on a page by itself.)  The local
46 variables list starts with a line containing the string `Local
47 Variables:', and ends with a line containing the string `End:'.  In
48 between come the variable names and values, one set per line, as
49 `VARIABLE: VALUE'.  The VALUEs are not evaluated; they are used
50 literally.
51
52    The line which starts the local variables list does not have to say
53 just `Local Variables:'.  If there is other text before `Local
54 Variables:', that text is called the "prefix", and if there is other
55 text after, that is called the "suffix".  If a prefix or suffix are
56 present, each entry in the local variables list should have the prefix
57 before it and the suffix after it.  This includes the `End:' line.  The
58 prefix and suffix are included to disguise the local variables list as
59 a comment so the compiler or text formatter  will ignore it.  If you do
60 not need to disguise the local variables list as a comment in this way,
61 there is no need to include a prefix or a suffix.
62
63    Two "variable" names are special in a local variables list: a value
64 for the variable `mode' sets the major mode, and a value for the
65 variable `eval' is simply evaluated as an expression and the value is
66 ignored.  These are not real variables; setting them in any other
67 context does not have the same effect.  If `mode' is used in a local
68 variables list, it should be the first entry in the list.
69
70    Here is an example of a local variables list:
71      ;;; Local Variables: ***
72      ;;; mode:lisp ***
73      ;;; comment-column:0 ***
74      ;;; comment-start: ";;; "  ***
75      ;;; comment-end:"***" ***
76      ;;; End: ***
77
78    Note that the prefix is `;;; ' and the suffix is ` ***'.  Note also
79 that comments in the file begin with and end with the same strings.
80 Presumably the file contains code in a language which is enough like
81 Lisp for Lisp mode to be useful but in which comments start and end
82 differently.  The prefix and suffix are used in the local variables
83 list to make the list look like several lines of comments when the
84 compiler or interpreter for that language reads the file.
85
86    The start of the local variables list must be no more than 3000
87 characters from the end of the file, and must be in the last page if the
88 file is divided into pages.  Otherwise, Emacs will not notice it is
89 there.  The purpose is twofold: a stray `Local Variables:' not in the
90 last page does not confuse Emacs, and Emacs never needs to search a
91 long file that contains no page markers and has no local variables list.
92
93    You may be tempted to turn on Auto Fill mode with a local variable
94 list.  That is inappropriate.  Whether you use Auto Fill mode or not is
95 a matter of personal taste, not a matter of the contents of particular
96 files.  If you want to use Auto Fill, set up major mode hooks with your
97 init file to turn it on (when appropriate) for you alone (*note Init
98 File::).  Don't try to use a local variable list that would impose your
99 taste on everyone working with the file.
100
101    XEmacs allows you to specify local variables in the first line of a
102 file, in addition to specifying them in the `Local Variables' section
103 at the end of a file.
104
105    If the first line of a file contains two occurrences of ``-*-'',
106 XEmacs uses the information between them to determine what the major
107 mode and variable settings should be.  For example, these are all legal:
108
109              ;;; -*- mode: emacs-lisp -*-
110              ;;; -*- mode: postscript; version-control: never -*-
111              ;;; -*- tags-file-name: "/foo/bar/TAGS" -*-
112
113    For historical reasons, the syntax ``-*- modename -*-'' is allowed
114 as well; for example, you can use:
115
116              ;;; -*- emacs-lisp -*-
117
118    The variable `enable-local-variables' controls the use of local
119 variables lists in files you visit.  The value can be `t', `nil', or
120 something else.  A value of `t' means local variables lists are obeyed;
121 `nil' means they are ignored; anything else means query.
122
123    The command `M-x normal-mode' always obeys local variables lists and
124 ignores this variable.
125
126 \1f
127 File: xemacs.info,  Node: Keyboard Macros,  Next: Key Bindings,  Prev: Variables,  Up: Customization
128
129 Keyboard Macros
130 ===============
131
132    A "keyboard macro" is a command defined by the user to abbreviate a
133 sequence of keys.  For example, if you discover that you are about to
134 type `C-n C-d' forty times, you can speed your work by defining a
135 keyboard macro to invoke `C-n C-d' and calling it with a repeat count
136 of forty.
137
138 `C-x ('
139      Start defining a keyboard macro (`start-kbd-macro').
140
141 `C-x )'
142      End the definition of a keyboard macro (`end-kbd-macro').
143
144 `C-x e'
145      Execute the most recent keyboard macro (`call-last-kbd-macro').
146
147 `C-u C-x ('
148      Re-execute last keyboard macro, then add more keys to its
149      definition.
150
151 `C-x q'
152      When this point is reached during macro execution, ask for
153      confirmation (`kbd-macro-query').
154
155 `M-x name-last-kbd-macro'
156      Give a command name (for the duration of the session) to the most
157      recently defined keyboard macro.
158
159 `M-x insert-kbd-macro'
160      Insert in the buffer a keyboard macro's definition, as Lisp code.
161
162    Keyboard macros differ from other Emacs commands in that they are
163 written in the Emacs command language rather than in Lisp.  This makes
164 it easier for the novice to write them and makes them more convenient as
165 temporary hacks.  However, the Emacs command language is not powerful
166 enough as a programming language to be useful for writing anything
167 general or complex.  For such things, Lisp must be used.
168
169    You define a keyboard macro by executing the commands which are its
170 definition.  Put differently, as you are defining a keyboard macro, the
171 definition is being executed for the first time.  This way, you see
172 what the effects of your commands are, and don't have to figure them
173 out in your head.  When you are finished, the keyboard macro is defined
174 and also has been executed once.  You can then execute the same set of
175 commands again by invoking the macro.
176
177 * Menu:
178
179 * Basic Kbd Macro::     Defining and running keyboard macros.
180 * Save Kbd Macro::      Giving keyboard macros names; saving them in files.
181 * Kbd Macro Query::     Keyboard macros that do different things each use.
182
183 \1f
184 File: xemacs.info,  Node: Basic Kbd Macro,  Next: Save Kbd Macro,  Up: Keyboard Macros
185
186 Basic Use
187 ---------
188
189    To start defining a keyboard macro, type `C-x ('
190 (`start-kbd-macro').  From then on, anything you type continues to be
191 executed, but also becomes part of the definition of the macro.  `Def'
192 appears in the mode line to remind you of what is going on.  When you
193 are finished, the `C-x )' command (`end-kbd-macro') terminates the
194 definition, without becoming part of it.
195
196    For example,
197
198      C-x ( M-f foo C-x )
199
200 defines a macro to move forward a word and then insert `foo'.
201
202    You can give `C-x )' a repeat count as an argument, in which case it
203 repeats the macro that many times right after defining it, but defining
204 the macro counts as the first repetition (since it is executed as you
205 define it).  If you give `C-x )' an argument of 4, it executes the
206 macro immediately 3 additional times.  An argument of zero to `C-x e'
207 or `C-x )' means repeat the macro indefinitely (until it gets an error
208 or you type `C-g').
209
210    Once you have defined a macro, you can invoke it again with the `C-x
211 e' command (`call-last-kbd-macro').  You can give the command a repeat
212 count numeric argument to execute the macro many times.
213
214    To repeat an operation at regularly spaced places in the text,
215 define a macro and include as part of the macro the commands to move to
216 the next place you want to use it.  For example, if you want to change
217 each line, you should position point at the start of a line, and define
218 a macro to change that line and leave point at the start of the next
219 line.  Repeating the macro will then operate on successive lines.
220
221    After you have terminated the definition of a keyboard macro, you
222 can add to the end of its definition by typing `C-u C-x ('.  This is
223 equivalent to plain `C-x (' followed by retyping the whole definition
224 so far.  As a consequence it re-executes the macro as previously
225 defined.
226
227 \1f
228 File: xemacs.info,  Node: Save Kbd Macro,  Next: Kbd Macro Query,  Prev: Basic Kbd Macro,  Up: Keyboard Macros
229
230 Naming and Saving Keyboard Macros
231 ---------------------------------
232
233    To save a keyboard macro for longer than until you define the next
234 one, you must give it a name using `M-x name-last-kbd-macro'.  This
235 reads a name as an argument using the minibuffer and defines that name
236 to execute the macro.  The macro name is a Lisp symbol, and defining it
237 in this way makes it a valid command name for calling with `M-x' or for
238 binding a key to with `global-set-key' (*note Keymaps::).  If you
239 specify a name that has a prior definition other than another keyboard
240 macro, Emacs prints an error message and nothing is changed.
241
242    Once a macro has a command name, you can save its definition in a
243 file.  You can then use it in another editing session.  First visit the
244 file you want to save the definition in.  Then use the command:
245
246      M-x insert-kbd-macro <RET> MACRONAME <RET>
247
248 This inserts some Lisp code that, when executed later, will define the
249 same macro with the same definition it has now.  You need not
250 understand Lisp code to do this, because `insert-kbd-macro' writes the
251 Lisp code for you.  Then save the file.  You can load the file with
252 `load-file' (*note Lisp Libraries::).  If the file you save in is your
253 initialization file (*note Init File::), then the macro will be defined
254 each time you run Emacs.
255
256    If you give `insert-kbd-macro' a prefix argument, it creates
257 additional Lisp code to record the keys (if any) that you have bound to
258 the keyboard macro, so that the macro is reassigned the same keys when
259 you load the file.
260
261 \1f
262 File: xemacs.info,  Node: Kbd Macro Query,  Prev: Save Kbd Macro,  Up: Keyboard Macros
263
264 Executing Macros With Variations
265 --------------------------------
266
267    You can use `C-x q' (`kbd-macro-query'), to get an effect similar to
268 that of `query-replace'.  The macro asks you  each time whether to make
269 a change.  When you are defining the macro, type `C-x q' at the point
270 where you want the query to occur.  During macro definition, the `C-x
271 q' does nothing, but when you invoke the macro, `C-x q' reads a
272 character from the terminal to decide whether to continue.
273
274    The special answers to a `C-x q' query are <SPC>, <DEL>, `C-d',
275 `C-l', and `C-r'.  Any other character terminates execution of the
276 keyboard macro and is then read as a command.  <SPC> means to continue.
277 <DEL> means to skip the remainder of this repetition of the macro,
278 starting again from the beginning in the next repetition.  `C-d' means
279 to skip the remainder of this repetition and cancel further repetition.
280 `C-l' redraws the frame and asks you again for a character to specify
281 what to do.  `C-r' enters a recursive editing level, in which you can
282 perform editing that is not part of the macro.  When you exit the
283 recursive edit using `C-M-c', you are asked again how to continue with
284 the keyboard macro.  If you type a <SPC> at this time, the rest of the
285 macro definition is executed.  It is up to you to leave point and the
286 text in a state such that the rest of the macro will do what you want.
287
288    `C-u C-x q', which is `C-x q' with a numeric argument, performs a
289 different function.  It enters a recursive edit reading input from the
290 keyboard, both when you type it during the definition of the macro and
291 when it is executed from the macro.  During definition, the editing you
292 do inside the recursive edit does not become part of the macro.  During
293 macro execution, the recursive edit gives you a chance to do some
294 particularized editing.  *Note Recursive Edit::.
295
296 \1f
297 File: xemacs.info,  Node: Key Bindings,  Next: Syntax,  Prev: Keyboard Macros,  Up: Customization
298
299 Customizing Key Bindings
300 ========================
301
302    This section deals with the "keymaps" that define the bindings
303 between keys and functions, and shows how you can customize these
304 bindings.
305
306    A command is a Lisp function whose definition provides for
307 interactive use.  Like every Lisp function, a command has a function
308 name, which is a Lisp symbol whose name usually consists of lower case
309 letters and hyphens.
310
311 * Menu:
312
313 * Keymaps::    Definition of the keymap data structure.
314                Names of Emacs's standard keymaps.
315 * Rebinding::  How to redefine one key's meaning conveniently.
316 * Disabling::  Disabling a command means confirmation is required
317                 before it can be executed.  This is done to protect
318                 beginners from surprises.
319
320 \1f
321 File: xemacs.info,  Node: Keymaps,  Next: Rebinding,  Up: Key Bindings
322
323 Keymaps
324 -------
325
326    The bindings between characters and command functions are recorded in
327 data structures called "keymaps".  Emacs has many of these.  One, the
328 "global" keymap, defines the meanings of the single-character keys that
329 are defined regardless of major mode.  It is the value of the variable
330 `global-map'.
331
332    Each major mode has another keymap, its "local keymap", which
333 contains overriding definitions for the single-character keys that are
334 redefined in that mode.  Each buffer records which local keymap is
335 installed for it at any time, and the current buffer's local keymap is
336 the only one that directly affects command execution.  The local keymaps
337 for Lisp mode, C mode, and many other major modes always exist even when
338 not in use.  They are the values of the variables `lisp-mode-map',
339 `c-mode-map', and so on.  For less frequently used major modes, the
340 local keymap is sometimes constructed only when the mode is used for the
341 first time in a session, to save space.
342
343    There are local keymaps for the minibuffer, too; they contain various
344 completion and exit commands.
345
346    * `minibuffer-local-map' is used for ordinary input (no completion).
347
348    * `minibuffer-local-ns-map' is similar, except that <SPC> exits just
349      like <RET>.  This is used mainly for Mocklisp compatibility.
350
351    * `minibuffer-local-completion-map' is for permissive completion.
352
353    * `minibuffer-local-must-match-map' is for strict completion and for
354      cautious completion.
355
356    * `repeat-complex-command-map' is for use in `C-x <ESC>'.
357
358    * `isearch-mode-map' contains the bindings of the special keys which
359      are bound in the pseudo-mode entered with `C-s' and `C-r'.
360
361    Finally, each prefix key has a keymap which defines the key sequences
362 that start with it.  For example, `ctl-x-map' is the keymap used for
363 characters following a `C-x'.
364
365    * `ctl-x-map' is the variable name for the map used for characters
366      that follow `C-x'.
367
368    * `help-map' is used for characters that follow `C-h'.
369
370    * `esc-map' is for characters that follow <ESC>. All Meta characters
371      are actually defined by this map.
372
373    * `ctl-x-4-map' is for characters that follow `C-x 4'.
374
375    * `mode-specific-map' is for characters that follow `C-c'.
376
377    The definition of a prefix key is the keymap to use for looking up
378 the following character.  Sometimes the definition is actually a Lisp
379 symbol whose function definition is the following character keymap.  The
380 effect is the same, but it provides a command name for the prefix key
381 that you can use as a description of what the prefix key is for.  Thus
382 the binding of `C-x' is the symbol `Ctl-X-Prefix', whose function
383 definition is the keymap for `C-x' commands, the value of `ctl-x-map'.
384
385    Prefix key definitions can appear in either the global map or a
386 local map.  The definitions of `C-c', `C-x', `C-h', and <ESC> as prefix
387 keys appear in the global map, so these prefix keys are always
388 available.  Major modes can locally redefine a key as a prefix by
389 putting a prefix key definition for it in the local map.
390
391    A mode can also put a prefix definition of a global prefix character
392 such as `C-x' into its local map.  This is how major modes override the
393 definitions of certain keys that start with `C-x'.  This case is
394 special, because the local definition does not entirely replace the
395 global one.  When both the global and local definitions of a key are
396 other keymaps, the next character is looked up in both keymaps, with
397 the local definition overriding the global one.  The character after the
398 `C-x' is looked up in both the major mode's own keymap for redefined
399 `C-x' commands and in `ctl-x-map'.  If the major mode's own keymap for
400 `C-x' commands contains `nil', the definition from the global keymap
401 for `C-x' commands is used.
402
403 \1f
404 File: xemacs.info,  Node: Rebinding,  Next: Disabling,  Prev: Keymaps,  Up: Key Bindings
405
406 Changing Key Bindings
407 ---------------------
408
409    You can redefine an Emacs key by changing its entry in a keymap.
410 You can change the global keymap, in which case the change is effective
411 in all major modes except those that have their own overriding local
412 definitions for the same key.  Or you can change the current buffer's
413 local map, which affects all buffers using the same major mode.
414
415 * Menu:
416
417 * Interactive Rebinding::      Changing Key Bindings Interactively
418 * Programmatic Rebinding::     Changing Key Bindings Programmatically
419 * Key Bindings Using Strings:: Using Strings for Changing Key Bindings
420
421 \1f
422 File: xemacs.info,  Node: Interactive Rebinding,  Next: Programmatic Rebinding,  Up: Rebinding
423
424 Changing Key Bindings Interactively
425 ...................................
426
427 `M-x global-set-key <RET> KEY CMD <RET>'
428      Defines KEY globally to run CMD.
429
430 `M-x local-set-key <RET> KEYS CMD <RET>'
431      Defines KEY locally (in the major mode now in effect) to run CMD.
432
433 `M-x local-unset-key <RET> KEYS <RET>'
434      Removes the local binding of KEY.
435
436    CMD is a symbol naming an interactively-callable function.
437
438    When called interactively, KEY is the next complete key sequence
439 that you type.  When called as a function, KEY is a string, a vector of
440 events, or a vector of key-description lists as described in the
441 `define-key' function description.  The binding goes in the current
442 buffer's local map, which is shared with other buffers in the same
443 major mode.
444
445    The following example:
446
447      M-x global-set-key <RET> C-f next-line <RET>
448
449 redefines `C-f' to move down a line.  The fact that CMD is read second
450 makes it serve as a kind of confirmation for KEY.
451
452    These functions offer no way to specify a particular prefix keymap as
453 the one to redefine in, but that is not necessary, as you can include
454 prefixes in KEY.  KEY is read by reading characters one by one until
455 they amount to a complete key (that is, not a prefix key).  Thus, if
456 you type `C-f' for KEY, Emacs enters the minibuffer immediately to read
457 CMD.  But if you type `C-x', another character is read; if that
458 character is `4', another character is read, and so on.  For example,
459
460      M-x global-set-key <RET> C-x 4 $ spell-other-window <RET>
461
462 redefines `C-x 4 $' to run the (fictitious) command
463 `spell-other-window'.
464
465    The most general way to modify a keymap is the function
466 `define-key', used in Lisp code (such as your init file).  `define-key'
467 takes three arguments: the keymap, the key to modify in it, and the new
468 definition.  *Note Init File::, for an example.
469 `substitute-key-definition' is used similarly; it takes three
470 arguments, an old definition, a new definition, and a keymap, and
471 redefines in that keymap all keys that were previously defined with the
472 old definition to have the new definition instead.
473
474 \1f
475 File: xemacs.info,  Node: Programmatic Rebinding,  Next: Key Bindings Using Strings,  Prev: Interactive Rebinding,  Up: Rebinding
476
477 Changing Key Bindings Programmatically
478 ......................................
479
480    You can use the functions `global-set-key' and `define-key' to
481 rebind keys under program control.
482
483 ``(global-set-key KEYS CMD)''
484      Defines KEYS globally to run CMD.
485
486 ``(define-key KEYMAP KEYS DEF)''
487      Defines KEYS to run DEF in the keymap KEYMAP.
488
489    KEYMAP is a keymap object.
490
491    KEYS is the sequence of keystrokes to bind.
492
493    DEF is anything that can be a key's definition:
494
495    * `nil', meaning key is undefined in this keymap
496
497    * A command, that is, a Lisp function suitable for interactive
498      calling
499
500    * A string or key sequence vector, which is treated as a keyboard
501      macro
502
503    * A keymap to define a prefix key
504
505    * A symbol so that when the key is looked up, the symbol stands for
506      its function definition, which should at that time be one of the
507      above, or another symbol whose function definition is used, and so
508      on
509
510    * A cons, `(string . defn)', meaning that DEFN is the definition
511      (DEFN should be a valid definition in its own right)
512
513    * A cons, `(keymap . char)', meaning use the definition of CHAR in
514      map KEYMAP
515
516    For backward compatibility, XEmacs allows you to specify key
517 sequences as strings.  However, the preferred method is to use the
518 representations of key sequences as vectors of keystrokes.  *Note
519 Keystrokes::, for more information about the rules for constructing key
520 sequences.
521
522    Emacs allows you to abbreviate representations for key sequences in
523 most places where there is no ambiguity.  Here are some rules for
524 abbreviation:
525
526    * The keysym by itself is equivalent to a list of just that keysym,
527      i.e., `f1' is equivalent to `(f1)'.
528
529    * A keystroke by itself is equivalent to a vector containing just
530      that keystroke, i.e.,  `(control a)' is equivalent to `[(control
531      a)]'.
532
533    * You can use ASCII codes for keysyms that have them. i.e., `65' is
534      equivalent to `A'. (This is not so much an abbreviation as an
535      alternate representation.)
536
537    Here are some examples of programmatically binding keys:
538
539
540      ;;;  Bind `my-command' to <f1>
541      (global-set-key 'f1 'my-command)
542      
543      ;;;  Bind `my-command' to Shift-f1
544      (global-set-key '(shift f1) 'my-command)
545      
546      ;;; Bind `my-command' to C-c Shift-f1
547      (global-set-key '[(control c) (shift f1)] 'my-command)
548      
549      ;;; Bind `my-command' to the middle mouse button.
550      (global-set-key 'button2 'my-command)
551      
552      ;;; Bind `my-command' to <META> <CTL> <Right Mouse Button>
553      ;;; in the keymap that is in force when you are running `dired'.
554      (define-key dired-mode-map '(meta control button3) 'my-command)
555
556 \1f
557 File: xemacs.info,  Node: Key Bindings Using Strings,  Prev: Programmatic Rebinding,  Up: Rebinding
558
559 Using Strings for Changing Key Bindings
560 .......................................
561
562    For backward compatibility, you can still use strings to represent
563 key sequences.  Thus you can use commands like the following:
564
565      ;;; Bind `end-of-line' to C-f
566      (global-set-key "\C-f" 'end-of-line)
567
568    Note, however, that in some cases you may be binding more than one
569 key sequence by using a single command.  This situation can arise
570 because in ASCII, `C-i' and <TAB> have the same representation.
571 Therefore, when Emacs sees:
572
573      (global-set-key "\C-i" 'end-of-line)
574
575    it is unclear whether the user intended to bind `C-i' or <TAB>.  The
576 solution XEmacs adopts is to bind both of these key sequences.
577
578    After binding a command to two key sequences with a form like:
579
580              (define-key global-map "\^X\^I" 'command-1)
581
582    it is possible to redefine only one of those sequences like so:
583
584              (define-key global-map [(control x) (control i)] 'command-2)
585              (define-key global-map [(control x) tab] 'command-3)
586
587    This applies only when running under a window system.  If you are
588 talking to Emacs through an ASCII-only channel, you do not get any of
589 these features.
590
591    Here is a table of pairs of key sequences that behave in a similar
592 fashion:
593
594              control h      backspace
595              control l      clear
596              control i      tab
597              control m      return
598              control j      linefeed
599              control [      escape
600              control @      control space
601
602 \1f
603 File: xemacs.info,  Node: Disabling,  Prev: Rebinding,  Up: Key Bindings
604
605 Disabling Commands
606 ------------------
607
608    Disabling a command marks it as requiring confirmation before it can
609 be executed.  The purpose of disabling a command is to prevent
610 beginning users from executing it by accident and being confused.
611
612    The direct mechanism for disabling a command is to have a non-`nil'
613 `disabled' property on the Lisp symbol for the command.  These
614 properties are normally set by the user's init file with Lisp
615 expressions such as:
616
617      (put 'delete-region 'disabled t)
618
619    *Note Init File::.
620
621    If the value of the `disabled' property is a string, that string is
622 included in the message printed when the command is used:
623
624      (put 'delete-region 'disabled
625           "Text deleted this way cannot be yanked back!\n")
626
627    You can disable a command either by editing the init file directly
628 or with the command `M-x disable-command', which edits the init file
629 for you.  *Note Init File::.
630
631    When you attempt to invoke a disabled command interactively in Emacs,
632 a window is displayed containing the command's name, its documentation,
633 and some instructions on what to do next; then Emacs asks for input
634 saying whether to execute the command as requested, enable it and
635 execute, or cancel it.  If you decide to enable the command, you are
636 asked whether to do this permanently or just for the current session.
637 Enabling permanently works by automatically editing your init file.
638 You can use `M-x enable-command' at any time to enable any command
639 permanently.
640
641    Whether a command is disabled is independent of what key is used to
642 invoke it; it also applies if the command is invoked using `M-x'.
643 Disabling a command has no effect on calling it as a function from Lisp
644 programs.
645
646 \1f
647 File: xemacs.info,  Node: Syntax,  Next: Init File,  Prev: Key Bindings,  Up: Customization
648
649 The Syntax Table
650 ================
651
652    All the Emacs commands which parse words or balance parentheses are
653 controlled by the "syntax table".  The syntax table specifies which
654 characters are opening delimiters, which are parts of words, which are
655 string quotes, and so on.  Actually, each major mode has its own syntax
656 table (though sometimes related major modes use the same one) which it
657 installs in each buffer that uses that major mode.  The syntax table
658 installed in the current buffer is the one that all commands use, so we
659 call it "the" syntax table.  A syntax table is a Lisp object, a vector
660 of length 256 whose elements are numbers.
661
662 * Menu:
663
664 * Entry: Syntax Entry.    What the syntax table records for each character.
665 * Change: Syntax Change.  How to change the information.
666
667 \1f
668 File: xemacs.info,  Node: Syntax Entry,  Next: Syntax Change,  Up: Syntax
669
670 Information About Each Character
671 --------------------------------
672
673    The syntax table entry for a character is a number that encodes six
674 pieces of information:
675
676    * The syntactic class of the character, represented as a small
677      integer
678
679    * The matching delimiter, for delimiter characters only (the
680      matching delimiter of `(' is `)', and vice versa)
681
682    * A flag saying whether the character is the first character of a
683      two-character comment starting sequence
684
685    * A flag saying whether the character is the second character of a
686      two-character comment starting sequence
687
688    * A flag saying whether the character is the first character of a
689      two-character comment ending sequence
690
691    * A flag saying whether the character is the second character of a
692      two-character comment ending sequence
693
694    The syntactic classes are stored internally as small integers, but
695 are usually described to or by the user with characters.  For example,
696 `(' is used to specify the syntactic class of opening delimiters.  Here
697 is a table of syntactic classes, with the characters that specify them.
698
699 ` '
700      The class of whitespace characters.
701
702 `w'
703      The class of word-constituent characters.
704
705 `_'
706      The class of characters that are part of symbol names but not
707      words.  This class is represented by `_' because the character `_'
708      has this class in both C and Lisp.
709
710 `.'
711      The class of punctuation characters that do not fit into any other
712      special class.
713
714 `('
715      The class of opening delimiters.
716
717 `)'
718      The class of closing delimiters.
719
720 `''
721      The class of expression-adhering characters.  These characters are
722      part of a symbol if found within or adjacent to one, and are part
723      of a following expression if immediately preceding one, but are
724      like whitespace if surrounded by whitespace.
725
726 `"'
727      The class of string-quote characters.  They match each other in
728      pairs, and the characters within the pair all lose their syntactic
729      significance except for the `\' and `/' classes of escape
730      characters, which can be used to include a string-quote inside the
731      string.
732
733 `$'
734      The class of self-matching delimiters.  This is intended for TeX's
735      `$', which is used both to enter and leave math mode.  Thus, a
736      pair of matching `$' characters surround each piece of math mode
737      TeX input.  A pair of adjacent `$' characters act like a single
738      one for purposes of matching.
739
740 `/'
741      The class of escape characters that always just deny the following
742      character its special syntactic significance.  The character after
743      one of these escapes is always treated as alphabetic.
744
745 `\'
746      The class of C-style escape characters.  In practice, these are
747      treated just like `/'-class characters, because the extra
748      possibilities for C escapes (such as being followed by digits)
749      have no effect on where the containing expression ends.
750
751 `<'
752      The class of comment-starting characters.  Only single-character
753      comment starters (such as `;' in Lisp mode) are represented this
754      way.
755
756 `>'
757      The class of comment-ending characters.  Newline has this syntax in
758      Lisp mode.
759
760    The characters flagged as part of two-character comment delimiters
761 can have other syntactic functions most of the time.  For example, `/'
762 and `*' in C code, when found separately, have nothing to do with
763 comments.  The comment-delimiter significance overrides when the pair of
764 characters occur together in the proper order.  Only the list and sexp
765 commands use the syntax table to find comments; the commands
766 specifically for comments have other variables that tell them where to
767 find comments.  Moreover, the list and sexp commands notice comments
768 only if `parse-sexp-ignore-comments' is non-`nil'.  This variable is set
769 to `nil' in modes where comment-terminator sequences are liable to
770 appear where there is no comment, for example, in Lisp mode where the
771 comment terminator is a newline but not every newline ends a comment.
772
773 \1f
774 File: xemacs.info,  Node: Syntax Change,  Prev: Syntax Entry,  Up: Syntax
775
776 Altering Syntax Information
777 ---------------------------
778
779    It is possible to alter a character's syntax table entry by storing
780 a new number in the appropriate element of the syntax table, but it
781 would be hard to determine what number to use.  Emacs therefore
782 provides a command that allows you to specify the syntactic properties
783 of a character in a convenient way.
784
785    `M-x modify-syntax-entry' is the command to change a character's
786 syntax.  It can be used interactively and is also used by major modes
787 to initialize their own syntax tables.  Its first argument is the
788 character to change.  The second argument is a string that specifies the
789 new syntax.  When called from Lisp code, there is a third, optional
790 argument, which specifies the syntax table in which to make the change.
791 If not supplied, or if this command is called interactively, the third
792 argument defaults to the current buffer's syntax table.
793
794   1. The first character in the string specifies the syntactic class.
795      It is one of the characters in the previous table (*note Syntax
796      Entry::).
797
798   2. The second character is the matching delimiter.  For a character
799      that is not an opening or closing delimiter, this should be a
800      space, and may be omitted if no following characters are needed.
801
802   3. The remaining characters are flags.  The flag characters allowed
803      are:
804
805     `1'
806           Flag this character as the first of a two-character comment
807           starting sequence.
808
809     `2'
810           Flag this character as the second of a two-character comment
811           starting sequence.
812
813     `3'
814           Flag this character as the first of a two-character comment
815           ending sequence.
816
817     `4'
818           Flag this character as the second of a two-character comment
819           ending sequence.
820
821    Use `C-h s' (`describe-syntax') to display a description of the
822 contents of the current syntax table.  The description of each
823 character includes both the string you have to pass to
824 `modify-syntax-entry' to set up that character's current syntax, and
825 some English to explain that string if necessary.
826
827 \1f
828 File: xemacs.info,  Node: Init File,  Next: Audible Bell,  Prev: Syntax,  Up: Customization
829
830 The Init File
831 =============
832
833    When you start Emacs, it normally loads either `.xemacs/init.el' or
834 the file `.emacs' (whichever comes first) in your home directory.  This
835 file, if it exists, should contain Lisp code.  It is called your
836 initialization file or "init file".  Use the command line switch `-q'
837 to tell Emacs whether to load an init file (*note Entering Emacs::).
838 Use the command line switch `-user-init-file' (*note Command
839 Switches::) to tell Emacs to load a different file instead of
840 `~/.xemacs/init.el'/`~/.emacs'.
841
842    When the init file is read, the variable `user-init-file' says which
843 init file was loaded.
844
845    At some sites there is a "default init file", which is the library
846 named `default.el', found via the standard search path for libraries.
847 The Emacs distribution contains no such library; your site may create
848 one for local customizations.  If this library exists, it is loaded
849 whenever you start Emacs.  But your init file, if any, is loaded first;
850 if it sets `inhibit-default-init' non-`nil', then `default' is not
851 loaded.
852
853    If you have a large amount of code in your init file, you should
854 byte-compile it to `~/.xemacs/init.elc' or `~/.emacs.elc'.
855
856 * Menu:
857
858 * Init Syntax::     Syntax of constants in Emacs Lisp.
859 * Init Examples::   How to do some things with an init file.
860 * Terminal Init::   Each terminal type can have an init file.
861
862 \1f
863 File: xemacs.info,  Node: Init Syntax,  Next: Init Examples,  Up: Init File
864
865 Init File Syntax
866 ----------------
867
868    The init file contains one or more Lisp function call expressions.
869 Each consists of a function name followed by arguments, all surrounded
870 by parentheses.  For example, `(setq fill-column 60)' represents a call
871 to the function `setq' which is used to set the variable `fill-column'
872 (*note Filling::) to 60.
873
874    The second argument to `setq' is an expression for the new value of
875 the variable.  This can be a constant, a variable, or a function call
876 expression.  In the init file, constants are used most of the time.
877 They can be:
878
879 Numbers
880      Integers are written in decimal, with an optional initial minus
881      sign.
882
883      If a sequence of digits is followed by a period and another
884      sequence of digits, it is interpreted as a floating point number.
885
886      The number prefixes `#b', `#o', and `#x' are supported to
887      represent numbers in binary, octal, and hexadecimal notation (or
888      radix).
889
890 Strings
891      Lisp string syntax is the same as C string syntax with a few extra
892      features.  Use a double-quote character to begin and end a string
893      constant.
894
895      Newlines and special characters may be present literally in
896      strings.  They can also be represented as backslash sequences:
897      `\n' for newline, `\b' for backspace, `\r' for return, `\t' for
898      tab, `\f' for formfeed (control-l), `\e' for escape, `\\' for a
899      backslash, `\"' for a double-quote, or `\OOO' for the character
900      whose octal code is OOO.  Backslash and double-quote are the only
901      characters for which backslash sequences are mandatory.
902
903      You can use `\C-' as a prefix for a control character, as in
904      `\C-s' for ASCII Control-S, and `\M-' as a prefix for a Meta
905      character, as in `\M-a' for Meta-A or `\M-\C-a' for Control-Meta-A.
906
907 Characters
908      Lisp character constant syntax consists of a `?' followed by
909      either a character or an escape sequence starting with `\'.
910      Examples: `?x', `?\n', `?\"', `?\)'.  Note that strings and
911      characters are not interchangeable in Lisp; some contexts require
912      one and some contexts require the other.
913
914 True
915      `t' stands for `true'.
916
917 False
918      `nil' stands for `false'.
919
920 Other Lisp objects
921      Write a single-quote (') followed by the Lisp object you want.
922
923 \1f
924 File: xemacs.info,  Node: Init Examples,  Next: Terminal Init,  Prev: Init Syntax,  Up: Init File
925
926 Init File Examples
927 ------------------
928
929    Here are some examples of doing certain commonly desired things with
930 Lisp expressions:
931
932    * Make <TAB> in C mode just insert a tab if point is in the middle
933      of a line.
934
935           (setq c-tab-always-indent nil)
936
937      Here we have a variable whose value is normally `t' for `true' and
938      the alternative is `nil' for `false'.
939
940    * Make searches case sensitive by default (in all buffers that do not
941      override this).
942
943           (setq-default case-fold-search nil)
944
945      This sets the default value, which is effective in all buffers
946      that do not have local values for the variable.  Setting
947      `case-fold-search' with `setq' affects only the current buffer's
948      local value, which is probably not what you want to do in an init
949      file.
950
951    * Make Text mode the default mode for new buffers.
952
953           (setq default-major-mode 'text-mode)
954
955      Note that `text-mode' is used because it is the command for
956      entering the mode we want.  A single-quote is written before it to
957      make a symbol constant; otherwise, `text-mode' would be treated as
958      a variable name.
959
960    * Turn on Auto Fill mode automatically in Text mode and related
961      modes.
962
963           (setq text-mode-hook
964             '(lambda () (auto-fill-mode 1)))
965
966      Here we have a variable whose value should be a Lisp function.  The
967      function we supply is a list starting with `lambda', and a single
968      quote is written in front of it to make it (for the purpose of this
969      `setq') a list constant rather than an expression.  Lisp functions
970      are not explained here; for mode hooks it is enough to know that
971      `(auto-fill-mode 1)' is an expression that will be executed when
972      Text mode is entered.  You could replace it with any other
973      expression that you like, or with several expressions in a row.
974
975           (setq text-mode-hook 'turn-on-auto-fill)
976
977      This is another way to accomplish the same result.
978      `turn-on-auto-fill' is a symbol whose function definition is
979      `(lambda () (auto-fill-mode 1))'.
980
981    * Load the installed Lisp library named `foo' (actually a file
982      `foo.elc' or `foo.el' in a standard Emacs directory).
983
984           (load "foo")
985
986      When the argument to `load' is a relative pathname, not starting
987      with `/' or `~', `load' searches the directories in `load-path'
988      (*note Loading::).
989
990    * Load the compiled Lisp file `foo.elc' from your home directory.
991
992           (load "~/foo.elc")
993
994      Here an absolute file name is used, so no searching is done.
995
996    * Rebind the key `C-x l' to run the function `make-symbolic-link'.
997
998           (global-set-key "\C-xl" 'make-symbolic-link)
999
1000      or
1001
1002           (define-key global-map "\C-xl" 'make-symbolic-link)
1003
1004      Note once again the single-quote used to refer to the symbol
1005      `make-symbolic-link' instead of its value as a variable.
1006
1007    * Do the same thing for C mode only.
1008
1009           (define-key c-mode-map "\C-xl" 'make-symbolic-link)
1010
1011    * Bind the function key <F1> to a command in C mode.  Note that the
1012      names of function keys must be lower case.
1013
1014           (define-key c-mode-map 'f1 'make-symbolic-link)
1015
1016    * Bind the shifted version of <F1> to a command.
1017
1018           (define-key c-mode-map '(shift f1) 'make-symbolic-link)
1019
1020    * Redefine all keys which now run `next-line' in Fundamental mode to
1021      run `forward-line' instead.
1022
1023           (substitute-key-definition 'next-line 'forward-line
1024                                      global-map)
1025
1026    * Make `C-x C-v' undefined.
1027
1028           (global-unset-key "\C-x\C-v")
1029
1030      One reason to undefine a key is so that you can make it a prefix.
1031      Simply defining `C-x C-v ANYTHING' would make `C-x C-v' a prefix,
1032      but `C-x C-v' must be freed of any non-prefix definition first.
1033
1034    * Make `$' have the syntax of punctuation in Text mode.  Note the
1035      use of a character constant for `$'.
1036
1037           (modify-syntax-entry ?\$ "." text-mode-syntax-table)
1038
1039    * Enable the use of the command `eval-expression' without
1040      confirmation.
1041
1042           (put 'eval-expression 'disabled nil)
1043
1044 \1f
1045 File: xemacs.info,  Node: Terminal Init,  Prev: Init Examples,  Up: Init File
1046
1047 Terminal-Specific Initialization
1048 --------------------------------
1049
1050    Each terminal type can have a Lisp library to be loaded into Emacs
1051 when it is run on that type of terminal.  For a terminal type named
1052 TERMTYPE, the library is called `term/TERMTYPE' and it is found by
1053 searching the directories `load-path' as usual and trying the suffixes
1054 `.elc' and `.el'.  Normally it appears in the subdirectory `term' of
1055 the directory where most Emacs libraries are kept.
1056
1057    The usual purpose of the terminal-specific library is to define the
1058 escape sequences used by the terminal's function keys using the library
1059 `keypad.el'.  See the file `term/vt100.el' for an example of how this
1060 is done.
1061
1062    When the terminal type contains a hyphen, only the part of the name
1063 before the first hyphen is significant in choosing the library name.
1064 Thus, terminal types `aaa-48' and `aaa-30-rv' both use the library
1065 `term/aaa'.  The code in the library can use `(getenv "TERM")' to find
1066 the full terminal type name.
1067
1068    The library's name is constructed by concatenating the value of the
1069 variable `term-file-prefix' and the terminal type.  Your init file can
1070 prevent the loading of the terminal-specific library by setting
1071 `term-file-prefix' to `nil'.  *Note Init File::.
1072
1073    The value of the variable `term-setup-hook', if not `nil', is called
1074 as a function of no arguments at the end of Emacs initialization, after
1075 both your init file and any terminal-specific library have been read.
1076 *Note Init File::.  You can set the value in the init file to override
1077 part of any of the terminal-specific libraries and to define
1078 initializations for terminals that do not have a library.
1079
1080 \1f
1081 File: xemacs.info,  Node: Audible Bell,  Next: Faces,  Prev: Init File,  Up: Customization
1082
1083 Changing the Bell Sound
1084 =======================
1085
1086    You can now change how the audible bell sounds using the variable
1087 `sound-alist'.
1088
1089    `sound-alist''s value is an list associating symbols with, among
1090 other things, strings of audio-data.  When `ding' is called with one of
1091 the symbols, the associated sound data is played instead of the
1092 standard beep.  This only works if you are logged in on the console of a
1093 machine with audio hardware. To listen to a sound of the provided type,
1094 call the function `play-sound' with the argument SOUND. You can also
1095 set the volume of the sound with the optional argument VOLUME.
1096
1097    Each element of `sound-alist' is a list describing a sound.  The
1098 first element of the list is the name of the sound being defined.
1099 Subsequent elements of the list are alternating keyword/value pairs:
1100
1101 `sound'
1102      A string of raw sound data, or the name of another sound to play.
1103      The symbol `t' here means use the default X beep.
1104
1105 `volume'
1106      An integer from 0-100, defaulting to `bell-volume'.
1107
1108 `pitch'
1109      If using the default X beep, the pitch (Hz) to generate.
1110
1111 `duration'
1112      If using the default X beep, the duration (milliseconds).
1113
1114    For compatibility, elements of `sound-alist' may also be of the form:
1115
1116      ( SOUND-NAME . <SOUND> )
1117      ( SOUND-NAME <VOLUME> <SOUND> )
1118
1119    You should probably add things to this list by calling the function
1120 `load-sound-file'.
1121
1122    Note that you can only play audio data if running on the console
1123 screen of a machine with audio hardware which emacs understands, which
1124 at this time means a Sun SparcStation, SGI, or HP9000s700.
1125
1126    Also note that the pitch, duration, and volume options are available
1127 everywhere, but most X servers ignore the `pitch' option.
1128
1129    The variable `bell-volume' should be an integer from 0 to 100, with
1130 100 being loudest, which controls how loud the sounds emacs makes
1131 should be.  Elements of the `sound-alist' may override this value.
1132 This variable applies to the standard X bell sound as well as sound
1133 files.
1134
1135    If the symbol `t' is in place of a sound-string, Emacs uses the
1136 default X beep.  This allows you to define beep-types of different
1137 volumes even when not running on the console.
1138
1139    You can add things to this list by calling the function
1140 `load-sound-file', which reads in an audio-file and adds its data to
1141 the sound-alist. You can specify the sound with the SOUND-NAME argument
1142 and the file into which the sounds are loaded with the FILENAME
1143 argument. The optional VOLUME argument sets the volume.
1144
1145    `load-sound-file (FILENAME SOUND-NAME &optional VOLUME)'
1146
1147    To load and install some sound files as beep-types, use the function
1148 `load-default-sounds' (note that this only works if you are on display
1149 0 of a machine with audio hardware).
1150
1151    The following beep-types are used by Emacs itself. Other Lisp
1152 packages may use other beep types, but these are the ones that the C
1153 kernel of Emacs uses.
1154
1155 `auto-save-error'
1156      An auto-save does not succeed
1157
1158 `command-error'
1159      The Emacs command loop catches an error
1160
1161 `undefined-key'
1162      You type a key that is undefined
1163
1164 `undefined-click'
1165      You use an undefined mouse-click combination
1166
1167 `no-completion'
1168      Completion was not possible
1169
1170 `y-or-n-p'
1171      You type something other than the required `y' or `n'
1172
1173 `yes-or-no-p'
1174      You type something other than `yes' or `no'
1175