From 562e180e64277f526f0f8f5a69823c0c156c6b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20G=C3=B6ttschkes?= Date: Sat, 30 Dec 2023 00:07:07 +0100 Subject: [PATCH] Allow binding a key to a keymap. --- src/keymap.lisp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/keymap.lisp b/src/keymap.lisp index ef73eb2c7..40747cbba 100644 --- a/src/keymap.lisp +++ b/src/keymap.lisp @@ -36,7 +36,7 @@ (defun define-key (keymap keyspec command-name) (check-type keyspec (or symbol string)) - (check-type command-name symbol) + (check-type command-name (or symbol keymap)) (typecase keyspec (symbol (setf (gethash keyspec (keymap-function-table keymap)) @@ -119,9 +119,11 @@ (let ((table (keymap-table keymap))) (labels ((f (k) (let ((cmd (gethash k table))) - (if (prefix-command-p cmd) - (setf table cmd) - cmd)))) + (cond ((prefix-command-p cmd) + (setf table cmd)) + ((keymap-p cmd) + (setf table (keymap-table cmd))) + (t cmd))))) (let ((parent (keymap-parent keymap))) (when parent (setf cmd (keymap-find-keybind parent key cmd))))