# HG changeset patch # User Richard M. Stallman # Date 1088108162 0 # Node ID b4cff9b59252d5b276785e45917d6bfd8b2ee269 # Parent e4e80ee3d6db77f38e410ced03025cf75f5fd584 (Keymap Terminology): Document `kbd'. (Changing Key Bindings, Key Binding Commands): Use kbd in examples. diff -r e4e80ee3d6db -r b4cff9b59252 lispref/keymaps.texi --- a/lispref/keymaps.texi Thu Jun 24 20:13:57 2004 +0000 +++ b/lispref/keymaps.texi Thu Jun 24 20:16:02 2004 +0000 @@ -95,6 +95,27 @@ keymaps shadow both local and global keymaps. @xref{Active Keymaps}, for details. + The Emacs Lisp representation for a key sequence is a string or vector. +You can enter key sequence constants using the ordinary string or vector +representation; it is also convenient to use @code{kbd}: + +@defmac kbd keyseq-text +This macro converts the text @var{keyseq-text} (a string constant) +into a key sequence (a string or vector constant). The contents +of @var{keyseq-text} should describe the key sequence using the syntax +used in this manual: + +@example +(kbd "C-x") @result{} "\C-x" +(kbd "C-x C-f") @result{} "\C-x\C-f" +(kbd "C-c C-c") @result{} "\C-c\C-c" +(kbd "C-x 4 C-f") @result{} "\C-x4\C-f" +(kbd "X") @result{} "X" +(kbd "RET") @result{} "\^M" +(kbd "C-c 3") @result{} "\C-c3" +@end example +@end defmac + @node Format of Keymaps @section Format of Keymaps @cindex format of keymaps @@ -880,6 +901,10 @@ @result{} find-file @end group @group +(lookup-key (current-global-map) (kbd "C-x C-f")) + @result{} find-file +@end group +@group (lookup-key (current-global-map) "\C-x\C-f12345") @result{} 2 @end group @@ -1126,7 +1151,7 @@ @group ;; @r{Build sparse submap for @kbd{C-x} and bind @kbd{f} in that.} -(define-key map "\C-xf" 'forward-word) +(define-key map (kbd "C-x f") 'forward-word) @result{} forward-word @end group @group @@ -1139,14 +1164,14 @@ @group ;; @r{Bind @kbd{C-p} to the @code{ctl-x-map}.} -(define-key map "\C-p" ctl-x-map) +(define-key map (kbd "C-p") ctl-x-map) ;; @code{ctl-x-map} @result{} [nil @dots{} find-file @dots{} backward-kill-sentence] @end group @group ;; @r{Bind @kbd{C-f} to @code{foo} in the @code{ctl-x-map}.} -(define-key map "\C-p\C-f" 'foo) +(define-key map (kbd "C-p C-f") 'foo) @result{} 'foo @end group @group @@ -1333,7 +1358,7 @@ (@pxref{Init File}) for simple customization. For example, @smallexample -(global-set-key "\C-x\C-\\" 'next-line) +(global-set-key (kbd "C-x C-\\") 'next-line) @end smallexample @noindent