Mercurial > hg > xemacs-beta
comparison man/lispref/keymaps.texi @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 74fd4e045ea6 |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
233 | 233 |
234 @node Key Sequences | 234 @node Key Sequences |
235 @section Key Sequences | 235 @section Key Sequences |
236 @cindex key sequences | 236 @cindex key sequences |
237 | 237 |
238 Contrary to popular belief, the world is not @sc{ascii}. When running | 238 Contrary to popular belief, the world is not @sc{ASCII}. When running |
239 under a window manager, XEmacs can tell the difference between, for | 239 under a window manager, XEmacs can tell the difference between, for |
240 example, the keystrokes @kbd{control-h}, @kbd{control-shift-h}, and | 240 example, the keystrokes @kbd{control-h}, @kbd{control-shift-h}, and |
241 @kbd{backspace}. You can, in fact, bind different commands to each of | 241 @kbd{backspace}. You can, in fact, bind different commands to each of |
242 these. | 242 these. |
243 | 243 |
244 A @dfn{key sequence} is a set of keystrokes. A @dfn{keystroke} is a | 244 A @dfn{key sequence} is a set of keystrokes. A @dfn{keystroke} is a |
245 keysym and some set of modifiers (such as @key{CONTROL} and @key{META}). | 245 keysym and some set of modifiers (such as @key{CONTROL} and @key{META}). |
246 A @dfn{keysym} is what is printed on the keys on your keyboard. | 246 A @dfn{keysym} is what is printed on the keys on your keyboard. |
247 | 247 |
248 A keysym may be represented by a symbol, or (if and only if it is | 248 A keysym may be represented by a symbol, or (if and only if it is |
249 equivalent to an @sc{ascii} character in the range 32 - 255) by a | 249 equivalent to an @sc{ASCII} character in the range 32 - 255) by a |
250 character or its equivalent @sc{ascii} code. The @kbd{A} key may be | 250 character or its equivalent @sc{ASCII} code. The @kbd{A} key may be |
251 represented by the symbol @code{A}, the character @code{?A}, or by the | 251 represented by the symbol @code{A}, the character @code{?A}, or by the |
252 number 65. The @kbd{break} key may be represented only by the symbol | 252 number 65. The @kbd{break} key may be represented only by the symbol |
253 @code{break}. | 253 @code{break}. |
254 | 254 |
255 A keystroke may be represented by a list: the last element of the list | 255 A keystroke may be represented by a list: the last element of the list |
260 @code{(control b)}, @code{(control ?b)}, and @code{(control 98)}. A | 260 @code{(control b)}, @code{(control ?b)}, and @code{(control 98)}. A |
261 keystroke may also be represented by an event object, as returned by the | 261 keystroke may also be represented by an event object, as returned by the |
262 @code{next-command-event} and @code{read-key-sequence} functions. | 262 @code{next-command-event} and @code{read-key-sequence} functions. |
263 | 263 |
264 Note that in this context, the keystroke @kbd{control-b} is @emph{not} | 264 Note that in this context, the keystroke @kbd{control-b} is @emph{not} |
265 represented by the number 2 (the @sc{ascii} code for @samp{^B}) or the | 265 represented by the number 2 (the @sc{ASCII} code for @samp{^B}) or the |
266 character @code{?\^B}. See below. | 266 character @code{?\^B}. See below. |
267 | 267 |
268 The @key{SHIFT} modifier is somewhat of a special case. You should | 268 The @key{SHIFT} modifier is somewhat of a special case. You should |
269 not (and cannot) use @code{(meta shift a)} to mean @code{(meta A)}, | 269 not (and cannot) use @code{(meta shift a)} to mean @code{(meta A)}, |
270 since for characters that have @sc{ascii} equivalents, the state of the | 270 since for characters that have @sc{ASCII} equivalents, the state of the |
271 shift key is implicit in the keysym (@samp{a} vs. @samp{A}). You also | 271 shift key is implicit in the keysym (@samp{a} vs. @samp{A}). You also |
272 cannot say @code{(shift =)} to mean @code{+}, as that sort of thing | 272 cannot say @code{(shift =)} to mean @code{+}, as that sort of thing |
273 varies from keyboard to keyboard. The @key{SHIFT} modifier is for use | 273 varies from keyboard to keyboard. The @key{SHIFT} modifier is for use |
274 only with characters that do not have a second keysym on the same key, | 274 only with characters that do not have a second keysym on the same key, |
275 such as @code{backspace} and @code{tab}. | 275 such as @code{backspace} and @code{tab}. |
277 A key sequence is a vector of keystrokes. As a degenerate case, | 277 A key sequence is a vector of keystrokes. As a degenerate case, |
278 elements of this vector may also be keysyms if they have no modifiers. | 278 elements of this vector may also be keysyms if they have no modifiers. |
279 That is, the @kbd{A} keystroke is represented by all of these forms: | 279 That is, the @kbd{A} keystroke is represented by all of these forms: |
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)] |
291 @end example | 291 @end example |
292 | 292 |
293 the key sequence @kbd{control-c control-a} is represented by these | 293 the key sequence @kbd{control-c control-a} is represented by these |
294 forms: | 294 forms: |
295 | 295 |
296 @example | 296 @example |
297 [(control c) (control a)] [(control ?c) (control ?a)] | 297 [(control c) (control a)] [(control ?c) (control ?a)] |
298 [(control 99) (control 65)] etc. | 298 [(control 99) (control 65)] etc. |
299 @end example | 299 @end example |
300 | 300 |
301 Mouse button clicks work just like keypresses: @code{(control | 301 Mouse button clicks work just like keypresses: @code{(control |
302 button1)} means pressing the left mouse button while holding down the | 302 button1)} means pressing the left mouse button while holding down the |
303 control key. @code{[(control c) (shift button3)]} means | 303 control key. @code{[(control c) (shift button3)]} means |
309 to the up and down strokes, though that is probably not what you want, | 309 to the up and down strokes, though that is probably not what you want, |
310 so be careful. | 310 so be careful. |
311 | 311 |
312 For backward compatibility, a key sequence may also be represented by | 312 For backward compatibility, a key sequence may also be represented by |
313 a string. In this case, it represents the key sequence(s) that would | 313 a string. In this case, it represents the key sequence(s) that would |
314 produce that sequence of @sc{ascii} characters in a purely @sc{ascii} | 314 produce that sequence of @sc{ASCII} characters in a purely @sc{ASCII} |
315 world. For example, a string containing the @sc{ascii} backspace | 315 world. For example, a string containing the @sc{ASCII} backspace |
316 character, @code{"\^H"}, would represent two key sequences: | 316 character, @code{"\^H"}, would represent two key sequences: |
317 @code{(control h)} and @code{backspace}. Binding a command to this will | 317 @code{(control h)} and @code{backspace}. Binding a command to this will |
318 actually bind both of those key sequences. Likewise for the following | 318 actually bind both of those key sequences. Likewise for the following |
319 pairs: | 319 pairs: |
320 | 320 |
321 @example | 321 @example |
322 control h backspace | 322 control h backspace |
323 control i tab | 323 control i tab |
324 control m return | 324 control m return |
325 control j linefeed | 325 control j linefeed |
326 control [ escape | 326 control [ escape |
327 control @@ control space | 327 control @@ control space |
328 @end example | 328 @end example |
329 | 329 |
330 After binding a command to two key sequences with a form like | 330 After binding a command to two key sequences with a form like |
331 | 331 |
332 @example | 332 @example |
333 (define-key global-map "\^X\^I" 'command-1) | 333 (define-key global-map "\^X\^I" 'command-1) |
334 @end example | 334 @end example |
335 | 335 |
336 @noindent | 336 @noindent |
337 it is possible to redefine only one of those sequences like so: | 337 it is possible to redefine only one of those sequences like so: |
338 | 338 |
339 @example | 339 @example |
340 (define-key global-map [(control x) (control i)] 'command-2) | 340 (define-key global-map [(control x) (control i)] 'command-2) |
341 (define-key global-map [(control x) tab] 'command-3) | 341 (define-key global-map [(control x) tab] 'command-3) |
342 @end example | 342 @end example |
343 | 343 |
344 Of course, all of this applies only when running under a window | 344 Of course, all of this applies only when running under a window |
345 system. If you're talking to XEmacs through a @sc{tty} connection, you | 345 system. If you're talking to XEmacs through a @sc{TTY} connection, you |
346 don't get any of these features. | 346 don't get any of these features. |
347 | 347 |
348 @defun event-matches-key-specifier-p event key-specifier | 348 @defun event-matches-key-specifier-p event key-specifier |
349 This function returns non-@code{nil} if @var{event} matches | 349 This function returns non-@code{nil} if @var{event} matches |
350 @var{key-specifier}, which can be any valid form representing a key | 350 @var{key-specifier}, which can be any valid form representing a key |
612 @group | 612 @group |
613 (current-local-map) | 613 (current-local-map) |
614 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558> | 614 @result{} #<keymap lisp-interaction-mode-map 5 entries 0x558> |
615 (describe-bindings-internal (current-local-map)) | 615 (describe-bindings-internal (current-local-map)) |
616 @result{} ; @r{Inserted into the buffer:} | 616 @result{} ; @r{Inserted into the buffer:} |
617 backspace backward-delete-char-untabify | 617 backspace backward-delete-char-untabify |
618 linefeed eval-print-last-sexp | 618 linefeed eval-print-last-sexp |
619 delete delete-char | 619 delete delete-char |
620 C-j eval-print-last-sexp | 620 C-j eval-print-last-sexp |
621 C-x << Prefix Command >> | 621 C-x << Prefix Command >> |
622 M-tab lisp-complete-symbol | 622 M-tab lisp-complete-symbol |
623 M-; lisp-indent-for-comment | 623 M-; lisp-indent-for-comment |
624 M-C-i lisp-complete-symbol | 624 M-C-i lisp-complete-symbol |
625 M-C-q indent-sexp | 625 M-C-q indent-sexp |
626 M-C-x eval-defun | 626 M-C-x eval-defun |
627 Alt-backspace backward-kill-sexp | 627 Alt-backspace backward-kill-sexp |
628 Alt-delete kill-sexp | 628 Alt-delete kill-sexp |
629 @end group | 629 @end group |
630 | 630 |
631 @group | 631 @group |
632 C-x x edebug-defun | 632 C-x x edebug-defun |
633 @end group | 633 @end group |
634 @end example | 634 @end example |
635 @end defun | 635 @end defun |
636 | 636 |
637 @defun current-minor-mode-maps | 637 @defun current-minor-mode-maps |
971 @cindex @key{ESC} | 971 @cindex @key{ESC} |
972 This variable is the meta-prefix character code. It is used when | 972 This variable is the meta-prefix character code. It is used when |
973 translating a two-character sequence to a meta character so it can be | 973 translating a two-character sequence to a meta character so it can be |
974 looked up in a keymap. For useful results, the value should be a prefix | 974 looked up in a keymap. For useful results, the value should be a prefix |
975 event (@pxref{Prefix Keys}). The default value is @code{?\^[} (integer | 975 event (@pxref{Prefix Keys}). The default value is @code{?\^[} (integer |
976 27), which is the @sc{ascii} character usually produced by the @key{ESC} | 976 27), which is the @sc{ASCII} character usually produced by the @key{ESC} |
977 key. | 977 key. |
978 | 978 |
979 As long as the value of @code{meta-prefix-char} remains @code{?\^[}, | 979 As long as the value of @code{meta-prefix-char} remains @code{?\^[}, |
980 key lookup translates @kbd{@key{ESC} b} into @kbd{M-b}, which is | 980 key lookup translates @kbd{@key{ESC} b} into @kbd{M-b}, which is |
981 normally defined as the @code{backward-word} command. However, if you | 981 normally defined as the @code{backward-word} command. However, if you |
982 set @code{meta-prefix-char} to @code{?\^X} (i.e. the keystroke | 982 set @code{meta-prefix-char} to @code{?\^X} (i.e. the keystroke |
983 @kbd{C-x}) or its equivalent @sc{ascii} code @code{24}, then XEmacs will | 983 @kbd{C-x}) or its equivalent @sc{ASCII} code @code{24}, then XEmacs will |
984 translate @kbd{C-x b} (whose standard binding is the | 984 translate @kbd{C-x b} (whose standard binding is the |
985 @code{switch-to-buffer} command) into @kbd{M-b}. | 985 @code{switch-to-buffer} command) into @kbd{M-b}. |
986 | 986 |
987 @smallexample | 987 @smallexample |
988 @group | 988 @group |
1501 @ignore @c #### Should fix where-is to be more like FSF | 1501 @ignore @c #### Should fix where-is to be more like FSF |
1502 If @var{firstonly} is @code{non-ascii}, then the value is a single | 1502 If @var{firstonly} is @code{non-ascii}, then the value is a single |
1503 string representing the first key sequence found, rather than a list of | 1503 string representing the first key sequence found, rather than a list of |
1504 all possible key sequences. If @var{firstonly} is @code{t}, then the | 1504 all possible key sequences. If @var{firstonly} is @code{t}, then the |
1505 value is the first key sequence, except that key sequences consisting | 1505 value is the first key sequence, except that key sequences consisting |
1506 entirely of @sc{ascii} characters (or meta variants of @sc{ascii} | 1506 entirely of @sc{ASCII} characters (or meta variants of @sc{ASCII} |
1507 characters) are preferred to all other key sequences. | 1507 characters) are preferred to all other key sequences. |
1508 @end ignore | 1508 @end ignore |
1509 | 1509 |
1510 If @var{noindirect} is non-@code{nil}, @code{where-is-internal} doesn't | 1510 If @var{noindirect} is non-@code{nil}, @code{where-is-internal} doesn't |
1511 follow indirect keymap bindings. This makes it possible to search for | 1511 follow indirect keymap bindings. This makes it possible to search for |
1544 displays it in a window. | 1544 displays it in a window. |
1545 | 1545 |
1546 If @var{prefix} is non-@code{nil}, it should be a prefix key; then the | 1546 If @var{prefix} is non-@code{nil}, it should be a prefix key; then the |
1547 listing includes only keys that start with @var{prefix}. | 1547 listing includes only keys that start with @var{prefix}. |
1548 | 1548 |
1549 When several characters with consecutive @sc{ascii} codes have the | 1549 When several characters with consecutive @sc{ASCII} codes have the |
1550 same definition, they are shown together, as | 1550 same definition, they are shown together, as |
1551 @samp{@var{firstchar}..@var{lastchar}}. In this instance, you need to | 1551 @samp{@var{firstchar}..@var{lastchar}}. In this instance, you need to |
1552 know the @sc{ascii} codes to understand which characters this means. | 1552 know the @sc{ASCII} codes to understand which characters this means. |
1553 For example, in the default global map, the characters @samp{@key{SPC} | 1553 For example, in the default global map, the characters @samp{@key{SPC} |
1554 ..@: ~} are described by a single line. @key{SPC} is @sc{ascii} 32, | 1554 ..@: ~} 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 | 1555 @kbd{~} is @sc{ASCII} 126, and the characters between them include all |
1556 the normal printing characters, (e.g., letters, digits, punctuation, | 1556 the normal printing characters, (e.g., letters, digits, punctuation, |
1557 etc.@:); all these characters are bound to @code{self-insert-command}. | 1557 etc.@:); all these characters are bound to @code{self-insert-command}. |
1558 | 1558 |
1559 If the second argument (prefix arg, interactively) is non-@code{nil} | 1559 If the second argument (prefix arg, interactively) is non-@code{nil} |
1560 then only the mouse bindings are displayed. | 1560 then only the mouse bindings are displayed. |