comparison man/xemacs/custom.texi @ 410:de805c49cfc1 r21-2-35

Import from CVS: tag r21-2-35
author cvs
date Mon, 13 Aug 2007 11:19:21 +0200
parents 2f8bb876ab1d
children 697ef44129c6
comparison
equal deleted inserted replaced
409:301b9ebbdf3b 410:de805c49cfc1
5 5
6 This chapter talks about various topics relevant to adapting the 6 This chapter talks about various topics relevant to adapting the
7 behavior of Emacs in minor ways. 7 behavior of Emacs in minor ways.
8 8
9 All kinds of customization affect only the particular Emacs job that you 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 10 do them in. They are completely lost when you kill the Emacs job, and
11 no effect on other Emacs jobs you may run at the same time or later. The 11 have no effect on other Emacs jobs you may run at the same time or
12 only way an Emacs job can affect anything outside of it is by writing a 12 later. The only way an Emacs job can affect anything outside of it is
13 file; in particular, the only way to make a customization `permanent' is to 13 by writing a file; in particular, the only way to make a customization
14 put something in your @file{.emacs} file or other appropriate file to do the 14 `permanent' is to put something in your init file or other appropriate
15 customization in each session. @xref{Init File}. 15 file to do the customization in each session. @xref{Init File}.
16 16
17 @menu 17 @menu
18 * Minor Modes:: Each minor mode is one feature you can turn on 18 * Minor Modes:: Each minor mode is one feature you can turn on
19 independently of any others. 19 independently of any others.
20 * Variables:: Many Emacs commands examine Emacs variables 20 * Variables:: Many Emacs commands examine Emacs variables
24 to be replayed with a single command. 24 to be replayed with a single command.
25 * Key Bindings:: The keymaps say what command each key runs. 25 * Key Bindings:: The keymaps say what command each key runs.
26 By changing them, you can "redefine keys". 26 By changing them, you can "redefine keys".
27 * Syntax:: The syntax table controls how words and expressions 27 * Syntax:: The syntax table controls how words and expressions
28 are parsed. 28 are parsed.
29 * Init File:: How to write common customizations in the @file{.emacs} 29 * Init File:: How to write common customizations in the init file.
30 file.
31 * Audible Bell:: Changing how Emacs sounds the bell. 30 * Audible Bell:: Changing how Emacs sounds the bell.
32 * Faces:: Changing the fonts and colors of a region of text. 31 * Faces:: Changing the fonts and colors of a region of text.
33 * Frame Components:: Controlling the presence and positions of the 32 * Frame Components:: Controlling the presence and positions of the
34 menubar, toolbars, and gutters. 33 menubar, toolbars, and gutters.
35 * X Resources:: X resources controlling various aspects of the 34 * X Resources:: X resources controlling various aspects of the
385 C-j}, 384 C-j},
386 385
387 @cindex saving option value 386 @cindex saving option value
388 Setting the option changes its value in the current Emacs session; 387 Setting the option changes its value in the current Emacs session;
389 @dfn{saving} the value changes it for future sessions as well. This 388 @dfn{saving} the value changes it for future sessions as well. This
390 works by writing code into your @file{~/.emacs} file so as to set the 389 works by writing code into your init file so as to set the option
391 option variable again each time you start Emacs. To save the option, 390 variable again each time you start Emacs. @xref{Init File}. To save
392 invoke @samp{[State]} and select the @samp{Save for Future Sessions} 391 the option, invoke @samp{[State]} and select the @samp{Save for Future
393 operation. 392 Sessions} operation.
394 393
395 You can also restore the option to its standard value by invoking 394 You can also restore the option to its standard value by invoking
396 @samp{[State]} and selecting the @samp{Reset} operation. There are 395 @samp{[State]} and selecting the @samp{Reset} operation. There are
397 actually three reset operations: 396 actually three reset operations:
398 397
748 747
749 You may be tempted to turn on Auto Fill mode with a local variable 748 You may be tempted to turn on Auto Fill mode with a local variable
750 list. That is inappropriate. Whether you use Auto Fill mode or not is 749 list. That is inappropriate. Whether you use Auto Fill mode or not is
751 a matter of personal taste, not a matter of the contents of particular 750 a matter of personal taste, not a matter of the contents of particular
752 files. If you want to use Auto Fill, set up major mode hooks with your 751 files. If you want to use Auto Fill, set up major mode hooks with your
753 @file{.emacs} file to turn it on (when appropriate) for you alone 752 file file to turn it on (when appropriate) for you alone
754 (@pxref{Init File}). Don't try to use a local variable list that would 753 (@pxref{Init File}). Don't try to use a local variable list that would
755 impose your taste on everyone working with the file. 754 impose your taste on everyone working with the file.
756 755
757 XEmacs allows you to specify local variables in the first line 756 XEmacs allows you to specify local variables in the first line
758 of a file, in addition to specifying them in the @code{Local Variables} 757 of a file, in addition to specifying them in the @code{Local Variables}
910 This inserts some Lisp code that, when executed later, will define the same 909 This inserts some Lisp code that, when executed later, will define the same
911 macro with the same definition it has now. You need not understand Lisp 910 macro with the same definition it has now. You need not understand Lisp
912 code to do this, because @code{insert-kbd-macro} writes the Lisp code for you. 911 code to do this, because @code{insert-kbd-macro} writes the Lisp code for you.
913 Then save the file. You can load the file with @code{load-file} 912 Then save the file. You can load the file with @code{load-file}
914 (@pxref{Lisp Libraries}). If the file you save in is your initialization file 913 (@pxref{Lisp Libraries}). If the file you save in is your initialization file
915 @file{~/.emacs} (@pxref{Init File}), then the macro will be defined each 914 (@pxref{Init File}), then the macro will be defined each
916 time you run Emacs. 915 time you run Emacs.
917 916
918 If you give @code{insert-kbd-macro} a prefix argument, it creates 917 If you give @code{insert-kbd-macro} a prefix argument, it creates
919 additional Lisp code to record the keys (if any) that you have bound to the 918 additional Lisp code to record the keys (if any) that you have bound to the
920 keyboard macro, so that the macro is reassigned the same keys when you 919 keyboard macro, so that the macro is reassigned the same keys when you
1153 @code{spell-other-window}. 1152 @code{spell-other-window}.
1154 1153
1155 @findex define-key 1154 @findex define-key
1156 @findex substitute-key-definition 1155 @findex substitute-key-definition
1157 The most general way to modify a keymap is the function 1156 The most general way to modify a keymap is the function
1158 @code{define-key}, used in Lisp code (such as your @file{.emacs} file). 1157 @code{define-key}, used in Lisp code (such as your init file).
1159 @code{define-key} takes three arguments: the keymap, the key to modify 1158 @code{define-key} takes three arguments: the keymap, the key to modify
1160 in it, and the new definition. @xref{Init File}, for an example. 1159 in it, and the new definition. @xref{Init File}, for an example.
1161 @code{substitute-key-definition} is used similarly; it takes three 1160 @code{substitute-key-definition} is used similarly; it takes three
1162 arguments, an old definition, a new definition, and a keymap, and 1161 arguments, an old definition, a new definition, and a keymap, and
1163 redefines in that keymap all keys that were previously defined with the 1162 redefines in that keymap all keys that were previously defined with the
1325 can be executed. The purpose of disabling a command is to prevent 1324 can be executed. The purpose of disabling a command is to prevent
1326 beginning users from executing it by accident and being confused. 1325 beginning users from executing it by accident and being confused.
1327 1326
1328 The direct mechanism for disabling a command is to have a non-@code{nil} 1327 The direct mechanism for disabling a command is to have a non-@code{nil}
1329 @code{disabled} property on the Lisp symbol for the command. These 1328 @code{disabled} property on the Lisp symbol for the command. These
1330 properties are normally set by the user's @file{.emacs} file with 1329 properties are normally set by the user's init file with
1331 Lisp expressions such as: 1330 Lisp expressions such as:
1332 1331
1333 @example 1332 @example
1334 (put 'delete-region 'disabled t) 1333 (put 'delete-region 'disabled t)
1335 @end example 1334 @end example
1335
1336 @xref{Init File}.
1336 1337
1337 If the value of the @code{disabled} property is a string, that string 1338 If the value of the @code{disabled} property is a string, that string
1338 is included in the message printed when the command is used: 1339 is included in the message printed when the command is used:
1339 1340
1340 @example 1341 @example
1342 "Text deleted this way cannot be yanked back!\n") 1343 "Text deleted this way cannot be yanked back!\n")
1343 @end example 1344 @end example
1344 1345
1345 @findex disable-command 1346 @findex disable-command
1346 @findex enable-command 1347 @findex enable-command
1347 You can disable a command either by editing the @file{.emacs} file 1348 You can disable a command either by editing the init file
1348 directly or with the command @kbd{M-x disable-command}, which edits the 1349 directly or with the command @kbd{M-x disable-command}, which edits the
1349 @file{.emacs} file for you. @xref{Init File}. 1350 init file for you. @xref{Init File}.
1350 1351
1351 When you attempt to invoke a disabled command interactively in Emacs, 1352 When you attempt to invoke a disabled command interactively in Emacs,
1352 a window is displayed containing the command's name, its 1353 a window is displayed containing the command's name, its
1353 documentation, and some instructions on what to do next; then 1354 documentation, and some instructions on what to do next; then
1354 Emacs asks for input saying whether to execute the command as requested, 1355 Emacs asks for input saying whether to execute the command as requested,
1355 enable it and execute, or cancel it. If you decide to enable the 1356 enable it and execute, or cancel it. If you decide to enable the
1356 command, you are asked whether to do this permanently or just for the 1357 command, you are asked whether to do this permanently or just for the
1357 current session. Enabling permanently works by automatically editing 1358 current session. Enabling permanently works by automatically editing
1358 your @file{.emacs} file. You can use @kbd{M-x enable-command} at any 1359 your init file. You can use @kbd{M-x enable-command} at any
1359 time to enable any command permanently. 1360 time to enable any command permanently.
1360 1361
1361 Whether a command is disabled is independent of what key is used to 1362 Whether a command is disabled is independent of what key is used to
1362 invoke it; it also applies if the command is invoked using @kbd{M-x}. 1363 invoke it; it also applies if the command is invoked using @kbd{M-x}.
1363 Disabling a command has no effect on calling it as a function from Lisp 1364 Disabling a command has no effect on calling it as a function from Lisp
1530 character includes both the string you have to pass to 1531 character includes both the string you have to pass to
1531 @code{modify-syntax-entry} to set up that character's current syntax, 1532 @code{modify-syntax-entry} to set up that character's current syntax,
1532 and some English to explain that string if necessary. 1533 and some English to explain that string if necessary.
1533 1534
1534 @node Init File 1535 @node Init File
1535 @section The Init File, .emacs 1536 @section The Init File
1536 @cindex init file 1537 @cindex init file
1537 @cindex Emacs initialization file 1538 @cindex Emacs initialization file
1538 @cindex key rebinding, permanent 1539 @cindex key rebinding, permanent
1539 @cindex rebinding keys, permanently 1540 @cindex rebinding keys, permanently
1540 1541
1541 When you start Emacs, it normally loads the file @file{.emacs} in your 1542 When you start Emacs, it normally loads either @file{.xemacs/init.el}
1542 home directory. This file, if it exists, should contain Lisp code. It 1543 or the file @file{.emacs} (whichever comes first) in your home directory.
1543 is called your initialization file or @dfn{init file}. Use the command 1544 This file, if it exists, should contain Lisp code. It is called your
1544 line switch @samp{-q} to tell Emacs whether to load an 1545 initialization file or @dfn{init file}. Use the command line switch
1545 init file (@pxref{Entering Emacs}). Use the command line switch 1546 @samp{-q} to tell Emacs whether to load an init file (@pxref{Entering
1546 @samp{-user-init-file} (@pxref{Command Switches}) to tell Emacs to load 1547 Emacs}). Use the command line switch @samp{-user-init-file}
1547 a different file instead of @file{~/.emacs}. 1548 (@pxref{Command Switches}) to tell Emacs to load a different file
1548 1549 instead of @file{~/.xemacs/init.el}/@file{~/.emacs}.
1549 When the @file{.emacs} file is read, the variable @code{user-init-file} 1550
1550 says which init file was loaded. 1551 When the init file is read, the variable @code{user-init-file} says
1552 which init file was loaded.
1551 1553
1552 At some sites there is a @dfn{default init file}, which is the 1554 At some sites there is a @dfn{default init file}, which is the
1553 library named @file{default.el}, found via the standard search path for 1555 library named @file{default.el}, found via the standard search path for
1554 libraries. The Emacs distribution contains no such library; your site 1556 libraries. The Emacs distribution contains no such library; your site
1555 may create one for local customizations. If this library exists, it is 1557 may create one for local customizations. If this library exists, it is
1556 loaded whenever you start Emacs. But your init file, if any, is loaded 1558 loaded whenever you start Emacs. But your init file, if any, is loaded
1557 first; if it sets @code{inhibit-default-init} non-@code{nil}, then 1559 first; if it sets @code{inhibit-default-init} non-@code{nil}, then
1558 @file{default} is not loaded. 1560 @file{default} is not loaded.
1559 1561
1560 If you have a large amount of code in your @file{.emacs} file, you 1562 If you have a large amount of code in your init file, you should
1561 should move it into another file named @file{@var{something}.el}, 1563 byte-compile it to @file{~/.xemacs/init.elc} or @file{~/.emacs.elc}.
1562 byte-compile it (@pxref{Lisp Libraries}), and load that file from your
1563 @file{.emacs} file using @code{load}.
1564 1564
1565 @menu 1565 @menu
1566 * Init Syntax:: Syntax of constants in Emacs Lisp. 1566 * Init Syntax:: Syntax of constants in Emacs Lisp.
1567 * Init Examples:: How to do some things with an init file. 1567 * Init Examples:: How to do some things with an init file.
1568 * Terminal Init:: Each terminal type can have an init file. 1568 * Terminal Init:: Each terminal type can have an init file.
1569 @end menu 1569 @end menu
1570 1570
1571 @node Init Syntax 1571 @node Init Syntax
1572 @subsection Init File Syntax 1572 @subsection Init File Syntax
1573 1573
1574 The @file{.emacs} file contains one or more Lisp function call 1574 The init file contains one or more Lisp function call
1575 expressions. Each consists of a function name followed by 1575 expressions. Each consists of a function name followed by
1576 arguments, all surrounded by parentheses. For example, @code{(setq 1576 arguments, all surrounded by parentheses. For example, @code{(setq
1577 fill-column 60)} represents a call to the function @code{setq} which is 1577 fill-column 60)} represents a call to the function @code{setq} which is
1578 used to set the variable @code{fill-column} (@pxref{Filling}) to 60. 1578 used to set the variable @code{fill-column} (@pxref{Filling}) to 60.
1579 1579
1580 The second argument to @code{setq} is an expression for the new value 1580 The second argument to @code{setq} is an expression for the new value
1581 of the variable. This can be a constant, a variable, or a function call 1581 of the variable. This can be a constant, a variable, or a function call
1582 expression. In @file{.emacs}, constants are used most of the time. 1582 expression. In the init file, constants are used most of the time.
1583 They can be: 1583 They can be:
1584 1584
1585 @table @asis 1585 @table @asis
1586 @item Numbers 1586 @item Numbers
1587 Integers are written in decimal, with an optional initial minus sign. 1587 Integers are written in decimal, with an optional initial minus sign.
1811 the library @file{term/aaa}. The code in the library can use 1811 the library @file{term/aaa}. The code in the library can use
1812 @code{(getenv "TERM")} to find the full terminal type name.@refill 1812 @code{(getenv "TERM")} to find the full terminal type name.@refill
1813 1813
1814 @vindex term-file-prefix 1814 @vindex term-file-prefix
1815 The library's name is constructed by concatenating the value of the 1815 The library's name is constructed by concatenating the value of the
1816 variable @code{term-file-prefix} and the terminal type. Your @file{.emacs} 1816 variable @code{term-file-prefix} and the terminal type. Your init
1817 file can prevent the loading of the terminal-specific library by setting 1817 file can prevent the loading of the terminal-specific library by setting
1818 @code{term-file-prefix} to @code{nil}. 1818 @code{term-file-prefix} to @code{nil}. @xref{Init File}.
1819 1819
1820 @vindex term-setup-hook 1820 @vindex term-setup-hook
1821 The value of the variable @code{term-setup-hook}, if not @code{nil}, is 1821 The value of the variable @code{term-setup-hook}, if not @code{nil}, is
1822 called as a function of no arguments at the end of Emacs initialization, 1822 called as a function of no arguments at the end of Emacs initialization,
1823 after both your @file{.emacs} file and any terminal-specific library have 1823 after both your init file and any terminal-specific library have been
1824 been read. You can set the value in the @file{.emacs} file to override 1824 read. @xref{Init File}. You can set the value in the init file to
1825 part of any of the terminal-specific libraries and to define 1825 override part of any of the terminal-specific libraries and to define
1826 initializations for terminals that do not have a library.@refill 1826 initializations for terminals that do not have a library.@refill
1827 1827
1828 @node Audible Bell 1828 @node Audible Bell
1829 @section Changing the Bell Sound 1829 @section Changing the Bell Sound
1830 @cindex audible bell, changing 1830 @cindex audible bell, changing