diff options
| author | Glenn Morris | 2012-02-05 19:20:11 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-02-05 19:20:11 -0800 |
| commit | dac86404ae17873adeff3f1f977b443a72772884 (patch) | |
| tree | ac7b496926835031547d9e755e6da103829cc9e8 | |
| parent | 91d2ed4e3b1650f1eaa4e9c2e291d574d95bd8ea (diff) | |
| download | emacs-dac86404ae17873adeff3f1f977b443a72772884.tar.gz emacs-dac86404ae17873adeff3f1f977b443a72772884.zip | |
Document make-composed-keymap
* doc/lispref/keymaps.texi (Inheritance and Keymaps):
Mention make-composed-keymap and multiple inheritance.
* etc/NEWS: Related edits.
| -rw-r--r-- | doc/lispref/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/lispref/keymaps.texi | 28 | ||||
| -rw-r--r-- | etc/NEWS | 7 |
3 files changed, 35 insertions, 2 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index e26f91b1b4c..5de2251c19f 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | 2012-02-06 Glenn Morris <rgm@gnu.org> | 1 | 2012-02-06 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * keymaps.texi (Tool Bar): Mention separators. | 3 | * keymaps.texi (Tool Bar): Mention separators. |
| 4 | (Inheritance and Keymaps): | ||
| 5 | Mention make-composed-keymap and multiple inheritance. | ||
| 4 | 6 | ||
| 5 | * modes.texi (Running Hooks): Mention run-hook-wrapped. | 7 | * modes.texi (Running Hooks): Mention run-hook-wrapped. |
| 6 | 8 | ||
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi index 923989413ee..a4c8c3981f3 100644 --- a/doc/lispref/keymaps.texi +++ b/doc/lispref/keymaps.texi | |||
| @@ -432,6 +432,34 @@ for every numeric character code without modifier bits, even if it is | |||
| 432 | @code{nil}, so these character's bindings are never inherited from | 432 | @code{nil}, so these character's bindings are never inherited from |
| 433 | the parent keymap. | 433 | the parent keymap. |
| 434 | 434 | ||
| 435 | @cindex keymap inheritance from multiple maps | ||
| 436 | Sometimes you want to make a keymap that inherits from more than one | ||
| 437 | map. You can use the function @code{make-composed-keymap} for this. | ||
| 438 | |||
| 439 | @defun make-composed-keymap maps &optional parent | ||
| 440 | This function returns a new keymap composed of the existing keymap(s) | ||
| 441 | @var{maps}, and optionally inheriting from a parent keymap | ||
| 442 | @var{parent}. @var{maps} can be a single keymap or a list of more | ||
| 443 | than one. When looking up a key in the resulting new map, Emacs | ||
| 444 | searches in each of the @var{maps}, and then in @var{parent}, stopping | ||
| 445 | at the first match. A @code{nil} binding in any one of @var{maps} | ||
| 446 | overrides any binding in @var{parent}, but not a non-@code{nil} binding | ||
| 447 | in any other of the @var{maps}. | ||
| 448 | @end defun | ||
| 449 | |||
| 450 | @noindent For example, here is how Emacs sets the parent of | ||
| 451 | @code{help-mode-map}, such that it inherits from both | ||
| 452 | @code{button-buffer-map} and @code{special-mode-map}: | ||
| 453 | |||
| 454 | @example | ||
| 455 | (defvar help-mode-map | ||
| 456 | (let ((map (make-sparse-keymap))) | ||
| 457 | (set-keymap-parent map (make-composed-keymap button-buffer-map | ||
| 458 | special-mode-map)) | ||
| 459 | ... map) ... ) | ||
| 460 | @end example | ||
| 461 | |||
| 462 | |||
| 435 | @node Prefix Keys | 463 | @node Prefix Keys |
| 436 | @section Prefix Keys | 464 | @section Prefix Keys |
| 437 | @cindex prefix key | 465 | @cindex prefix key |
| @@ -1412,8 +1412,11 @@ as well as those in the -*- line. | |||
| 1412 | --- | 1412 | --- |
| 1413 | ** rx.el has a new `group-n' construct for explicitly numbered groups. | 1413 | ** rx.el has a new `group-n' construct for explicitly numbered groups. |
| 1414 | 1414 | ||
| 1415 | ** keymaps can inherit from multiple parents. | 1415 | +++ |
| 1416 | There is a new function `make-composed-keymap' that [does something]. | 1416 | ** New function `make-composed-keymap' that constructs a new keymap |
| 1417 | from multiple input maps. You can use this to make a keymap that | ||
| 1418 | inherits from multiple maps, eg: | ||
| 1419 | (set-keymap-parent newmap (make-composed-keymap othermap parent)) | ||
| 1417 | 1420 | ||
| 1418 | +++ | 1421 | +++ |
| 1419 | ** Set `debug-on-event' to make Emacs enter the debugger e.g. on receipt | 1422 | ** Set `debug-on-event' to make Emacs enter the debugger e.g. on receipt |