aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-02-15 00:41:16 +0800
committerChong Yidong2012-02-15 00:41:16 +0800
commit3d8badf411c8749ea9fcd7c525471fe01c416d6b (patch)
treee283c311ce2b24776aca0349566d69f330ecc34e
parent835bdcba536b6df51ff97d1a914b42a7d9072298 (diff)
downloademacs-3d8badf411c8749ea9fcd7c525471fe01c416d6b.tar.gz
emacs-3d8badf411c8749ea9fcd7c525471fe01c416d6b.zip
Update Keymaps chapter of Lisp manual.
* doc/emacs/keymaps.texi (Format of Keymaps): The CACHE component of keymaps was removed on 2009-09-10. Update lisp-mode-map example. (Inheritance and Keymaps): Minor clarification. (Searching Keymaps): Remove out-of-place enumeration. (Key Lookup): Remove unnecessary example (one was already given in Format of Keymaps). (Changing Key Bindings): Update suppress-keymap example. (Menu Bar, Tool Bar): Copyedits. (Tool Bar): Update tool-bar-map example.
-rw-r--r--admin/FOR-RELEASE2
-rw-r--r--doc/lispref/ChangeLog12
-rw-r--r--doc/lispref/keymaps.texi211
3 files changed, 91 insertions, 134 deletions
diff --git a/admin/FOR-RELEASE b/admin/FOR-RELEASE
index 75103ff3cec..f2c572cfd17 100644
--- a/admin/FOR-RELEASE
+++ b/admin/FOR-RELEASE
@@ -204,7 +204,7 @@ hooks.texi
204index.texi 204index.texi
205internals.texi 205internals.texi
206intro.texi cyd 206intro.texi cyd
207keymaps.texi 207keymaps.texi cyd
208lists.texi cyd 208lists.texi cyd
209loading.texi cyd 209loading.texi cyd
210locals.texi 210locals.texi
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index c5848ca8b2d..baab5113057 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,15 @@
12012-02-14 Chong Yidong <cyd@gnu.org>
2
3 * keymaps.texi (Format of Keymaps): The CACHE component of keymaps
4 was removed on 2009-09-10. Update lisp-mode-map example.
5 (Inheritance and Keymaps): Minor clarification.
6 (Searching Keymaps): Remove out-of-place enumeration.
7 (Key Lookup): Remove unnecessary example (one was already given in
8 Format of Keymaps).
9 (Changing Key Bindings): Update suppress-keymap example.
10 (Menu Bar, Tool Bar): Copyedits.
11 (Tool Bar): Update tool-bar-map example.
12
12012-02-12 Chong Yidong <cyd@gnu.org> 132012-02-12 Chong Yidong <cyd@gnu.org>
2 14
3 * debugging.texi (Debugger Commands): Continuing is now allowed 15 * debugging.texi (Debugger Commands): Continuing is now allowed
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi
index a8528a548fc..5652d94114e 100644
--- a/doc/lispref/keymaps.texi
+++ b/doc/lispref/keymaps.texi
@@ -173,13 +173,11 @@ ordinary binding applies to events of a particular @dfn{event type},
173which is always a character or a symbol. @xref{Classifying Events}. 173which is always a character or a symbol. @xref{Classifying Events}.
174In this kind of binding, @var{binding} is a command. 174In this kind of binding, @var{binding} is a command.
175 175
176@item (@var{type} @var{item-name} @r{[}@var{cache}@r{]} .@: @var{binding}) 176@item (@var{type} @var{item-name} .@: @var{binding})
177This specifies a binding which is also a simple menu item that 177This specifies a binding which is also a simple menu item that
178displays as @var{item-name} in the menu. @var{cache}, if present, 178displays as @var{item-name} in the menu. @xref{Simple Menu Items}.
179caches certain information for display in the menu. @xref{Simple Menu
180Items}.
181 179
182@item (@var{type} @var{item-name} @var{help-string} @r{[}@var{cache}@r{]} .@: @var{binding}) 180@item (@var{type} @var{item-name} @var{help-string} .@: @var{binding})
183This is a simple menu item with help string @var{help-string}. 181This is a simple menu item with help string @var{help-string}.
184 182
185@item (@var{type} menu-item .@: @var{details}) 183@item (@var{type} menu-item .@: @var{details})
@@ -234,8 +232,9 @@ other input events; thus, @kbd{M-@key{end}} has nothing to do with
234@kbd{@key{ESC} @key{end}}. 232@kbd{@key{ESC} @key{end}}.
235 233
236 Here as an example is the local keymap for Lisp mode, a sparse 234 Here as an example is the local keymap for Lisp mode, a sparse
237keymap. It defines bindings for @key{DEL} and @key{TAB}, plus @kbd{C-c 235keymap. It defines bindings for @key{DEL}, @kbd{C-c C-z},
238C-l}, @kbd{M-C-q}, and @kbd{M-C-x}. 236@kbd{C-M-q}, and @kbd{C-M-x} (the actual value also contains a menu
237binding, which is omitted here for the sake of brevity).
239 238
240@example 239@example
241@group 240@group
@@ -250,11 +249,8 @@ lisp-mode-map
250@end group 249@end group
251@group 250@group
252 (27 keymap 251 (27 keymap
253 ;; @r{@kbd{M-C-x}, treated as @kbd{@key{ESC} C-x}} 252 ;; @r{@kbd{C-M-x}, treated as @kbd{@key{ESC} C-x}}
254 (24 . lisp-send-defun) 253 (24 . lisp-send-defun))
255 keymap
256 ;; @r{@kbd{M-C-q}, treated as @kbd{@key{ESC} C-q}}
257 (17 . indent-sexp))
258@end group 254@end group
259@group 255@group
260 ;; @r{This part is inherited from @code{lisp-mode-shared-map}.} 256 ;; @r{This part is inherited from @code{lisp-mode-shared-map}.}
@@ -264,9 +260,8 @@ lisp-mode-map
264@end group 260@end group
265@group 261@group
266 (27 keymap 262 (27 keymap
267 ;; @r{@kbd{M-C-q}, treated as @kbd{@key{ESC} C-q}} 263 ;; @r{@kbd{C-M-q}, treated as @kbd{@key{ESC} C-q}}
268 (17 . indent-sexp)) 264 (17 . indent-sexp)))
269 (9 . lisp-indent-line))
270@end group 265@end group
271@end example 266@end example
272 267
@@ -441,10 +436,10 @@ This function returns a new keymap composed of the existing keymap(s)
441@var{maps}, and optionally inheriting from a parent keymap 436@var{maps}, and optionally inheriting from a parent keymap
442@var{parent}. @var{maps} can be a single keymap or a list of more 437@var{parent}. @var{maps} can be a single keymap or a list of more
443than one. When looking up a key in the resulting new map, Emacs 438than one. When looking up a key in the resulting new map, Emacs
444searches in each of the @var{maps}, and then in @var{parent}, stopping 439searches in each of the @var{maps} in turn, and then in @var{parent},
445at the first match. A @code{nil} binding in any one of @var{maps} 440stopping at the first match. A @code{nil} binding in any one of
446overrides any binding in @var{parent}, but not a non-@code{nil} binding 441@var{maps} overrides any binding in @var{parent}, but it does not
447in any other of the @var{maps}. 442override any non-@code{nil} binding in any other of the @var{maps}.
448@end defun 443@end defun
449 444
450@noindent For example, here is how Emacs sets the parent of 445@noindent For example, here is how Emacs sets the parent of
@@ -762,35 +757,23 @@ them:
762@end lisp 757@end lisp
763 758
764@noindent 759@noindent
765The @var{find-in} and @var{find-in-any} are pseudo functions that 760@var{find-in} and @var{find-in-any} are pseudo functions that search
766search in one keymap and in an alist of keymaps, respectively. 761in one keymap and in an alist of keymaps, respectively. (Searching a
767(Searching a single keymap for a binding is called @dfn{key lookup}; 762single keymap for a binding is called @dfn{key lookup}; see @ref{Key
768see @ref{Key Lookup}.) If the key sequence starts with a mouse event, 763Lookup}.) If the key sequence starts with a mouse event, or a
769or a symbolic prefix event followed by a mouse event, that event's 764symbolic prefix event followed by a mouse event, that event's position
770position is used instead of point and the current buffer. Mouse 765is used instead of point and the current buffer. Mouse events on an
771events on an embedded string use non-@code{nil} text properties from 766embedded string use non-@code{nil} text properties from that string
772that string instead of the buffer. 767instead of the buffer.
773 768
774@enumerate 769 When a match is found (@pxref{Key Lookup}), if the binding in the
775@item
776The function finally found may be remapped
777(@pxref{Remapping Commands}).
778
779@item
780Characters that are bound to @code{self-insert-command} are translated
781according to @code{translation-table-for-input} before insertion.
782
783@item
784@code{current-active-maps} returns a list of the
785currently active keymaps at point.
786
787@item
788When a match is found (@pxref{Key Lookup}), if the binding in the
789keymap is a function, the search is over. However if the keymap entry 770keymap is a function, the search is over. However if the keymap entry
790is a symbol with a value or a string, Emacs replaces the input key 771is a symbol with a value or a string, Emacs replaces the input key
791sequences with the variable's value or the string, and restarts the 772sequences with the variable's value or the string, and restarts the
792search of the active keymaps. 773search of the active keymaps.
793@end enumerate 774
775 The function finally found might also be remapped. @xref{Remapping
776Commands}.
794 777
795@node Controlling Active Maps 778@node Controlling Active Maps
796@section Controlling the Active Keymaps 779@section Controlling the Active Keymaps
@@ -1088,21 +1071,9 @@ lookup form a complete key, and the object is its binding, but the
1088binding is not executable as a command. 1071binding is not executable as a command.
1089@end table 1072@end table
1090 1073
1091 In short, a keymap entry may be a keymap, a command, a keyboard macro, 1074 In short, a keymap entry may be a keymap, a command, a keyboard
1092a symbol that leads to one of them, or an indirection or @code{nil}. 1075macro, a symbol that leads to one of them, or an indirection or
1093Here is an example of a sparse keymap with two characters bound to 1076@code{nil}.
1094commands and one bound to another keymap. This map is the normal value
1095of @code{emacs-lisp-mode-map}. Note that 9 is the code for @key{TAB},
1096127 for @key{DEL}, 27 for @key{ESC}, 17 for @kbd{C-q} and 24 for
1097@kbd{C-x}.
1098
1099@example
1100@group
1101(keymap (9 . lisp-indent-line)
1102 (127 . backward-delete-char-untabify)
1103 (27 keymap (17 . indent-sexp) (24 . eval-defun)))
1104@end group
1105@end example
1106 1077
1107@node Functions for Key Lookup 1078@node Functions for Key Lookup
1108@section Functions for Key Lookup 1079@section Functions for Key Lookup
@@ -1472,23 +1443,21 @@ that is used for some other purpose is likely to cause trouble; for
1472example, suppressing @code{global-map} would make it impossible to use 1443example, suppressing @code{global-map} would make it impossible to use
1473most of Emacs. 1444most of Emacs.
1474 1445
1475Most often, @code{suppress-keymap} is used to initialize local 1446This function can be used to initialize the local keymap of a major
1476keymaps of modes such as Rmail and Dired where insertion of text is not 1447mode for which insertion of text is not desirable. But usually such a
1477desirable and the buffer is read-only. Here is an example taken from 1448mode should be derived from @code{special-mode} (@pxref{Basic Major
1478the file @file{emacs/lisp/dired.el}, showing how the local keymap for 1449Modes}); then its keymap will automatically inherit from
1479Dired mode is set up: 1450@code{special-mode-map}, which is already suppressed. Here is how
1451@code{special-mode-map} is defined:
1480 1452
1481@smallexample 1453@smallexample
1482@group 1454@group
1483(setq dired-mode-map (make-keymap)) 1455(defvar special-mode-map
1484(suppress-keymap dired-mode-map) 1456 (let ((map (make-sparse-keymap)))
1485(define-key dired-mode-map "r" 'dired-rename-file) 1457 (suppress-keymap map)
1486(define-key dired-mode-map "\C-d" 'dired-flag-file-deleted) 1458 (define-key map "q" 'quit-window)
1487(define-key dired-mode-map "d" 'dired-flag-file-deleted) 1459 @dots{}
1488(define-key dired-mode-map "v" 'dired-view-file) 1460 map))
1489(define-key dired-mode-map "e" 'dired-find-file)
1490(define-key dired-mode-map "f" 'dired-find-file)
1491@dots{}
1492@end group 1461@end group
1493@end smallexample 1462@end smallexample
1494@end defun 1463@end defun
@@ -2064,12 +2033,10 @@ event type (it doesn't matter what event type) to a binding like this:
2064@noindent 2033@noindent
2065The @sc{car}, @var{item-string}, is the string to be displayed in the 2034The @sc{car}, @var{item-string}, is the string to be displayed in the
2066menu. It should be short---preferably one to three words. It should 2035menu. It should be short---preferably one to three words. It should
2067describe the action of the command it corresponds to. Note that it is 2036describe the action of the command it corresponds to. Note that not
2068not generally possible to display non-@acronym{ASCII} text in menus. It will 2037all graphical toolkits can display non-@acronym{ASCII} text in menus
2069work for keyboard menus and will work to a large extent when Emacs is 2038(it will work for keyboard menus and will work to a large extent with
2070built with the Gtk+ toolkit.@footnote{In this case, the text is first 2039the GTK+ toolkit).
2071encoded using the @code{utf-8} coding system and then rendered by the
2072toolkit as it sees fit.}
2073 2040
2074 You can also supply a second string, called the help string, as follows: 2041 You can also supply a second string, called the help string, as follows:
2075 2042
@@ -2418,18 +2385,6 @@ this; @key{SPC} is the default.)
2418she should type the corresponding character---the one whose binding is 2385she should type the corresponding character---the one whose binding is
2419that alternative. 2386that alternative.
2420 2387
2421@ignore
2422In a menu intended for keyboard use, each menu item must clearly
2423indicate what character to type. The best convention to use is to make
2424the character the first letter of the item string---that is something
2425users will understand without being told. We plan to change this; by
2426the time you read this manual, keyboard menus may explicitly name the
2427key for each alternative.
2428@end ignore
2429
2430 This way of using menus in an Emacs-like editor was inspired by the
2431Hierarkey system.
2432
2433@defvar menu-prompt-more-char 2388@defvar menu-prompt-more-char
2434This variable specifies the character to use to ask to see 2389This variable specifies the character to use to ask to see
2435the next line of a menu. Its initial value is 32, the code 2390the next line of a menu. Its initial value is 32, the code
@@ -2512,21 +2467,17 @@ can do it this way:
2512@subsection The Menu Bar 2467@subsection The Menu Bar
2513@cindex menu bar 2468@cindex menu bar
2514 2469
2515 Most window systems allow each frame to have a @dfn{menu bar}---a 2470 On graphical displays, there is usually a @dfn{menu bar} at the top
2516permanently displayed menu stretching horizontally across the top of 2471of each frame. @xref{Menu Bars,,,emacs, The GNU Emacs Manual}. Menu
2517the frame. (In order for a frame to display a menu bar, its 2472bar items are subcommands of the fake ``function key''
2518@code{menu-bar-lines} parameter must be greater than zero. 2473@code{menu-bar}, as defined in the active keymaps.
2519@xref{Layout Parameters}.)
2520
2521 The items of the menu bar are the subcommands of the fake ``function
2522key'' @code{menu-bar}, as defined in the active keymaps.
2523 2474
2524 To add an item to the menu bar, invent a fake ``function key'' of your 2475 To add an item to the menu bar, invent a fake ``function key'' of your
2525own (let's call it @var{key}), and make a binding for the key sequence 2476own (let's call it @var{key}), and make a binding for the key sequence
2526@code{[menu-bar @var{key}]}. Most often, the binding is a menu keymap, 2477@code{[menu-bar @var{key}]}. Most often, the binding is a menu keymap,
2527so that pressing a button on the menu bar item leads to another menu. 2478so that pressing a button on the menu bar item leads to another menu.
2528 2479
2529 When more than one active keymap defines the same fake function key 2480 When more than one active keymap defines the same ``function key''
2530for the menu bar, the item appears just once. If the user clicks on 2481for the menu bar, the item appears just once. If the user clicks on
2531that menu bar item, it brings up a single, combined menu containing 2482that menu bar item, it brings up a single, combined menu containing
2532all the subcommands of that item---the global subcommands, the local 2483all the subcommands of that item---the global subcommands, the local
@@ -2541,11 +2492,6 @@ were @code{nil}. @xref{Active Keymaps}.
2541 2492
2542@example 2493@example
2543@group 2494@group
2544(modify-frame-parameters (selected-frame)
2545 '((menu-bar-lines . 2)))
2546@end group
2547
2548@group
2549;; @r{Make a menu keymap (with a prompt string)} 2495;; @r{Make a menu keymap (with a prompt string)}
2550;; @r{and make it the menu bar item's definition.} 2496;; @r{and make it the menu bar item's definition.}
2551(define-key global-map [menu-bar words] 2497(define-key global-map [menu-bar words]
@@ -2618,20 +2564,17 @@ that the command does not actually have, it is ignored.
2618@subsection Tool bars 2564@subsection Tool bars
2619@cindex tool bar 2565@cindex tool bar
2620 2566
2621 A @dfn{tool bar} is a row of icons at the top of a frame, that execute 2567 A @dfn{tool bar} is a row of clickable icons at the top of a frame,
2622commands when you click on them---in effect, a kind of graphical menu 2568just below the menu bar. @xref{Tool Bars,,,emacs, The GNU Emacs
2623bar. 2569Manual}.
2624
2625 The frame parameter @code{tool-bar-lines} (X resource @samp{toolBar})
2626controls how many lines' worth of height to reserve for the tool bar. A
2627zero value suppresses the tool bar. If the value is nonzero, and
2628@code{auto-resize-tool-bars} is non-@code{nil}, the tool bar expands and
2629contracts automatically as needed to hold the specified contents.
2630 2570
2631 If the value of @code{auto-resize-tool-bars} is @code{grow-only}, 2571 On each frame, the frame parameter @code{tool-bar-lines} controls
2632the tool bar expands automatically, but does not contract automatically. 2572how many lines' worth of height to reserve for the tool bar. A zero
2633To contract the tool bar, the user has to redraw the frame by entering 2573value suppresses the tool bar. If the value is nonzero, and
2634@kbd{C-l}. 2574@code{auto-resize-tool-bars} is non-@code{nil}, the tool bar expands
2575and contracts automatically as needed to hold the specified contents.
2576If the value is @code{grow-only}, the tool bar expands automatically,
2577but does not contract automatically.
2635 2578
2636 The tool bar contents are controlled by a menu keymap attached to a 2579 The tool bar contents are controlled by a menu keymap attached to a
2637fake ``function key'' called @code{tool-bar} (much like the way the menu 2580fake ``function key'' called @code{tool-bar} (much like the way the menu
@@ -2683,17 +2626,17 @@ button in disabled state by applying an edge-detection algorithm to the
2683image. 2626image.
2684 2627
2685The @code{:rtl} property specifies an alternative image to use for 2628The @code{:rtl} property specifies an alternative image to use for
2686right-to-left languages. Only the Gtk+ version of Emacs supports this 2629right-to-left languages. Only the GTK+ version of Emacs supports this
2687at present. 2630at present.
2688 2631
2689Like the menu bar, the tool bar can display separators (@pxref{Menu 2632Like the menu bar, the tool bar can display separators (@pxref{Menu
2690Separators}). Tool bar separators are vertical rather than 2633Separators}). Tool bar separators are vertical rather than
2691horizontal, though, and only a single style is supported. Separators 2634horizontal, though, and only a single style is supported. They are
2692are represented in the tool bar keymap in the same way as for the 2635represented in the tool bar keymap by @code{(menu-item "--")} entries;
2693menu bar, i.e. using a @code{(menu-item "--"}) entry. The Gtk+ and 2636properties like @code{:visible} are not supported for tool bar
2694Nextstep tool bars render separators natively, otherwise Emacs selects 2637separators. Separators are rendered natively in GTK+ and Nextstep
2695a separator image that is appropriate for the display. Note that tool 2638tool bars; in the other cases, they are rendered using an image of a
2696bar separators do not support any properties, such as @code{:visible}. 2639vertical line.
2697 2640
2698The default tool bar is defined so that items specific to editing do not 2641The default tool bar is defined so that items specific to editing do not
2699appear for major modes whose command symbol has a @code{mode-class} 2642appear for major modes whose command symbol has a @code{mode-class}
@@ -2706,18 +2649,20 @@ using an indirection through @code{tool-bar-map}.
2706 2649
2707@defvar tool-bar-map 2650@defvar tool-bar-map
2708By default, the global map binds @code{[tool-bar]} as follows: 2651By default, the global map binds @code{[tool-bar]} as follows:
2652
2709@example 2653@example
2710(global-set-key [tool-bar] 2654(global-set-key [tool-bar]
2711 '(menu-item "tool bar" ignore 2655 `(menu-item ,(purecopy "tool bar") ignore
2712 :filter (lambda (ignore) tool-bar-map))) 2656 :filter tool-bar-make-keymap))
2713@end example 2657@end example
2658
2714@noindent 2659@noindent
2715Thus the tool bar map is derived dynamically from the value of variable 2660The function @code{tool-bar-make-keymap}, in turn, derives the actual
2716@code{tool-bar-map} and you should normally adjust the default (global) 2661tool bar map dynamically from the value of the variable
2717tool bar by changing that map. Major modes may replace the global bar 2662@code{tool-bar-map}. Hence, you should normally adjust the default
2718completely by making @code{tool-bar-map} buffer-local and set to a 2663(global) tool bar by changing that map. Some major modes, such as
2719keymap containing only the desired items. Info mode provides an 2664Info mode, completely replace the global tool bar by making
2720example. 2665@code{tool-bar-map} buffer-local and setting it to a different keymap.
2721@end defvar 2666@end defvar
2722 2667
2723There are two convenience functions for defining tool bar items, as 2668There are two convenience functions for defining tool bar items, as