/[emacs]/emacs/lispref/keymaps.texi
ViewVC logotype

Diff of /emacs/lispref/keymaps.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.39 by rms, Fri Nov 2 07:11:18 2001 UTC revision 1.39.4.1 by miles, Fri Apr 4 06:20:41 2003 UTC
# Line 1  Line 1 
1  @c -*-texinfo-*-  @c -*-texinfo-*-
2  @c This is part of the GNU Emacs Lisp Reference Manual.  @c This is part of the GNU Emacs Lisp Reference Manual.
3  @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998, 1999, 2000  @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998, 1999, 2000
4  @c   Free Software Foundation, Inc.  @c   Free Software Foundation, Inc.
5  @c See the file elisp.texi for copying conditions.  @c See the file elisp.texi for copying conditions.
6  @setfilename ../info/keymaps  @setfilename ../info/keymaps
7  @node Keymaps, Modes, Command Loop, Top  @node Keymaps, Modes, Command Loop, Top
# Line 103  for details. Line 103  for details.
103    
104    A keymap is a list whose @sc{car} is the symbol @code{keymap}.  The    A keymap is a list whose @sc{car} is the symbol @code{keymap}.  The
105  remaining elements of the list define the key bindings of the keymap.  remaining elements of the list define the key bindings of the keymap.
106  Use the function @code{keymapp} (see below) to test whether an object is  A symbol whose function definition is a keymap is also a keymap.  Use
107  a keymap.  the function @code{keymapp} (see below) to test whether an object is a
108    keymap.
109    
110    Several kinds of elements may appear in a keymap, after the symbol    Several kinds of elements may appear in a keymap, after the symbol
111  @code{keymap} that begins it:  @code{keymap} that begins it:
# Line 174  C-l}, @kbd{M-C-q}, and @kbd{M-C-x}. Line 175  C-l}, @kbd{M-C-q}, and @kbd{M-C-x}.
175  @example  @example
176  @group  @group
177  lisp-mode-map  lisp-mode-map
178  @result{}  @result{}
179  @end group  @end group
180  @group  @group
181  (keymap  (keymap
182   ;; @key{TAB}   ;; @key{TAB}
183   (9 . lisp-indent-line)                   (9 . lisp-indent-line)
184  @end group  @end group
185  @group  @group
186   ;; @key{DEL}   ;; @key{DEL}
187   (127 . backward-delete-char-untabify)     (127 . backward-delete-char-untabify)
188  @end group  @end group
189  @group  @group
190   (3 keymap   (3 keymap
191      ;; @kbd{C-c C-l}      ;; @kbd{C-c C-l}
192      (12 . run-lisp))                          (12 . run-lisp))
193  @end group  @end group
194  @group  @group
195   (27 keymap   (27 keymap
196       ;; @r{@kbd{M-C-q}, treated as @kbd{@key{ESC} C-q}}       ;; @r{@kbd{M-C-q}, treated as @kbd{@key{ESC} C-q}}
197       (17 . indent-sexp)                       (17 . indent-sexp)
198       ;; @r{@kbd{M-C-x}, treated as @kbd{@key{ESC} C-x}}       ;; @r{@kbd{M-C-x}, treated as @kbd{@key{ESC} C-x}}
199       (24 . lisp-send-defun)))                 (24 . lisp-send-defun)))
200  @end group  @end group
201  @end example  @end example
202    
203  @defun keymapp object  @defun keymapp object
204  This function returns @code{t} if @var{object} is a keymap, @code{nil}  This function returns @code{t} if @var{object} is a keymap, @code{nil}
205  otherwise.  More precisely, this function tests for a list whose  otherwise.  More precisely, this function tests for a list whose
206  @sc{car} is @code{keymap}.  @sc{car} is @code{keymap}, or for a symbol whose function definition
207    satisfies @code{keymapp}.
208    
209  @example  @example
210  @group  @group
# Line 210  otherwise.  More precisely, this functio Line 212  otherwise.  More precisely, this functio
212      @result{} t      @result{} t
213  @end group  @end group
214  @group  @group
215    (fset 'foo '(keymap))
216    (keymapp 'foo)
217        @result{} t
218    @end group
219    @group
220  (keymapp (current-global-map))  (keymapp (current-global-map))
221      @result{} t      @result{} t
222  @end group  @end group
# Line 273  definition is a keymap; the same symbol Line 280  definition is a keymap; the same symbol
280  @end group  @end group
281  @group  @group
282       ;; @r{(This implements meta characters.)}       ;; @r{(This implements meta characters.)}
283       (27 keymap               (27 keymap
284           (83 . center-paragraph)           (83 . center-paragraph)
285           (115 . center-line))           (115 . center-line))
286       (9 . tab-to-tab-stop))       (9 . tab-to-tab-stop))
# Line 522  certain parts of the buffer; see @ref{Sp Line 529  certain parts of the buffer; see @ref{Sp
529  when the minor mode is enabled.  when the minor mode is enabled.
530    
531    The variable @code{overriding-local-map}, if non-@code{nil}, specifies    The variable @code{overriding-local-map}, if non-@code{nil}, specifies
532  another local keymap that overrides the buffer's local map and all the  another local keymap that overrides the buffer's local map and all the
533  minor mode keymaps.  minor mode keymaps.
534    
535    All the active keymaps are used together to determine what command to    All the active keymaps are used together to determine what command to
# Line 577  other. Line 584  other.
584  @example  @example
585  @group  @group
586  (current-global-map)  (current-global-map)
587  @result{} (keymap [set-mark-command beginning-of-line @dots{}  @result{} (keymap [set-mark-command beginning-of-line @dots{}
588              delete-backward-char])              delete-backward-char])
589  @end group  @end group
590  @end example  @end example
# Line 593  keymap. Line 600  keymap.
600  @example  @example
601  @group  @group
602  (current-local-map)  (current-local-map)
603  @result{} (keymap  @result{} (keymap
604      (10 . eval-print-last-sexp)      (10 . eval-print-last-sexp)
605      (9 . lisp-indent-line)      (9 . lisp-indent-line)
606      (127 . backward-delete-char-untabify)      (127 . backward-delete-char-untabify)
607  @end group  @end group
608  @group  @group
609      (27 keymap      (27 keymap
610          (24 . eval-defun)          (24 . eval-defun)
611          (17 . indent-sexp)))          (17 . indent-sexp)))
612  @end group  @end group
613  @end example  @end example
# Line 997  meta-prefix-char                    ; @r Line 1004  meta-prefix-char                    ; @r
1004  @end group  @end group
1005  @group  @group
1006  (setq meta-prefix-char 24)  (setq meta-prefix-char 24)
1007       @result{} 24             @result{} 24
1008  @end group  @end group
1009  @group  @group
1010  (key-binding "\M-b")  (key-binding "\M-b")
# Line 1063  in another keymap reached from @var{keym Line 1070  in another keymap reached from @var{keym
1070  meaningful.  (For a list of meaningful types, see @ref{Key Lookup}.)  meaningful.  (For a list of meaningful types, see @ref{Key Lookup}.)
1071  The value returned by @code{define-key} is @var{binding}.  The value returned by @code{define-key} is @var{binding}.
1072    
1073    If @var{key} is @code{[t]}, this sets the default binding in
1074    @var{keymap}.  When an event has no binding of its own, the Emacs
1075    command loop uses the keymap's default binding, if there is one.
1076    
1077  @cindex invalid prefix key error  @cindex invalid prefix key error
1078  @cindex key sequence error  @cindex key sequence error
1079  Every prefix of @var{key} must be a prefix key (i.e., bound to a keymap)  Every prefix of @var{key} must be a prefix key (i.e., bound to a keymap)
# Line 1072  key so that the rest of @var{key} can be Line 1083  key so that the rest of @var{key} can be
1083    
1084  If there was previously no binding for @var{key} in @var{keymap}, the  If there was previously no binding for @var{key} in @var{keymap}, the
1085  new binding is added at the beginning of @var{keymap}.  The order of  new binding is added at the beginning of @var{keymap}.  The order of
1086  bindings in a keymap makes no difference in most cases, but it does  bindings in a keymap makes no difference for keyboard input, but it
1087  matter for menu keymaps (@pxref{Menu Keymaps}).  does matter for menu keymaps (@pxref{Menu Keymaps}).
1088  @end defun  @end defun
1089    
1090    Here is an example that creates a sparse keymap and makes a number of    Here is an example that creates a sparse keymap and makes a number of
# Line 1100  map Line 1111  map
1111  @end group  @end group
1112  @group  @group
1113  map  map
1114  @result{} (keymap  @result{} (keymap
1115      (24 keymap                ; @kbd{C-x}      (24 keymap                ; @kbd{C-x}
1116          (102 . forward-word)) ;      @kbd{f}          (102 . forward-word)) ;      @kbd{f}
1117      (6 . forward-char))       ; @kbd{C-f}      (6 . forward-char))       ; @kbd{C-f}
# Line 1110  map Line 1121  map
1121  ;; @r{Bind @kbd{C-p} to the @code{ctl-x-map}.}  ;; @r{Bind @kbd{C-p} to the @code{ctl-x-map}.}
1122  (define-key map "\C-p" ctl-x-map)  (define-key map "\C-p" ctl-x-map)
1123  ;; @code{ctl-x-map}  ;; @code{ctl-x-map}
1124  @result{} [nil @dots{} find-file @dots{} backward-kill-sentence]  @result{} [nil @dots{} find-file @dots{} backward-kill-sentence]
1125  @end group  @end group
1126    
1127  @group  @group
# Line 1122  map Line 1133  map
1133  map  map
1134  @result{} (keymap     ; @r{Note @code{foo} in @code{ctl-x-map}.}  @result{} (keymap     ; @r{Note @code{foo} in @code{ctl-x-map}.}
1135      (16 keymap [nil @dots{} foo @dots{} backward-kill-sentence])      (16 keymap [nil @dots{} foo @dots{} backward-kill-sentence])
1136      (24 keymap      (24 keymap
1137          (102 . forward-word))          (102 . forward-word))
1138      (6 . forward-char))      (6 . forward-char))
1139  @end group  @end group
# Line 1146  standard bindings: Line 1157  standard bindings:
1157    
1158  @smallexample  @smallexample
1159  @group  @group
1160  (substitute-key-definition  (substitute-key-definition
1161   'find-file 'find-file-read-only (current-global-map))   'find-file 'find-file-read-only (current-global-map))
1162  @end group  @end group
1163  @end smallexample  @end smallexample
# Line 1179  Here is an example showing a keymap befo Line 1190  Here is an example showing a keymap befo
1190    
1191  @smallexample  @smallexample
1192  @group  @group
1193  (setq map '(keymap  (setq map '(keymap
1194              (?1 . olddef-1)              (?1 . olddef-1)
1195              (?2 . olddef-2)              (?2 . olddef-2)
1196              (?3 . olddef-1)))              (?3 . olddef-1)))
1197  @result{} (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1))  @result{} (keymap (49 . olddef-1) (50 . olddef-2) (51 . olddef-1))
1198  @end group  @end group
# Line 1209  digits to run @code{digit-argument}, and Line 1220  digits to run @code{digit-argument}, and
1220  @code{negative-argument}.  Otherwise it makes them undefined like the  @code{negative-argument}.  Otherwise it makes them undefined like the
1221  rest of the printing characters.  rest of the printing characters.
1222    
1223  @cindex yank suppression  @cindex yank suppression
1224  @cindex @code{quoted-insert} suppression  @cindex @code{quoted-insert} suppression
1225  The @code{suppress-keymap} function does not make it impossible to  The @code{suppress-keymap} function does not make it impossible to
1226  modify a buffer, as it does not suppress commands such as @code{yank}  modify a buffer, as it does not suppress commands such as @code{yank}
1227  and @code{quoted-insert}.  To prevent any modification of a buffer, make  and @code{quoted-insert}.  To prevent any modification of a buffer, make
# Line 1412  definition is the sparse keymap @code{(k Line 1423  definition is the sparse keymap @code{(k
1423  @smallexample  @smallexample
1424  @group  @group
1425  (accessible-keymaps (current-local-map))  (accessible-keymaps (current-local-map))
1426  @result{}(("" keymap  @result{}(("" keymap
1427        (27 keymap   ; @r{Note this keymap for @key{ESC} is repeated below.}        (27 keymap   ; @r{Note this keymap for @key{ESC} is repeated below.}
1428            (83 . center-paragraph)            (83 . center-paragraph)
1429            (115 . center-line))            (115 . center-line))
# Line 1420  definition is the sparse keymap @code{(k Line 1431  definition is the sparse keymap @code{(k
1431  @end group  @end group
1432    
1433  @group  @group
1434     ("^[" keymap     ("^[" keymap
1435      (83 . center-paragraph)      (83 . center-paragraph)
1436      (115 . foo)))      (115 . foo)))
1437  @end group  @end group
1438  @end smallexample  @end smallexample
# Line 1436  of a window. Line 1447  of a window.
1447  @smallexample  @smallexample
1448  @group  @group
1449  (accessible-keymaps (current-global-map))  (accessible-keymaps (current-global-map))
1450  @result{} (("" keymap [set-mark-command beginning-of-line @dots{}  @result{} (("" keymap [set-mark-command beginning-of-line @dots{}
1451                     delete-backward-char])                     delete-backward-char])
1452  @end group  @end group
1453  @group  @group
# Line 2229  property list elements to add to the men Line 2240  property list elements to add to the men
2240  To define items in some local map, bind @code{`tool-bar-map} with  To define items in some local map, bind @code{`tool-bar-map} with
2241  @code{let} around calls of this function:  @code{let} around calls of this function:
2242  @example  @example
2243  (defvar foo-tool-bar-map  (defvar foo-tool-bar-map
2244    (let ((tool-bar-map (make-sparse-keymap)))    (let ((tool-bar-map (make-sparse-keymap)))
2245      (tool-bar-add-item @dots{})      (tool-bar-add-item @dots{})
2246      @dots{}      @dots{}

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.39.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26