Copyright (C) 2000-2012 |
GNU Info (elisp)Inheritance and KeymapsInheritance and Keymaps ======================= A keymap can inherit the bindings of another keymap, which we call the "parent keymap". Such a keymap looks like this: (keymap BINDINGS... . PARENT-KEYMAP) The effect is that this keymap inherits all the bindings of PARENT-KEYMAP, whatever they may be at the time a key is looked up, but can add to them or override them with BINDINGS. If you change the bindings in PARENT-KEYMAP using `define-key' or other key-binding functions, these changes are visible in the inheriting keymap unless shadowed by BINDINGS. The converse is not true: if you use `define-key' to change the inheriting keymap, that affects BINDINGS, but has no effect on PARENT-KEYMAP. The proper way to construct a keymap with a parent is to use `set-keymap-parent'; if you have code that directly constructs a keymap with a parent, please convert the program to use `set-keymap-parent' instead. - Function: keymap-parent keymap This returns the parent keymap of KEYMAP. If KEYMAP has no parent, `keymap-parent' returns `nil'. - Function: set-keymap-parent keymap parent This sets the parent keymap of KEYMAP to PARENT, and returns PARENT. If PARENT is `nil', this function gives KEYMAP no parent at all. If KEYMAP has submaps (bindings for prefix keys), they too receive new parent keymaps that reflect what PARENT specifies for those prefix keys. Here is an example showing how to make a keymap that inherits from `text-mode-map': (let ((map (make-sparse-keymap))) (set-keymap-parent map text-mode-map) map) automatically generated by info2www version 1.2.2.9 |