Mercurial > hg > xemacs-beta
comparison man/lispref/keymaps.texi @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | 8de8e3f6228a |
children | 1ccc32a20af4 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
1 @c -*-texinfo-*- | 1 @c -*-texinfo-*- |
2 @c This is part of the XEmacs Lisp Reference Manual. | 2 @c This is part of the XEmacs Lisp Reference Manual. |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | 3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. |
4 @c Copyright (C) 1996 Ben Wing. | 4 @c Copyright (C) 1996 Ben Wing. |
5 @c See the file lispref.texi for copying conditions. | 5 @c See the file lispref.texi for copying conditions. |
6 @setfilename ../../info/keymaps.info | 6 @setfilename ../../info/keymaps.info |
7 @node Keymaps, Menus, Command Loop, Top | 7 @node Keymaps, Menus, Command Loop, Top |
8 @chapter Keymaps | 8 @chapter Keymaps |
129 @defun make-sparse-keymap &optional name | 129 @defun make-sparse-keymap &optional name |
130 This function constructs and returns a new keymap object. All entries | 130 This function constructs and returns a new keymap object. All entries |
131 in it are @code{nil}, meaning ``command undefined''. The only | 131 in it are @code{nil}, meaning ``command undefined''. The only |
132 difference between this function and @code{make-keymap} is that this | 132 difference between this function and @code{make-keymap} is that this |
133 function returns a ``smaller'' keymap (one that is expected to contain | 133 function returns a ``smaller'' keymap (one that is expected to contain |
134 fewer entries). As keymaps dynamically resize, the distinction is not | 134 fewer entries). As keymaps dynamically resize, this distinction is not |
135 great. | 135 great. |
136 | 136 |
137 Optional argument @var{name} specifies a name to assign to the keymap, | 137 Optional argument @var{name} specifies a name to assign to the keymap, |
138 as in @code{set-keymap-name}. This name is only a debugging | 138 as in @code{set-keymap-name}. This name is only a debugging |
139 convenience; it is not used except when printing the keymap. | 139 convenience; it is not used except when printing the keymap. |
280 | 280 |
281 @example | 281 @example |
282 A ?A 65 (A) (?A) (65) | 282 A ?A 65 (A) (?A) (65) |
283 [A] [?A] [65] [(A)] [(?A)] [(65)] | 283 [A] [?A] [65] [(A)] [(?A)] [(65)] |
284 @end example | 284 @end example |
285 | 285 |
286 the @kbd{control-a} keystroke is represented by these forms: | 286 the @kbd{control-a} keystroke is represented by these forms: |
287 | 287 |
288 @example | 288 @example |
289 (control A) (control ?A) (control 65) | 289 (control A) (control ?A) (control 65) |
290 [(control A)] [(control ?A)] [(control 65)] | 290 [(control A)] [(control ?A)] [(control 65)] |
600 @result{} #<keymap global-map 639 entries 0x221> | 600 @result{} #<keymap global-map 639 entries 0x221> |
601 @end group | 601 @end group |
602 @end example | 602 @end example |
603 @end defun | 603 @end defun |
604 | 604 |
605 @defun current-local-map | 605 @defun current-local-map &optional buffer |
606 This function returns the current buffer's local keymap, or @code{nil} | 606 This function returns @var{buffer}'s local keymap, or @code{nil} |
607 if it has none. In the following example, the keymap for the | 607 if it has none. @var{buffer} defaults to the current buffer. |
608 @samp{*scratch*} buffer (using Lisp Interaction mode) has a number | 608 |
609 of entries, including one prefix key, @kbd{C-x}. | 609 In the following example, the keymap for the @samp{*scratch*} buffer |
610 (using Lisp Interaction mode) has a number of entries, including one | |
611 prefix key, @kbd{C-x}. | |
610 | 612 |
611 @example | 613 @example |
612 @group | 614 @group |
613 (current-local-map) | 615 (current-local-map) |
614 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558> | 616 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558> |
929 @result{} keyboard-escape-quit | 931 @result{} keyboard-escape-quit |
930 @end group | 932 @end group |
931 @end example | 933 @end example |
932 @end defun | 934 @end defun |
933 | 935 |
934 @defun local-key-binding key &optional accept-defaults | 936 @defun local-key-binding keys &optional accept-defaults |
935 This function returns the binding for @var{key} in the current | 937 This function returns the binding for @var{keys} in the current |
936 local keymap, or @code{nil} if it is undefined there. | 938 local keymap, or @code{nil} if it is undefined there. |
937 | 939 |
938 @c Emacs 19 feature | 940 @c Emacs 19 feature |
939 The argument @var{accept-defaults} controls checking for default bindings, | 941 The argument @var{accept-defaults} controls checking for default bindings, |
940 as in @code{lookup-key} (above). | 942 as in @code{lookup-key} (above). |
941 @end defun | 943 @end defun |
942 | 944 |
943 @defun global-key-binding key &optional accept-defaults | 945 @defun global-key-binding keys &optional accept-defaults |
944 This function returns the binding for command @var{key} in the | 946 This function returns the binding for command @var{keys} in the |
945 current global keymap, or @code{nil} if it is undefined there. | 947 current global keymap, or @code{nil} if it is undefined there. |
946 | 948 |
947 @c Emacs 19 feature | 949 @c Emacs 19 feature |
948 The argument @var{accept-defaults} controls checking for default bindings, | 950 The argument @var{accept-defaults} controls checking for default bindings, |
949 as in @code{lookup-key} (above). | 951 as in @code{lookup-key} (above). |
1000 @result{} ?\^X ; @r{Under XEmacs 20.} | 1002 @result{} ?\^X ; @r{Under XEmacs 20.} |
1001 @result{} 24 ; @r{Under XEmacs 19.} | 1003 @result{} 24 ; @r{Under XEmacs 19.} |
1002 @end group | 1004 @end group |
1003 @group | 1005 @group |
1004 (setq meta-prefix-char 24) | 1006 (setq meta-prefix-char 24) |
1005 @result{} 24 | 1007 @result{} 24 |
1006 @end group | 1008 @end group |
1007 @group | 1009 @group |
1008 (key-binding "\C-xb") | 1010 (key-binding "\C-xb") |
1009 @result{} backward-word ; @r{Now, typing @kbd{C-x b} is} | 1011 @result{} backward-word ; @r{Now, typing @kbd{C-x b} is} |
1010 ; @r{like typing @kbd{M-b}.} | 1012 ; @r{like typing @kbd{M-b}.} |
1147 Note that storing a new binding for @kbd{C-p C-f} actually works by | 1149 Note that storing a new binding for @kbd{C-p C-f} actually works by |
1148 changing an entry in @code{ctl-x-map}, and this has the effect of | 1150 changing an entry in @code{ctl-x-map}, and this has the effect of |
1149 changing the bindings of both @kbd{C-p C-f} and @kbd{C-x C-f} in the | 1151 changing the bindings of both @kbd{C-p C-f} and @kbd{C-x C-f} in the |
1150 default global map. | 1152 default global map. |
1151 | 1153 |
1152 @defun substitute-key-definition olddef newdef keymap &optional oldmap | 1154 @defun substitute-key-definition olddef newdef keymap &optional oldmap prefix |
1153 @cindex replace bindings | 1155 @cindex replace bindings |
1154 This function replaces @var{olddef} with @var{newdef} for any keys in | 1156 This function replaces @var{olddef} with @var{newdef} for any keys in |
1155 @var{keymap} that were bound to @var{olddef}. In other words, | 1157 @var{keymap} that were bound to @var{olddef}. In other words, |
1156 @var{olddef} is replaced with @var{newdef} wherever it appears. The | 1158 @var{olddef} is replaced with @var{newdef} wherever it appears. Prefix |
1157 function returns @code{nil}. | 1159 keymaps are checked recursively. |
1160 | |
1161 The function returns @code{nil}. | |
1158 | 1162 |
1159 For example, this redefines @kbd{C-x C-f}, if you do it in an XEmacs with | 1163 For example, this redefines @kbd{C-x C-f}, if you do it in an XEmacs with |
1160 standard bindings: | 1164 standard bindings: |
1161 | 1165 |
1162 @smallexample | 1166 @smallexample |
1163 @group | 1167 @group |
1164 (substitute-key-definition | 1168 (substitute-key-definition |
1165 'find-file 'find-file-read-only (current-global-map)) | 1169 'find-file 'find-file-read-only (current-global-map)) |
1166 @end group | 1170 @end group |
1167 @end smallexample | 1171 @end smallexample |
1168 | 1172 |
1169 @c Emacs 19 feature | 1173 @c Emacs 19 feature |
1170 If @var{oldmap} is non-@code{nil}, then its bindings determine which | 1174 If @var{oldmap} is non-@code{nil}, then its bindings determine which |
1171 keys to rebind. The rebindings still happen in @var{newmap}, not in | 1175 keys to rebind. The rebindings still happen in @var{keymap}, not in |
1172 @var{oldmap}. Thus, you can change one map under the control of the | 1176 @var{oldmap}. Thus, you can change one map under the control of the |
1173 bindings in another. For example, | 1177 bindings in another. For example, |
1174 | 1178 |
1175 @smallexample | 1179 @smallexample |
1176 (substitute-key-definition | 1180 (substitute-key-definition |
1179 @end smallexample | 1183 @end smallexample |
1180 | 1184 |
1181 @noindent | 1185 @noindent |
1182 puts the special deletion command in @code{my-map} for whichever keys | 1186 puts the special deletion command in @code{my-map} for whichever keys |
1183 are globally bound to the standard deletion command. | 1187 are globally bound to the standard deletion command. |
1188 | |
1189 If argument @var{prefix} is non-@code{nil}, then only those occurrences | |
1190 of @var{olddef} found in keymaps accessible through the keymap bound to | |
1191 @var{prefix} in @var{keymap} are redefined. See also | |
1192 @code{accessible-keymaps}. | |
1184 | 1193 |
1185 @ignore | 1194 @ignore |
1186 @c Emacs 18 only | 1195 @c Emacs 18 only |
1187 Prefix keymaps that appear within @var{keymap} are not checked | 1196 Prefix keymaps that appear within @var{keymap} are not checked |
1188 recursively for keys bound to @var{olddef}; they are not changed at all. | 1197 recursively for keys bound to @var{olddef}; they are not changed at all. |
1192 @ignore @c #### fix this up. | 1201 @ignore @c #### fix this up. |
1193 Here is an example showing a keymap before and after substitution: | 1202 Here is an example showing a keymap before and after substitution: |
1194 | 1203 |
1195 @smallexample | 1204 @smallexample |
1196 @group | 1205 @group |
1197 (setq map '(keymap | 1206 (setq map '(keymap |
1198 (?1 . olddef-1) | 1207 (?1 . olddef-1) |
1199 (?2 . olddef-2) | 1208 (?2 . olddef-2) |
1200 (?3 . olddef-1))) | 1209 (?3 . olddef-1))) |
1201 @result{} (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1)) | 1210 @result{} (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1)) |
1202 @end group | 1211 @end group |
1203 | 1212 |
1204 @group | 1213 @group |
1223 If @var{nodigits} is @code{nil}, then @code{suppress-keymap} defines | 1232 If @var{nodigits} is @code{nil}, then @code{suppress-keymap} defines |
1224 digits to run @code{digit-argument}, and @kbd{-} to run | 1233 digits to run @code{digit-argument}, and @kbd{-} to run |
1225 @code{negative-argument}. Otherwise it makes them undefined like the | 1234 @code{negative-argument}. Otherwise it makes them undefined like the |
1226 rest of the printing characters. | 1235 rest of the printing characters. |
1227 | 1236 |
1228 @cindex yank suppression | 1237 @cindex yank suppression |
1229 @cindex @code{quoted-insert} suppression | 1238 @cindex @code{quoted-insert} suppression |
1230 The @code{suppress-keymap} function does not make it impossible to | 1239 The @code{suppress-keymap} function does not make it impossible to |
1231 modify a buffer, as it does not suppress commands such as @code{yank} | 1240 modify a buffer, as it does not suppress commands such as @code{yank} |
1232 and @code{quoted-insert}. To prevent any modification of a buffer, make | 1241 and @code{quoted-insert}. To prevent any modification of a buffer, make |
1233 it read-only (@pxref{Read Only Buffers}). | 1242 it read-only (@pxref{Read Only Buffers}). |
1234 | 1243 |
1402 as its parent, and @code{lisp-interaction-mode-map} defines no key | 1411 as its parent, and @code{lisp-interaction-mode-map} defines no key |
1403 sequences beginning with @kbd{C-x}.) | 1412 sequences beginning with @kbd{C-x}.) |
1404 | 1413 |
1405 @smallexample | 1414 @smallexample |
1406 @group | 1415 @group |
1407 (current-local-map) | 1416 (current-local-map) |
1408 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558> | 1417 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558> |
1409 (accessible-keymaps (current-local-map)) | 1418 (accessible-keymaps (current-local-map)) |
1410 @result{}(([] . #<keymap lisp-interaction-mode-map 5 entries 0x558>) | 1419 @result{}(([] . #<keymap lisp-interaction-mode-map 5 entries 0x558>) |
1411 ([(control x)] . | 1420 ([(control x)] . |
1412 #<keymap ((control x) #<keymap emacs-lisp-mode-map 8 entries 0x546>) | 1421 #<keymap ((control x) #<keymap emacs-lisp-mode-map 8 entries 0x546>) |
1450 @end group | 1459 @end group |
1451 @end smallexample | 1460 @end smallexample |
1452 @end defun | 1461 @end defun |
1453 | 1462 |
1454 @defun map-keymap function keymap &optional sort-first | 1463 @defun map-keymap function keymap &optional sort-first |
1455 This function applies @var{function} to each element of @code{KEYMAP}. | 1464 This function applies @var{function} to each element of @var{keymap}. |
1456 @var{function} will be called with two arguments: a key-description | 1465 @var{function} will be called with two arguments: a key-description |
1457 list, and the binding. The order in which the elements of the keymap | 1466 list, and the binding. The order in which the elements of the keymap |
1458 are passed to the function is unspecified. If the function inserts new | 1467 are passed to the function is unspecified. If the function inserts new |
1459 elements into the keymap, it may or may not be called with them later. | 1468 elements into the keymap, it may or may not be called with them later. |
1460 No element of the keymap will ever be passed to the function more than | 1469 No element of the keymap will ever be passed to the function more than |
1480 bound to @var{definition} in a set of keymaps. | 1489 bound to @var{definition} in a set of keymaps. |
1481 | 1490 |
1482 The argument @var{definition} can be any object; it is compared with all | 1491 The argument @var{definition} can be any object; it is compared with all |
1483 keymap entries using @code{eq}. | 1492 keymap entries using @code{eq}. |
1484 | 1493 |
1485 KEYMAPS can be either a keymap (meaning search in that keymap and the | 1494 @var{keymaps} can be either a keymap (meaning search in that keymap and the |
1486 current global keymap) or a list of keymaps (meaning search in exactly | 1495 current global keymap) or a list of keymaps (meaning search in exactly |
1487 those keymaps and no others). If KEYMAPS is nil, search in the currently | 1496 those keymaps and no others). If @var{keymaps} is nil, search in the currently |
1488 applicable maps for EVENT-OR-KEYS. | 1497 applicable maps for @var{event-or-keys}. |
1489 | 1498 |
1490 If @var{keymap} is a keymap, then the maps searched are @var{keymap} and | 1499 If @var{keymaps} is a keymap, then the maps searched are @var{keymaps} and |
1491 the global keymap. If @var{keymap} is a list of keymaps, then the maps | 1500 the global keymap. If @var{keymaps} is a list of keymaps, then the maps |
1492 searched are exactly those keymaps, and no others. If @var{keymap} is | 1501 searched are exactly those keymaps, and no others. If @var{keymaps} is |
1493 @code{nil}, then the maps used are the current active keymaps for | 1502 @code{nil}, then the maps used are the current active keymaps for |
1494 @var{event-or-keys} (this is equivalent to specifying | 1503 @var{event-or-keys} (this is equivalent to specifying |
1495 @code{(current-keymaps @var{event-or-keys})} as the argument to | 1504 @code{(current-keymaps @var{event-or-keys})} as the argument to |
1496 @var{keymaps}). | 1505 @var{keymaps}). |
1497 | 1506 |
1536 @end defun | 1545 @end defun |
1537 | 1546 |
1538 @code{describe-bindings-internal} is used to implement the | 1547 @code{describe-bindings-internal} is used to implement the |
1539 help command @code{describe-bindings}. | 1548 help command @code{describe-bindings}. |
1540 | 1549 |
1541 @deffn Command describe-bindings prefix mouse-only-p | 1550 @deffn Command describe-bindings &optional prefix mouse-only-p |
1542 This function creates a listing of all defined keys and their | 1551 This function creates a listing of all defined keys and their |
1543 definitions. It writes the listing in a buffer named @samp{*Help*} and | 1552 definitions. It writes the listing in a buffer named @samp{*Help*} and |
1544 displays it in a window. | 1553 displays it in a window. |
1545 | 1554 |
1546 If @var{prefix} is non-@code{nil}, it should be a prefix key; then the | 1555 If optional argument @var{prefix} is non-@code{nil}, it should be a |
1547 listing includes only keys that start with @var{prefix}. | 1556 prefix key; then the listing includes only keys that start with |
1557 @var{prefix}. | |
1548 | 1558 |
1549 When several characters with consecutive @sc{ascii} codes have the | 1559 When several characters with consecutive @sc{ascii} codes have the |
1550 same definition, they are shown together, as | 1560 same definition, they are shown together, as |
1551 @samp{@var{firstchar}..@var{lastchar}}. In this instance, you need to | 1561 @samp{@var{firstchar}..@var{lastchar}}. In this instance, you need to |
1552 know the @sc{ascii} codes to understand which characters this means. | 1562 know the @sc{ascii} codes to understand which characters this means. |
1554 ..@: ~} are described by a single line. @key{SPC} is @sc{ascii} 32, | 1564 ..@: ~} are described by a single line. @key{SPC} is @sc{ascii} 32, |
1555 @kbd{~} is @sc{ascii} 126, and the characters between them include all | 1565 @kbd{~} is @sc{ascii} 126, and the characters between them include all |
1556 the normal printing characters, (e.g., letters, digits, punctuation, | 1566 the normal printing characters, (e.g., letters, digits, punctuation, |
1557 etc.@:); all these characters are bound to @code{self-insert-command}. | 1567 etc.@:); all these characters are bound to @code{self-insert-command}. |
1558 | 1568 |
1559 If the second argument (prefix arg, interactively) is non-@code{nil} | 1569 If the second optional argument @var{mouse-only-p} (prefix arg, |
1560 then only the mouse bindings are displayed. | 1570 interactively) is non-@code{nil} then only the mouse bindings are |
1571 displayed. | |
1561 @end deffn | 1572 @end deffn |
1562 | 1573 |
1563 @node Other Keymap Functions | 1574 @node Other Keymap Functions |
1564 @section Other Keymap Functions | 1575 @section Other Keymap Functions |
1565 | 1576 |