diff options
| author | Chong Yidong | 2008-11-17 23:09:04 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-11-17 23:09:04 +0000 |
| commit | 0a11d656fd450189ba43ac86dfd727227bbca86b (patch) | |
| tree | 5c52243e36f3d0f01b958b879dd6e3bbf42d2c6d | |
| parent | cd9da8b8f32e85f0469240d61edcff58d24d44bf (diff) | |
| download | emacs-0a11d656fd450189ba43ac86dfd727227bbca86b.tar.gz emacs-0a11d656fd450189ba43ac86dfd727227bbca86b.zip | |
(Easy Customization): Use "init file" instead of .emacs.
(Customization Groups): Update to new Custom buffer appearance.
(Saving Customizations): Copyedits. Update example.
(Variables): Give example of variable type-sensitivity.
(Examining): Update example.
(Hooks): Copyedits.
(Specifying File Variables): Use C comments instead of an artificial
Lisp for the example.
(Keymaps): Move internals discussion to Prefix Keymaps.
(Rebinding): Remove redundant paragraph (stated in Key Binding).
(Init Rebinding): Document kbd macro.
(Init File): Link to Find Init.
| -rw-r--r-- | doc/emacs/custom.texi | 540 |
1 files changed, 229 insertions, 311 deletions
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi index e01dbd1309b..57f656eb1fe 100644 --- a/doc/emacs/custom.texi +++ b/doc/emacs/custom.texi | |||
| @@ -70,11 +70,11 @@ mode command. Because not all minor modes work this way, we recommend | |||
| 70 | that you avoid changing the mode variables directly; use the mode | 70 | that you avoid changing the mode variables directly; use the mode |
| 71 | commands instead. | 71 | commands instead. |
| 72 | 72 | ||
| 73 | Some minor modes are buffer-local; they apply only to the current | 73 | Some minor modes are @dfn{buffer-local}: they apply only to the |
| 74 | buffer, so you can enable the mode in certain buffers and not others. | 74 | current buffer, so you can enable the mode in certain buffers and not |
| 75 | Other minor modes are global: while enabled, they affect everything | 75 | others. Other minor modes are @dfn{global}: while enabled, they |
| 76 | you do in the Emacs session, in all buffers. Some global minor modes | 76 | affect everything you do in the Emacs session, in all buffers. Some |
| 77 | are enabled by default. | 77 | global minor modes are enabled by default. |
| 78 | 78 | ||
| 79 | The following is a list of some buffer-local minor modes: | 79 | The following is a list of some buffer-local minor modes: |
| 80 | 80 | ||
| @@ -190,29 +190,23 @@ by default. @xref{Mark}. | |||
| 190 | @section Easy Customization Interface | 190 | @section Easy Customization Interface |
| 191 | 191 | ||
| 192 | @cindex settings | 192 | @cindex settings |
| 193 | Emacs has many @dfn{settings} which have values that you can specify | 193 | Emacs has many @dfn{settings} which have values that you can change. |
| 194 | in order to customize various commands. Many are documented in this | 194 | Many are documented in this manual. Most settings are @dfn{user |
| 195 | manual. Most settings are @dfn{user options}---that is to say, Lisp | 195 | options}---that is to say, Lisp variables (@pxref{Variables})---and |
| 196 | variables (@pxref{Variables})---so their names appear in the Variable | 196 | their names appear in the Variable Index (@pxref{Variable Index}). |
| 197 | Index (@pxref{Variable Index}). The other settings are faces and | 197 | The other settings are faces and their attributes (@pxref{Faces}). |
| 198 | their attributes (@pxref{Faces}). | ||
| 199 | 198 | ||
| 200 | @findex customize | 199 | @findex customize |
| 201 | @cindex customization buffer | 200 | @cindex customization buffer |
| 202 | You can browse interactively through settings and change them using | 201 | You can browse settings and change them using @kbd{M-x customize}. |
| 203 | @kbd{M-x customize}. This command creates a @dfn{customization | 202 | This creates a @dfn{customization buffer}, which lets you navigate |
| 204 | buffer}, which offers commands to navigate through a logically | 203 | through a logically organized list of settings, edit and set their |
| 205 | organized structure of the Emacs settings; you can also use it to edit | 204 | values, and save them permanently in your initialization file |
| 206 | and set their values, and to save settings permanently in your | 205 | (@pxref{Init File}). |
| 207 | @file{~/.emacs} file (@pxref{Init File}). | ||
| 208 | |||
| 209 | The appearance of the example buffers in this section is typically | ||
| 210 | different under a graphical display, since faces are then used to indicate | ||
| 211 | buttons, links and editable fields. | ||
| 212 | 206 | ||
| 213 | @menu | 207 | @menu |
| 214 | * Groups: Customization Groups. How settings are classified in a structure. | 208 | * Customization Groups:: How settings are classified in a structure. |
| 215 | * Browsing: Browsing Custom. Browsing and searching for settings. | 209 | * Browsing Custom:: Browsing and searching for settings. |
| 216 | * Changing a Variable:: How to edit an option's value and set the option. | 210 | * Changing a Variable:: How to edit an option's value and set the option. |
| 217 | * Saving Customizations:: Specifying the file for saving customizations. | 211 | * Saving Customizations:: Specifying the file for saving customizations. |
| 218 | * Face Customization:: How to edit the attributes of a face. | 212 | * Face Customization:: How to edit the attributes of a face. |
| @@ -239,16 +233,14 @@ under it. It looks like this, in part: | |||
| 239 | @page | 233 | @page |
| 240 | @smallexample | 234 | @smallexample |
| 241 | @group | 235 | @group |
| 242 | /- Emacs group: ---------------------------------------------------\ | 236 | /- Emacs group: Customization of the One True Editor. -------------\ |
| 243 | [State]: visible group members are all at standard values. | 237 | [State]: visible group members are all at standard values. |
| 244 | Customization of the One True Editor. | 238 | |
| 245 | See also [Manual]. | 239 | See also [Manual]. |
| 246 | 240 | ||
| 247 | Editing group: [Go to Group] | 241 | [Editing] : Basic text editing facilities. |
| 248 | Basic text editing facilities. | ||
| 249 | 242 | ||
| 250 | External group: [Go to Group] | 243 | [External] : Interfacing to external utilities. |
| 251 | Interfacing to external utilities. | ||
| 252 | 244 | ||
| 253 | @var{more second-level groups} | 245 | @var{more second-level groups} |
| 254 | 246 | ||
| @@ -273,19 +265,18 @@ There are also @dfn{buttons} and @dfn{links}, which do something when | |||
| 273 | you @dfn{invoke} them. To invoke a button or a link, either click on | 265 | you @dfn{invoke} them. To invoke a button or a link, either click on |
| 274 | it with @kbd{Mouse-1}, or move point to it and type @key{RET}. | 266 | it with @kbd{Mouse-1}, or move point to it and type @key{RET}. |
| 275 | 267 | ||
| 276 | For example, the phrase @samp{[State]} that appears in | 268 | For example, the phrase @samp{[State]} that appears in a |
| 277 | a second-level group is a button. It operates on the same | 269 | second-level group is a button. It operates on the same customization |
| 278 | customization buffer. The phrase @samp{[Go to Group]} is a kind | 270 | buffer. Each group name, such as @samp{[Editing]}, is a hypertext |
| 279 | of hypertext link to another group. Invoking it creates a new | 271 | link to that group; invoking it creates a new customization buffer, |
| 280 | customization buffer, which shows that group and its contents. | 272 | showing the group and its contents. |
| 281 | 273 | ||
| 282 | The @code{Emacs} group includes a few settings, but mainly it | 274 | The @code{Emacs} group only contains other groups. These groups, in |
| 283 | contains other groups, which contain more groups, which contain the | 275 | turn, can contain settings or still more groups. By browsing the |
| 284 | settings. By browsing the hierarchy of groups, you will eventually | 276 | hierarchy of groups, you will eventually find the feature you are |
| 285 | find the feature you are interested in customizing. Then you can use | 277 | interested in customizing. Then you can use the customization buffer |
| 286 | the customization buffer to set that feature's settings. You can also | 278 | to set that feature's settings. You can also go straight to a |
| 287 | go straight to a particular group by name, using the command @kbd{M-x | 279 | particular group by name, using the command @kbd{M-x customize-group}. |
| 288 | customize-group}. | ||
| 289 | 280 | ||
| 290 | @node Browsing Custom | 281 | @node Browsing Custom |
| 291 | @subsection Browsing and Searching for Options and Faces | 282 | @subsection Browsing and Searching for Options and Faces |
| @@ -442,9 +433,9 @@ field; @kbd{S-@key{TAB}} (@code{widget-backward}) moves backward to | |||
| 442 | the previous button or editable field. | 433 | the previous button or editable field. |
| 443 | 434 | ||
| 444 | Typing @key{RET} on an editable field also moves forward, just like | 435 | Typing @key{RET} on an editable field also moves forward, just like |
| 445 | @key{TAB}. We set it up this way because people often type @key{RET} | 436 | @key{TAB}. You can thus type @key{RET} when you are finished editing |
| 446 | when they are finished editing a field. To insert a newline within an | 437 | a field, to move on to the next button or field. To insert a newline |
| 447 | editable field, use @kbd{C-o} or @kbd{C-q C-j}. | 438 | within an editable field, use @kbd{C-o} or @kbd{C-q C-j}. |
| 448 | 439 | ||
| 449 | @cindex saving a setting | 440 | @cindex saving a setting |
| 450 | @cindex settings, how to save | 441 | @cindex settings, how to save |
| @@ -511,16 +502,17 @@ are hidden, nor on subgroups which are hidden or not visible in the buffer. | |||
| 511 | @node Saving Customizations | 502 | @node Saving Customizations |
| 512 | @subsection Saving Customizations | 503 | @subsection Saving Customizations |
| 513 | 504 | ||
| 505 | @vindex custom-file | ||
| 514 | Saving customizations from the customization buffer works by writing | 506 | Saving customizations from the customization buffer works by writing |
| 515 | code that future sessions will read, code to set up those | 507 | code to a file. By reading this code, future sessions can set up the |
| 516 | customizations again. | 508 | customizations again. Normally, the code is saved in your |
| 509 | initialization file (@pxref{Init File}). | ||
| 517 | 510 | ||
| 518 | @vindex custom-file | 511 | You can choose to save your customizations in a file other than your |
| 519 | Normally this saves customizations in your init file, | 512 | initialization file. To make this work, you must add a couple of |
| 520 | @file{~/.emacs}. If you wish, you can save customizations in another | 513 | lines of code to your initialization file, to set the variable |
| 521 | file instead. To make this work, your @file{~/.emacs} should set | 514 | @code{custom-file} to the name of the desired file, and to load that |
| 522 | @code{custom-file} to the name of that file. Then you should load the | 515 | file. For example: |
| 523 | file by calling @code{load}. For example: | ||
| 524 | 516 | ||
| 525 | @example | 517 | @example |
| 526 | (setq custom-file "~/.emacs-custom.el") | 518 | (setq custom-file "~/.emacs-custom.el") |
| @@ -531,27 +523,24 @@ file by calling @code{load}. For example: | |||
| 531 | files for different Emacs versions, like this: | 523 | files for different Emacs versions, like this: |
| 532 | 524 | ||
| 533 | @example | 525 | @example |
| 534 | (cond ((< emacs-major-version 21) | 526 | (cond ((< emacs-major-version 22) |
| 535 | ;; @r{Emacs 20 customization.} | 527 | ;; @r{Emacs 21 customization.} |
| 536 | (setq custom-file "~/.custom-20.el")) | ||
| 537 | ((and (= emacs-major-version 21) (< emacs-minor-version 4)) | ||
| 538 | ;; @r{Emacs 21 customization, before version 21.4.} | ||
| 539 | (setq custom-file "~/.custom-21.el")) | 528 | (setq custom-file "~/.custom-21.el")) |
| 540 | ((< emacs-major-version 22) | 529 | ((and (= emacs-major-version 22) (< emacs-minor-version 3)) |
| 541 | ;; @r{Emacs version 21.4 or later.} | 530 | ;; @r{Emacs 22 customization, before version 22.3.} |
| 542 | (setq custom-file "~/.custom-21.4.el")) | 531 | (setq custom-file "~/.custom-22.el")) |
| 543 | (t | 532 | (t |
| 544 | ;; @r{Emacs version 22.1 or later.} | 533 | ;; @r{Emacs version 22.3 or later.} |
| 545 | (setq custom-file "~/.custom-22.el"))) | 534 | (setq custom-file "~/.emacs-custom.el"))) |
| 546 | 535 | ||
| 547 | (load custom-file) | 536 | (load custom-file) |
| 548 | @end example | 537 | @end example |
| 549 | 538 | ||
| 550 | If Emacs was invoked with the @option{-q} or @option{--no-init-file} | 539 | If Emacs was invoked with the @option{-q} or @option{--no-init-file} |
| 551 | options (@pxref{Initial Options}), it will not let you save your | 540 | options (@pxref{Initial Options}), it will not let you save your |
| 552 | customizations in your @file{~/.emacs} init file. This is because | 541 | customizations in your initialization file. This is because saving |
| 553 | saving customizations from such a session would wipe out all the other | 542 | customizations from such a session would wipe out all the other |
| 554 | customizations you might have on your init file. | 543 | customizations you might have on your initialization file. |
| 555 | 544 | ||
| 556 | @node Face Customization | 545 | @node Face Customization |
| 557 | @subsection Customizing Faces | 546 | @subsection Customizing Faces |
| @@ -766,32 +755,42 @@ enables the theme.) | |||
| 766 | @cindex user option | 755 | @cindex user option |
| 767 | 756 | ||
| 768 | A @dfn{variable} is a Lisp symbol which has a value. The symbol's | 757 | A @dfn{variable} is a Lisp symbol which has a value. The symbol's |
| 769 | name is also called the name of the variable. A variable name can | 758 | name is also called the @dfn{variable name}. A variable name can |
| 770 | contain any characters that can appear in a file, but conventionally | 759 | contain any characters that can appear in a file, but most variable |
| 771 | variable names consist of words separated by hyphens. A variable can | 760 | names consist of ordinary words separated by hyphens. |
| 772 | have a documentation string which describes what kind of value it should | ||
| 773 | have and how the value will be used. | ||
| 774 | 761 | ||
| 775 | Emacs Lisp allows any variable (with a few exceptions) to have any | 762 | The name of the variable serves as a compact description of its |
| 776 | kind of value, but most variables that Emacs uses expect a value of a | 763 | role. Most variables also have a @dfn{documentation string}, which |
| 777 | certain type. Often the value should always be a string, or should | 764 | describes what the variable's purpose is, what kind of value it should |
| 778 | always be a number. Sometimes we say that a certain feature is turned | 765 | have, and how the value will be used. You can view this documentation |
| 779 | on if a variable is ``non-@code{nil},'' meaning that if the variable's | 766 | using the help command @kbd{C-h v} (@code{describe-variable}). |
| 780 | value is @code{nil}, the feature is off, but the feature is on for | 767 | @xref{Examining}. |
| 781 | @emph{any} other value. The conventional value to use to turn on the | ||
| 782 | feature---since you have to pick one particular value when you set the | ||
| 783 | variable---is @code{t}. | ||
| 784 | 768 | ||
| 785 | Emacs uses many Lisp variables for internal record keeping, but the | 769 | Emacs uses many Lisp variables for internal record keeping, but the |
| 786 | most interesting variables for a non-programmer user are those meant | 770 | most interesting variables for a non-programmer user are those meant |
| 787 | for users to change---these are called @dfn{user options}. | 771 | for users to change---these are called @dfn{user options}. @xref{Easy |
| 772 | Customization}, for information about using the Customize facility to | ||
| 773 | set user options. In the following sections, we describe will other | ||
| 774 | aspects of Emacs variables, such as how to set them outside Customize. | ||
| 788 | 775 | ||
| 789 | Each user option that you can set with the customization buffer is | 776 | Emacs Lisp allows any variable (with a few exceptions) to have any |
| 790 | in fact a Lisp variable. Emacs does not (usually) change the values | 777 | kind of value. However, many variables are meaningful only if |
| 791 | of these variables on its own; instead, you set the values in order to | 778 | assigned values of a certain type. For example, only numbers are |
| 792 | control the behavior of certain Emacs commands. Use of the | 779 | meaningful values for @code{kill-ring-max}, which specifies the |
| 793 | customization buffer is explained above (@pxref{Easy Customization}); | 780 | maximum length of the kill ring (@pxref{Earlier Kills}); if you give |
| 794 | here we describe other aspects of Emacs variables. | 781 | @code{kill-ring-max} a string value, commands such as @kbd{C-y} |
| 782 | (@code{yank}) will signal an error. On the other hand, some variables | ||
| 783 | don't care about type; for instance, if a variable has one effect for | ||
| 784 | @code{nil} values and another effect for ``non-@code{nil}'' values, | ||
| 785 | then any value that is not the symbol @code{nil} induces the second | ||
| 786 | effect, regardless of its type (by convention, we usually use the | ||
| 787 | value @code{t}---a symbol which stands for ``true''---to specify a | ||
| 788 | non-@code{nil} value). If you set a variable using the customization | ||
| 789 | buffer, you need not worry about giving it an invalid type: the | ||
| 790 | customization buffer usually only allows you to enter meaningful | ||
| 791 | values. When in doubt, use @kbd{C-h v} (@code{describe-variable}) to | ||
| 792 | check the variable's documentation string to see kind of value it | ||
| 793 | expects (@pxref{Examining}). | ||
| 795 | 794 | ||
| 796 | @menu | 795 | @menu |
| 797 | * Examining:: Examining or setting one variable's value. | 796 | * Examining:: Examining or setting one variable's value. |
| @@ -832,8 +831,9 @@ fill-column's value is 70 | |||
| 832 | Local in buffer custom.texi; global value is 70 | 831 | Local in buffer custom.texi; global value is 70 |
| 833 | Automatically becomes buffer-local when set in any fashion. | 832 | Automatically becomes buffer-local when set in any fashion. |
| 834 | 833 | ||
| 835 | This variable is safe to use as a file local variable only if its value | 834 | Automatically becomes buffer-local when set in any fashion. |
| 836 | satisfies the predicate `integerp'. | 835 | This variable is safe as a file local variable if its value |
| 836 | satisfies the predicate `integerp'. | ||
| 837 | 837 | ||
| 838 | Documentation: | 838 | Documentation: |
| 839 | *Column beyond which automatic line-wrapping should happen. | 839 | *Column beyond which automatic line-wrapping should happen. |
| @@ -843,14 +843,13 @@ You can customize this variable. | |||
| 843 | @end smallexample | 843 | @end smallexample |
| 844 | 844 | ||
| 845 | @noindent | 845 | @noindent |
| 846 | The line that says you can customize the variable indicates that this | 846 | The line that says ``You can customize the variable'' indicates that |
| 847 | variable is a user option. (The star also indicates this, but it is | 847 | this variable is a user option. @kbd{C-h v} is not restricted to user |
| 848 | an obsolete indicator that may eventually disappear.) @kbd{C-h v} is | 848 | options; it allows any variable name. |
| 849 | not restricted to user options; it allows any variable name. | ||
| 850 | 849 | ||
| 851 | @findex set-variable | 850 | @findex set-variable |
| 852 | The most convenient way to set a specific user option variable is with | 851 | The most convenient way to set a specific user option variable is |
| 853 | @kbd{M-x set-variable}. This reads the variable name with the | 852 | with @kbd{M-x set-variable}. This reads the variable name with the |
| 854 | minibuffer (with completion), and then reads a Lisp expression for the | 853 | minibuffer (with completion), and then reads a Lisp expression for the |
| 855 | new value using the minibuffer a second time (you can insert the old | 854 | new value using the minibuffer a second time (you can insert the old |
| 856 | value into the minibuffer for editing via @kbd{M-n}). For example, | 855 | value into the minibuffer for editing via @kbd{M-n}). For example, |
| @@ -877,27 +876,28 @@ Interaction}. | |||
| 877 | Setting variables, like all means of customizing Emacs except where | 876 | Setting variables, like all means of customizing Emacs except where |
| 878 | otherwise stated, affects only the current Emacs session. The only | 877 | otherwise stated, affects only the current Emacs session. The only |
| 879 | way to alter the variable in future sessions is to put something in | 878 | way to alter the variable in future sessions is to put something in |
| 880 | the @file{~/.emacs} file to set it those sessions (@pxref{Init File}). | 879 | your initialization file to set it those sessions (@pxref{Init File}). |
| 881 | 880 | ||
| 882 | @node Hooks | 881 | @node Hooks |
| 883 | @subsection Hooks | 882 | @subsection Hooks |
| 884 | @cindex hook | 883 | @cindex hook |
| 885 | @cindex running a hook | 884 | @cindex running a hook |
| 886 | 885 | ||
| 887 | @dfn{Hooks} are an important mechanism for customization of Emacs. A | 886 | @dfn{Hooks} are an important mechanism for customizing Emacs. A |
| 888 | hook is a Lisp variable which holds a list of functions, to be called on | 887 | hook is a Lisp variable which holds a list of functions, to be called |
| 889 | some well-defined occasion. (This is called @dfn{running the hook}.) | 888 | on some well-defined occasion. (This is called @dfn{running the |
| 890 | The individual functions in the list are called the @dfn{hook functions} | 889 | hook}.) The individual functions in the list are called the @dfn{hook |
| 891 | of the hook. With rare exceptions, hooks in Emacs are empty when Emacs | 890 | functions} of the hook. With rare exceptions, hooks in Emacs are |
| 892 | starts up, so the only hook functions in any given hook are the ones you | 891 | empty when Emacs starts up, so the only hook functions in any given |
| 893 | explicitly put there as customization. | 892 | hook are the ones you explicitly put there as customization. |
| 894 | 893 | ||
| 895 | Most major modes run one or more @dfn{mode hooks} as the last step of | 894 | Most major modes run one or more @dfn{mode hooks} as the last step |
| 896 | initialization. This makes it easy for you to customize the behavior of | 895 | of initialization. This makes it easy for you to customize the |
| 897 | the mode, by setting up a hook function to override the local variable | 896 | behavior of the mode, by setting up a hook function to override the |
| 898 | assignments already made by the mode. But hooks are also used in other | 897 | local variable assignments already made by the mode. But hooks are |
| 899 | contexts. For example, the hook @code{suspend-hook} runs just before | 898 | also used in other contexts. For example, the hook |
| 900 | Emacs suspends itself (@pxref{Exiting}). | 899 | @code{kill-emacs-hook} runs just before quitting the Emacs job |
| 900 | (@pxref{Exiting}). | ||
| 901 | 901 | ||
| 902 | @cindex normal hook | 902 | @cindex normal hook |
| 903 | Most Emacs hooks are @dfn{normal hooks}. This means that running the | 903 | Most Emacs hooks are @dfn{normal hooks}. This means that running the |
| @@ -1112,41 +1112,37 @@ The same is true for man pages which start with the magic string | |||
| 1112 | @samp{'\"} to specify a list of troff preprocessors (not all do, | 1112 | @samp{'\"} to specify a list of troff preprocessors (not all do, |
| 1113 | however). | 1113 | however). |
| 1114 | 1114 | ||
| 1115 | A @dfn{local variables list} goes near the end of the file, in the | 1115 | A @dfn{local variables list} goes near the end of the file. It |
| 1116 | last page. (It is often best to put it on a page by itself.) The local | 1116 | starts with a line containing the string @samp{Local Variables:}, and |
| 1117 | variables list starts with a line containing the string @samp{Local | 1117 | ends with a line containing the string @samp{End:}. In between come |
| 1118 | Variables:}, and ends with a line containing the string @samp{End:}. In | 1118 | the variable names and values, one set per line, as |
| 1119 | between come the variable names and values, one set per line, as | ||
| 1120 | @samp{@var{variable}:@: @var{value}}. The @var{value}s are not | 1119 | @samp{@var{variable}:@: @var{value}}. The @var{value}s are not |
| 1121 | evaluated; they are used literally. If a file has both a local | 1120 | evaluated; they are used literally. If a file has both a local |
| 1122 | variables list and a @samp{-*-} line, Emacs processes @emph{everything} | 1121 | variables list and a @samp{-*-} line, Emacs processes |
| 1123 | in the @samp{-*-} line first, and @emph{everything} in the local | 1122 | @emph{everything} in the @samp{-*-} line first, and @emph{everything} |
| 1124 | variables list afterward. | 1123 | in the local variables list afterward. |
| 1125 | 1124 | ||
| 1126 | Here is an example of a local variables list: | 1125 | Here is an example of a local variables list: |
| 1127 | 1126 | ||
| 1128 | @example | 1127 | @example |
| 1129 | ;; Local Variables: ** | 1128 | /* Local Variables: */ |
| 1130 | ;; mode:lisp ** | 1129 | /* mode:c */ |
| 1131 | ;; comment-column:0 ** | 1130 | /* comment-column:0 */ |
| 1132 | ;; comment-start: ";; " ** | 1131 | /* End: */ |
| 1133 | ;; comment-end:"**" ** | ||
| 1134 | ;; End: ** | ||
| 1135 | @end example | 1132 | @end example |
| 1136 | 1133 | ||
| 1137 | Each line starts with the prefix @samp{;; } and each line ends with | 1134 | In this example, each line starts with the prefix @samp{/*} and each |
| 1138 | the suffix @samp{ **}. Emacs recognizes these as the prefix and | 1135 | line ends with the suffix @samp{*/}. Emacs recognizes these as the |
| 1139 | suffix based on the first line of the list, by finding them | 1136 | prefix and suffix by finding them surrounding the magic string |
| 1140 | surrounding the magic string @samp{Local Variables:}; then it | 1137 | @samp{Local Variables:}, on the first line of the list; it then |
| 1141 | automatically discards them from the other lines of the list. | 1138 | automatically discards them from the other lines of the list. |
| 1142 | 1139 | ||
| 1143 | The usual reason for using a prefix and/or suffix is to embed the | 1140 | The usual reason for using a prefix and/or suffix is to embed the |
| 1144 | local variables list in a comment, so it won't confuse other programs | 1141 | local variables list in a comment, so it won't confuse other programs |
| 1145 | that the file is intended as input for. The example above is for a | 1142 | that the file is intended as input for. The example above is for the |
| 1146 | language where comment lines start with @samp{;; } and end with | 1143 | C programming language, where comment lines start with @samp{/*} and |
| 1147 | @samp{**}; the local values for @code{comment-start} and | 1144 | end with @samp{*/}. Don't use a prefix (or a suffix) if you don't |
| 1148 | @code{comment-end} customize the rest of Emacs for this unusual | 1145 | need one. |
| 1149 | syntax. Don't use a prefix (or a suffix) if you don't need one. | ||
| 1150 | 1146 | ||
| 1151 | If you write a multi-line string value, you should put the prefix | 1147 | If you write a multi-line string value, you should put the prefix |
| 1152 | and suffix on each line, even lines that start or end within the | 1148 | and suffix on each line, even lines that start or end within the |
| @@ -1192,12 +1188,10 @@ alone (@pxref{Init File}). Don't use a local variable list to impose | |||
| 1192 | your taste on everyone. | 1188 | your taste on everyone. |
| 1193 | 1189 | ||
| 1194 | The start of the local variables list must be no more than 3000 | 1190 | The start of the local variables list must be no more than 3000 |
| 1195 | characters from the end of the file, and must be in the last page if the | 1191 | characters from the end of the file, and must be in the last page if |
| 1196 | file is divided into pages. Otherwise, Emacs will not notice it is | 1192 | the file is divided into pages. Otherwise, Emacs will not notice it |
| 1197 | there. The purpose of this rule is so that a stray @samp{Local | 1193 | is there. The purpose of this rule is so that Emacs need not take the |
| 1198 | Variables:}@: not in the last page does not confuse Emacs, and so that | 1194 | time to search the whole file. |
| 1199 | visiting a long file that is all one page and has no local variables | ||
| 1200 | list need not take the time to search the whole file. | ||
| 1201 | 1195 | ||
| 1202 | Use the command @code{normal-mode} to reset the local variables and | 1196 | Use the command @code{normal-mode} to reset the local variables and |
| 1203 | major mode of a buffer according to the file name and contents, | 1197 | major mode of a buffer according to the file name and contents, |
| @@ -1361,12 +1355,12 @@ name, which usually consists of lower-case letters and hyphens. | |||
| 1361 | in data structures called @dfn{keymaps}. Emacs has many of these, each | 1355 | in data structures called @dfn{keymaps}. Emacs has many of these, each |
| 1362 | used on particular occasions. | 1356 | used on particular occasions. |
| 1363 | 1357 | ||
| 1364 | Recall that a @dfn{key sequence} (@dfn{key}, for short) is a sequence | 1358 | A @dfn{key sequence} (@dfn{key}, for short) is a sequence of |
| 1365 | of @dfn{input events} that have a meaning as a unit. Input events | 1359 | @dfn{input events} that have a meaning as a unit. Input events |
| 1366 | include characters, function keys and mouse buttons---all the inputs | 1360 | include characters, function keys and mouse buttons---all the inputs |
| 1367 | that you can send to the computer with your terminal. A key sequence | 1361 | that you can send to the computer with your terminal. A key sequence |
| 1368 | gets its meaning from its @dfn{binding}, which says what command it | 1362 | gets its meaning from its @dfn{binding}, which says what command it |
| 1369 | runs. The function of keymaps is to record these bindings. | 1363 | runs. The role of keymaps is to record these bindings. |
| 1370 | 1364 | ||
| 1371 | @cindex global keymap | 1365 | @cindex global keymap |
| 1372 | The @dfn{global} keymap is the most important keymap because it is | 1366 | The @dfn{global} keymap is the most important keymap because it is |
| @@ -1383,48 +1377,26 @@ Commands to rebind keys, such as @kbd{M-x global-set-key}, actually work | |||
| 1383 | by storing the new binding in the proper place in the global map. | 1377 | by storing the new binding in the proper place in the global map. |
| 1384 | @xref{Rebinding}. | 1378 | @xref{Rebinding}. |
| 1385 | 1379 | ||
| 1386 | Meta characters work differently; Emacs translates each Meta | ||
| 1387 | character into a pair of characters starting with @key{ESC}. When you | ||
| 1388 | type the character @kbd{M-a} in a key sequence, Emacs replaces it with | ||
| 1389 | @kbd{@key{ESC} a}. A meta key comes in as a single input event, but | ||
| 1390 | becomes two events for purposes of key bindings. The reason for this is | ||
| 1391 | historical, and we might change it someday. | ||
| 1392 | |||
| 1393 | @cindex function key | 1380 | @cindex function key |
| 1394 | Most modern keyboards have function keys as well as character keys. | 1381 | Most modern keyboards have function keys as well as character keys. |
| 1395 | Function keys send input events just as character keys do, and keymaps | 1382 | Function keys send input events just as character keys do, and keymaps |
| 1396 | can have bindings for them. | 1383 | can have bindings for them. On text terminals, typing a function key |
| 1397 | 1384 | actually sends the computer a sequence of characters; the precise | |
| 1398 | On text terminals, typing a function key actually sends the computer a | 1385 | details of the sequence depends on which function key and on the model |
| 1399 | sequence of characters; the precise details of the sequence depends on | 1386 | of terminal you are using. (Often the sequence starts with |
| 1400 | which function key and on the model of terminal you are using. (Often | 1387 | @kbd{@key{ESC} [}.) If Emacs understands your terminal type properly, |
| 1401 | the sequence starts with @kbd{@key{ESC} [}.) If Emacs understands your | 1388 | it recognizes the character sequences forming function keys wherever |
| 1402 | terminal type properly, it recognizes the character sequences forming | 1389 | they occur in a key sequence. Thus, for most purposes, you can |
| 1403 | function keys wherever they occur in a key sequence (not just at the | 1390 | pretend the function keys reach Emacs directly and ignore their |
| 1404 | beginning). Thus, for most purposes, you can pretend the function keys | 1391 | encoding as character sequences. |
| 1405 | reach Emacs directly and ignore their encoding as character sequences. | 1392 | |
| 1406 | 1393 | Key sequences can mix function keys and characters. For example, if | |
| 1407 | @cindex mouse | 1394 | your keyboard has a @key{Home} function key, Emacs also recognizes key |
| 1408 | Mouse buttons also produce input events. These events come with other | 1395 | sequences like @kbd{C-x @key{Home}}. You can even mix mouse events |
| 1409 | data---the window and position where you pressed or released the button, | 1396 | with keyboard events, but we recommend against it, because such key |
| 1410 | and a time stamp. But only the choice of button matters for key | 1397 | sequences are inconvenient to use. |
| 1411 | bindings; the other data matters only if a command looks at it. | 1398 | |
| 1412 | (Commands designed for mouse invocation usually do look at the other | 1399 | As a user, you can redefine any key, but it is usually best to stick |
| 1413 | data.) | ||
| 1414 | |||
| 1415 | A keymap records definitions for single events. Interpreting a key | ||
| 1416 | sequence of multiple events involves a chain of keymaps. The first | ||
| 1417 | keymap gives a definition for the first event; this definition is | ||
| 1418 | another keymap, which is used to look up the second event in the | ||
| 1419 | sequence, and so on. | ||
| 1420 | |||
| 1421 | Key sequences can mix function keys and characters. For example, | ||
| 1422 | @kbd{C-x @key{SELECT}} is meaningful. If you make @key{SELECT} a prefix | ||
| 1423 | key, then @kbd{@key{SELECT} C-n} makes sense. You can even mix mouse | ||
| 1424 | events with keyboard events, but we recommend against it, because such | ||
| 1425 | key sequences are inconvenient to use. | ||
| 1426 | |||
| 1427 | As a user, you can redefine any key; but it is usually best to stick | ||
| 1428 | to key sequences that consist of @kbd{C-c} followed by a letter (upper | 1400 | to key sequences that consist of @kbd{C-c} followed by a letter (upper |
| 1429 | or lower case). These keys are ``reserved for users,'' so they won't | 1401 | or lower case). These keys are ``reserved for users,'' so they won't |
| 1430 | conflict with any properly designed Emacs extension. The function | 1402 | conflict with any properly designed Emacs extension. The function |
| @@ -1435,9 +1407,13 @@ extensions or major modes which redefine the same key. | |||
| 1435 | @node Prefix Keymaps | 1407 | @node Prefix Keymaps |
| 1436 | @subsection Prefix Keymaps | 1408 | @subsection Prefix Keymaps |
| 1437 | 1409 | ||
| 1438 | A prefix key such as @kbd{C-x} or @key{ESC} has its own keymap, | 1410 | Internally, Emacs records only single events in each keymap. |
| 1439 | which holds the definition for the event that immediately follows | 1411 | Interpreting a key sequence of multiple events involves a chain of |
| 1440 | that prefix. | 1412 | keymaps: the first keymap gives a definition for the first event, |
| 1413 | which is another keymap, which is used to look up the second event in | ||
| 1414 | the sequence, and so on. Thus, a prefix key such as @kbd{C-x} or | ||
| 1415 | @key{ESC} has its own keymap, which holds the definition for the event | ||
| 1416 | that immediately follows that prefix. | ||
| 1441 | 1417 | ||
| 1442 | The definition of a prefix key is usually the keymap to use for | 1418 | The definition of a prefix key is usually the keymap to use for |
| 1443 | looking up the following event. The definition can also be a Lisp | 1419 | looking up the following event. The definition can also be a Lisp |
| @@ -1631,11 +1607,6 @@ M-x global-set-key @key{RET} C-x 4 $ spell-other-window @key{RET} | |||
| 1631 | redefines @kbd{C-x 4 $} to run the (fictitious) command | 1607 | redefines @kbd{C-x 4 $} to run the (fictitious) command |
| 1632 | @code{spell-other-window}. | 1608 | @code{spell-other-window}. |
| 1633 | 1609 | ||
| 1634 | The two-character keys consisting of @kbd{C-c} followed by a letter | ||
| 1635 | are reserved for user customizations. Lisp programs are not supposed to | ||
| 1636 | define these keys, so the bindings you make for them will be available | ||
| 1637 | in all major modes and will never get in the way of anything. | ||
| 1638 | |||
| 1639 | You can remove the global definition of a key with | 1610 | You can remove the global definition of a key with |
| 1640 | @code{global-unset-key}. This makes the key @dfn{undefined}; if you | 1611 | @code{global-unset-key}. This makes the key @dfn{undefined}; if you |
| 1641 | type it, Emacs will just beep. Similarly, @code{local-unset-key} makes | 1612 | type it, Emacs will just beep. Similarly, @code{local-unset-key} makes |
| @@ -1660,67 +1631,68 @@ command is less work to invoke when you really want to. | |||
| 1660 | @c it, the tutorial needs to be adjusted. (TUTORIAL.de) | 1631 | @c it, the tutorial needs to be adjusted. (TUTORIAL.de) |
| 1661 | 1632 | ||
| 1662 | If you have a set of key bindings that you like to use all the time, | 1633 | If you have a set of key bindings that you like to use all the time, |
| 1663 | you can specify them in your @file{.emacs} file by using their Lisp | 1634 | you can specify them in your initialization file by writing Lisp code |
| 1664 | syntax. (@xref{Init File}.) | 1635 | (@pxref{Init File}). |
| 1665 | 1636 | ||
| 1666 | The simplest method for doing this works for @acronym{ASCII} characters and | 1637 | @findex kbd |
| 1667 | Meta-modified @acronym{ASCII} characters only. This method uses a string to | 1638 | There are several ways to write a key binding using Lisp. The |
| 1668 | represent the key sequence you want to rebind. For example, here's how | 1639 | simplest is to use the @code{kbd} macro, which converts a textual |
| 1669 | to bind @kbd{C-z} to @code{shell}: | 1640 | representation of a key sequence---similar to how we have written key |
| 1641 | sequences in this manual---into a form that can be passed as an | ||
| 1642 | argument to @code{global-set-key}. For example, here's how to bind | ||
| 1643 | @kbd{C-z} to @code{shell} (@pxref{Interactive Shell}): | ||
| 1670 | 1644 | ||
| 1671 | @example | 1645 | @example |
| 1672 | (global-set-key "\C-z" 'shell) | 1646 | (global-set-key (kbd "C-z") 'shell) |
| 1673 | @end example | 1647 | @end example |
| 1674 | 1648 | ||
| 1675 | @noindent | 1649 | @noindent |
| 1676 | This example uses a string constant containing one character, | 1650 | The single-quote before the command name, @code{shell}, marks it as a |
| 1677 | @kbd{C-z}. (@samp{\C-} is string syntax for a control character.) The | ||
| 1678 | single-quote before the command name, @code{shell}, marks it as a | ||
| 1679 | constant symbol rather than a variable. If you omit the quote, Emacs | 1651 | constant symbol rather than a variable. If you omit the quote, Emacs |
| 1680 | would try to evaluate @code{shell} immediately as a variable. This | 1652 | would try to evaluate @code{shell} as a variable. This probably |
| 1681 | probably causes an error; it certainly isn't what you want. | 1653 | causes an error; it certainly isn't what you want. |
| 1682 | 1654 | ||
| 1683 | Here is another example that binds the key sequence @kbd{C-x M-l}: | 1655 | Here are some additional examples, including binding function keys |
| 1656 | and mouse events: | ||
| 1684 | 1657 | ||
| 1685 | @example | 1658 | @example |
| 1686 | (global-set-key "\C-x\M-l" 'make-symbolic-link) | 1659 | (global-set-key (kbd "C-c y") 'clipboard-yank) |
| 1660 | (global-set-key (kbd "C-M-q") 'query-replace) | ||
| 1661 | (global-set-key (kbd "<f5>") 'flyspell-mode) | ||
| 1662 | (global-set-key (kbd "C-<f5>") 'linum-mode) | ||
| 1663 | (global-set-key (kbd "C-<right>") 'forward-sentence) | ||
| 1664 | (global-set-key (kbd "<mouse-2>") 'mouse-save-then-kill) | ||
| 1665 | (global-set-key (kbd "C-<down-mouse-3>") 'mouse-yank-at-click) | ||
| 1687 | @end example | 1666 | @end example |
| 1688 | 1667 | ||
| 1689 | To put @key{TAB}, @key{RET}, @key{ESC}, or @key{DEL} in the | 1668 | Instead of using the @code{kbd} macro, you can use a Lisp string or |
| 1690 | string, you can use the Emacs Lisp escape sequences, @samp{\t}, | 1669 | vector to specify the key sequence. Using a string is simpler, but |
| 1691 | @samp{\r}, @samp{\e}, and @samp{\d}. Here is an example which binds | 1670 | only works for @acronym{ASCII} characters and Meta-modified |
| 1692 | @kbd{C-x @key{TAB}}: | 1671 | @acronym{ASCII} characters. For example, here's how to bind @kbd{C-x |
| 1672 | M-l} to @code{make-symbolic-link} (@pxref{Misc File Ops}): | ||
| 1693 | 1673 | ||
| 1694 | @example | 1674 | @example |
| 1695 | (global-set-key "\C-x\t" 'indent-rigidly) | 1675 | (global-set-key "\C-x\M-l" 'make-symbolic-link) |
| 1696 | @end example | 1676 | @end example |
| 1697 | 1677 | ||
| 1698 | These examples show how to write some other special @acronym{ASCII} characters | 1678 | To put @key{TAB}, @key{RET}, @key{ESC}, or @key{DEL} in the string, |
| 1699 | in strings for key bindings: | 1679 | use the Emacs Lisp escape sequences @samp{\t}, @samp{\r}, @samp{\e}, |
| 1680 | and @samp{\d} respectively. Here is an example which binds @kbd{C-x | ||
| 1681 | @key{TAB}} to @code{indent-rigidly} (@pxref{Indentation}): | ||
| 1700 | 1682 | ||
| 1701 | @example | 1683 | @example |
| 1702 | (global-set-key "\r" 'newline) ;; @key{RET} | 1684 | (global-set-key "\C-x\t" 'indent-rigidly) |
| 1703 | (global-set-key "\d" 'delete-backward-char) ;; @key{DEL} | ||
| 1704 | (global-set-key "\C-x\e\e" 'repeat-complex-command) ;; @key{ESC} | ||
| 1705 | @end example | 1685 | @end example |
| 1706 | 1686 | ||
| 1707 | When the key sequence includes function keys or mouse button events, | 1687 | When the key sequence includes function keys or mouse button events, |
| 1708 | or non-@acronym{ASCII} characters such as @code{C-=} or @code{H-a}, you must use | 1688 | or non-@acronym{ASCII} characters such as @code{C-=} or @code{H-a}, |
| 1709 | the more general method of rebinding, which uses a vector to specify the | 1689 | you must use a vector to specify the key sequence. Each element in |
| 1710 | key sequence. | 1690 | the vector stands for an input event; the elements are separated by |
| 1711 | 1691 | spaces and surrounded by a pair of square brackets. If an element is | |
| 1712 | The way to write a vector in Emacs Lisp is with square brackets around | 1692 | a symbol, simply write the symbol's name---no other delimiters or |
| 1713 | the vector elements. Use spaces to separate the elements. If an | 1693 | punctuation are needed. If a vector element is a character, write it |
| 1714 | element is a symbol, simply write the symbol's name---no other | 1694 | as a Lisp character constant: @samp{?} followed by the character as it |
| 1715 | delimiters or punctuation are needed. If a vector element is a | 1695 | would appear in a string. Here are some examples: |
| 1716 | character, write it as a Lisp character constant: @samp{?} followed by | ||
| 1717 | the character as it would appear in a string. | ||
| 1718 | |||
| 1719 | Here are examples of using vectors to rebind @kbd{C-=} (a control | ||
| 1720 | character not in @acronym{ASCII}), @kbd{C-M-=} (not in @acronym{ASCII} because @kbd{C-=} | ||
| 1721 | is not), @kbd{H-a} (a Hyper character; @acronym{ASCII} doesn't have Hyper at | ||
| 1722 | all), @key{F7} (a function key), and @kbd{C-Mouse-1} (a | ||
| 1723 | keyboard-modified mouse button): | ||
| 1724 | 1696 | ||
| 1725 | @example | 1697 | @example |
| 1726 | (global-set-key [?\C-=] 'make-symbolic-link) | 1698 | (global-set-key [?\C-=] 'make-symbolic-link) |
| @@ -1730,25 +1702,15 @@ keyboard-modified mouse button): | |||
| 1730 | (global-set-key [C-mouse-1] 'make-symbolic-link) | 1702 | (global-set-key [C-mouse-1] 'make-symbolic-link) |
| 1731 | @end example | 1703 | @end example |
| 1732 | 1704 | ||
| 1733 | You can use a vector for the simple cases too. Here's how to | 1705 | @noindent |
| 1734 | rewrite the first six examples above to use vectors: | 1706 | You can use a vector for the simple cases too: |
| 1735 | 1707 | ||
| 1736 | @example | 1708 | @example |
| 1737 | (global-set-key [?\C-z] 'shell) | 1709 | (global-set-key [?\C-z ?\M-l] 'make-symbolic-link) |
| 1738 | (global-set-key [?\C-x ?l] 'make-symbolic-link) | ||
| 1739 | (global-set-key [?\C-x ?\t] 'indent-rigidly) | ||
| 1740 | (global-set-key [?\r] 'newline) | ||
| 1741 | (global-set-key [?\d] 'delete-backward-char) | ||
| 1742 | (global-set-key [?\C-x ?\e ?\e] 'repeat-complex-command) | ||
| 1743 | @end example | 1710 | @end example |
| 1744 | 1711 | ||
| 1745 | @noindent | 1712 | Language and coding systems may cause problems with key bindings for |
| 1746 | As you see, you represent a multi-character key sequence with a vector | 1713 | non-@acronym{ASCII} characters. @xref{Init Non-ASCII}. |
| 1747 | by listing all of the characters, in order, within the square brackets | ||
| 1748 | that delimit the vector. | ||
| 1749 | |||
| 1750 | Language and coding systems can cause problems with key bindings | ||
| 1751 | for non-@acronym{ASCII} characters. @xref{Init Non-ASCII}. | ||
| 1752 | 1714 | ||
| 1753 | @node Modifier Keys | 1715 | @node Modifier Keys |
| 1754 | @subsection Modifier Keys | 1716 | @subsection Modifier Keys |
| @@ -1762,8 +1724,8 @@ and does not apply to ``shifted'' versions of other keys; for | |||
| 1762 | instance, @kbd{C-@@} is not the same as @kbd{C-2}. | 1724 | instance, @kbd{C-@@} is not the same as @kbd{C-2}. |
| 1763 | 1725 | ||
| 1764 | When you customize Emacs, you can make modified alphabetical | 1726 | When you customize Emacs, you can make modified alphabetical |
| 1765 | characters case-sensitive way. For instance, you could make @kbd{M-a} | 1727 | characters case-sensitive. For instance, you could make @kbd{M-a} and |
| 1766 | and @kbd{M-A} run different commands. | 1728 | @kbd{M-A} run different commands. |
| 1767 | 1729 | ||
| 1768 | As a special exception, a @key{Control}-modified alphabetical | 1730 | As a special exception, a @key{Control}-modified alphabetical |
| 1769 | character is always case-insensitive, for historical reasons: Emacs | 1731 | character is always case-insensitive, for historical reasons: Emacs |
| @@ -1830,52 +1792,7 @@ X) may use different names. To make certain what symbol is used for a | |||
| 1830 | given function key on your terminal, type @kbd{C-h c} followed by that | 1792 | given function key on your terminal, type @kbd{C-h c} followed by that |
| 1831 | key. | 1793 | key. |
| 1832 | 1794 | ||
| 1833 | A key sequence which contains function key symbols (or anything but | 1795 | @xref{Init Rebinding}, for examples of binding function keys. |
| 1834 | @acronym{ASCII} characters) must be a vector rather than a string. | ||
| 1835 | Thus, to bind function key @samp{f1} to the command @code{rmail}, | ||
| 1836 | write the following: | ||
| 1837 | |||
| 1838 | @example | ||
| 1839 | (global-set-key [f1] 'rmail) | ||
| 1840 | @end example | ||
| 1841 | |||
| 1842 | @noindent | ||
| 1843 | To bind the right-arrow key to the command @code{forward-char}, you can | ||
| 1844 | use this expression: | ||
| 1845 | |||
| 1846 | @example | ||
| 1847 | (global-set-key [right] 'forward-char) | ||
| 1848 | @end example | ||
| 1849 | |||
| 1850 | @noindent | ||
| 1851 | This uses the Lisp syntax for a vector containing the symbol | ||
| 1852 | @code{right}. (This binding is present in Emacs by default.) | ||
| 1853 | |||
| 1854 | @xref{Init Rebinding}, for more information about using vectors for | ||
| 1855 | rebinding. | ||
| 1856 | |||
| 1857 | You can mix function keys and characters in a key sequence. This | ||
| 1858 | example binds @kbd{C-x @key{NEXT}} to the command @code{forward-page}. | ||
| 1859 | |||
| 1860 | @example | ||
| 1861 | (global-set-key [?\C-x next] 'forward-page) | ||
| 1862 | @end example | ||
| 1863 | |||
| 1864 | @noindent | ||
| 1865 | where @code{?\C-x} is the Lisp character constant for the character | ||
| 1866 | @kbd{C-x}. The vector element @code{next} is a symbol and therefore | ||
| 1867 | does not take a question mark. | ||
| 1868 | |||
| 1869 | You can use the modifier keys @key{Control}, @key{Meta}, | ||
| 1870 | @key{Hyper}, @key{Super}, @key{Alt} and @key{Shift} with function | ||
| 1871 | keys. To represent these modifiers, add the strings @samp{C-}, | ||
| 1872 | @samp{M-}, @samp{H-}, @samp{s-}, @samp{A-} and @samp{S-} at the front | ||
| 1873 | of the symbol name. Thus, here is how to make | ||
| 1874 | @kbd{Hyper-Meta-@key{RIGHT}} move forward a word: | ||
| 1875 | |||
| 1876 | @example | ||
| 1877 | (global-set-key [H-M-right] 'forward-word) | ||
| 1878 | @end example | ||
| 1879 | 1796 | ||
| 1880 | @cindex keypad | 1797 | @cindex keypad |
| 1881 | Many keyboards have a ``numeric keypad'' on the right hand side. | 1798 | Many keyboards have a ``numeric keypad'' on the right hand side. |
| @@ -1910,8 +1827,8 @@ used so often that they have special keys of their own. For instance, | |||
| 1910 | @key{TAB} was another name for @kbd{C-i}. Later, users found it | 1827 | @key{TAB} was another name for @kbd{C-i}. Later, users found it |
| 1911 | convenient to distinguish in Emacs between these keys and the ``same'' | 1828 | convenient to distinguish in Emacs between these keys and the ``same'' |
| 1912 | control characters typed with the @key{CTRL} key. Therefore, on most | 1829 | control characters typed with the @key{CTRL} key. Therefore, on most |
| 1913 | modern terminals, they are no longer the same, and @key{TAB} is | 1830 | modern terminals, they are no longer the same: @key{TAB} is different |
| 1914 | distinguishable from @kbd{C-i}. | 1831 | from @kbd{C-i}. |
| 1915 | 1832 | ||
| 1916 | Emacs can distinguish these two kinds of input if the keyboard does. | 1833 | Emacs can distinguish these two kinds of input if the keyboard does. |
| 1917 | It treats the ``special'' keys as function keys named @code{tab}, | 1834 | It treats the ``special'' keys as function keys named @code{tab}, |
| @@ -2152,16 +2069,17 @@ Reference Manual}. | |||
| 2152 | @cindex rebinding keys, permanently | 2069 | @cindex rebinding keys, permanently |
| 2153 | @cindex startup (init file) | 2070 | @cindex startup (init file) |
| 2154 | 2071 | ||
| 2155 | When Emacs is started, it normally loads a Lisp program from the file | 2072 | When Emacs is started, it normally tries to load a Lisp program from |
| 2156 | @file{.emacs} or @file{.emacs.el} in your home directory (@pxref{Find Init}). | 2073 | an @dfn{initialization file}, or @dfn{init file} for short. This |
| 2157 | We call this file your @dfn{init file} because it specifies how to | 2074 | file, if it exists, specifies how to initialize Emacs for you. Emacs |
| 2158 | initialize Emacs for you. You can use the command line switch | 2075 | looks for your init file using the filenames @file{~/.emacs}, |
| 2159 | @samp{-q} to prevent loading your init file, and @samp{-u} (or | 2076 | @file{~/.emacs.el}, or @file{~/.emacs.d/init.el}; you can choose to |
| 2160 | @samp{--user}) to specify a different user's init file (@pxref{Initial | 2077 | use any one of these three names (@pxref{Find Init}). Here, @file{~/} |
| 2161 | Options}). | 2078 | stands for your home directory. |
| 2162 | 2079 | ||
| 2163 | You can also use @file{~/.emacs.d/init.el} as the init file. Emacs | 2080 | You can use the command line switch @samp{-q} to prevent loading |
| 2164 | tries this if it cannot find @file{~/.emacs} or @file{~/.emacs.el}. | 2081 | your init file, and @samp{-u} (or @samp{--user}) to specify a |
| 2082 | different user's init file (@pxref{Initial Options}). | ||
| 2165 | 2083 | ||
| 2166 | @cindex @file{default.el}, the default init file | 2084 | @cindex @file{default.el}, the default init file |
| 2167 | There can also be a @dfn{default init file}, which is the library | 2085 | There can also be a @dfn{default init file}, which is the library |
| @@ -2192,14 +2110,14 @@ Many sites put these files in the @file{site-lisp} subdirectory of the | |||
| 2192 | Emacs installation directory, typically | 2110 | Emacs installation directory, typically |
| 2193 | @file{/usr/local/share/emacs/site-lisp}. | 2111 | @file{/usr/local/share/emacs/site-lisp}. |
| 2194 | 2112 | ||
| 2195 | Byte-compiling your @file{.emacs} is not recommended (@pxref{Byte | 2113 | Byte-compiling your init file is not recommended (@pxref{Byte |
| 2196 | Compilation,, Byte Compilation, elisp, the Emacs Lisp Reference | 2114 | Compilation,, Byte Compilation, elisp, the Emacs Lisp Reference |
| 2197 | Manual}). It generally does not speed up startup very much, and often | 2115 | Manual}). It generally does not speed up startup very much, and often |
| 2198 | leads to problems when you forget to recompile the file. A better | 2116 | leads to problems when you forget to recompile the file. A better |
| 2199 | solution is to use the Emacs server to reduce the number of times you | 2117 | solution is to use the Emacs server to reduce the number of times you |
| 2200 | have to start Emacs (@pxref{Emacs Server}). If your @file{.emacs} | 2118 | have to start Emacs (@pxref{Emacs Server}). If your init file defines |
| 2201 | defines many functions, consider moving them to a separate | 2119 | many functions, consider moving them to a separate (byte-compiled) |
| 2202 | (byte-compiled) file that you load in your @file{.emacs}. | 2120 | file that you load in your init file. |
| 2203 | 2121 | ||
| 2204 | If you are going to write actual Emacs Lisp programs that go beyond | 2122 | If you are going to write actual Emacs Lisp programs that go beyond |
| 2205 | minor customization, you should read the @cite{Emacs Lisp Reference Manual}. | 2123 | minor customization, you should read the @cite{Emacs Lisp Reference Manual}. |
| @@ -2219,11 +2137,11 @@ Manual}. | |||
| 2219 | @node Init Syntax | 2137 | @node Init Syntax |
| 2220 | @subsection Init File Syntax | 2138 | @subsection Init File Syntax |
| 2221 | 2139 | ||
| 2222 | The @file{.emacs} file contains one or more Lisp function call | 2140 | The init file contains one or more Lisp expressions. Each of these |
| 2223 | expressions. Each of these consists of a function name followed by | 2141 | consists of a function name followed by arguments, all surrounded by |
| 2224 | arguments, all surrounded by parentheses. For example, @code{(setq | 2142 | parentheses. For example, @code{(setq fill-column 60)} calls the |
| 2225 | fill-column 60)} calls the function @code{setq} to set the variable | 2143 | function @code{setq} to set the variable @code{fill-column} |
| 2226 | @code{fill-column} (@pxref{Filling}) to 60. | 2144 | (@pxref{Filling}) to 60. |
| 2227 | 2145 | ||
| 2228 | You can set any Lisp variable with @code{setq}, but with certain | 2146 | You can set any Lisp variable with @code{setq}, but with certain |
| 2229 | variables @code{setq} won't do what you probably want in the | 2147 | variables @code{setq} won't do what you probably want in the |