Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow binding a key to a keymap. #1208

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/keymap.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))))
Expand Down