summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2011-08-03 17:40:06 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2011-08-03 17:40:06 -0400
commit640c8776f65beda19e4d4221b1cc2fe7a4b503d0 (patch)
tree63db8386b0bb79328e9f4dce9a7efab2373847e4 /lisp/subr.el
parent8a10d76c8770781641cc742beb6a2ba653c99e00 (diff)
downloademacs-640c8776f65beda19e4d4221b1cc2fe7a4b503d0.tar.gz
* src/keymap.c (Fmake_composed_keymap): Move to subr.el.
* lisp/subr.el (make-composed-keymap): Move from C. Change calling convention, and improve docstring to bring attention to a subtle point. * lisp/minibuffer.el (completing-read-default): Adjust accordingly.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index ef19797012a..d57c507a548 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -526,6 +526,20 @@ but optional second arg NODIGITS non-nil treats them like other chars."
(define-key map (char-to-string loop) 'digit-argument)
(setq loop (1+ loop))))))
+(defun make-composed-keymap (maps &optional parent)
+ "Construct a new keymap composed of MAPS and inheriting from PARENT.
+When looking up a key in the returned map, the key is looked in each
+keymap of MAPS in turn until a binding is found.
+If no binding is found in MAPS, the lookup continues in PARENT, if non-nil.
+As always with keymap inheritance, a nil binding in MAPS overrides
+any corresponding binding in PARENT, but it does not override corresponding
+bindings in other keymaps of MAPS.
+MAPS can be a list of keymaps or a single keymap.
+PARENT if non-nil should be a keymap."
+ `(keymap
+ ,@(if (keymapp maps) (list maps) maps)
+ ,@parent))
+
(defun define-key-after (keymap key definition &optional after)
"Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding.
This is like `define-key' except that the binding for KEY is placed