Use key-parse' in
keymap-lookup'
It's stricter than `kbd', and doesn't try to do anything with key sequences that look like macros. * lisp/keymap.el (keymap-lookup): Use `key-parse' instead of `kbd'. * test/src/keymap-tests.el (keymap-set-after-menus): Test the `keymap-set-after' API.
This commit is contained in:
parent
8904a26a9d
commit
dcd59457b4
2 changed files with 17 additions and 1 deletions
|
@ -405,7 +405,7 @@ specified buffer position instead of point are used."
|
||||||
(symbolp value))
|
(symbolp value))
|
||||||
(or (command-remapping value) value)
|
(or (command-remapping value) value)
|
||||||
value))
|
value))
|
||||||
(key-binding (kbd key) accept-default no-remap position)))
|
(key-binding (key-parse key) accept-default no-remap position)))
|
||||||
|
|
||||||
(defun keymap-local-lookup (keys &optional accept-default)
|
(defun keymap-local-lookup (keys &optional accept-default)
|
||||||
"Return the binding for command KEYS in current local keymap only.
|
"Return the binding for command KEYS in current local keymap only.
|
||||||
|
|
|
@ -430,6 +430,22 @@ g .. h foo
|
||||||
(make-non-key-event 'keymap-tests-event)
|
(make-non-key-event 'keymap-tests-event)
|
||||||
(should (equal (where-is-internal 'keymap-tests-command) '([3 103]))))
|
(should (equal (where-is-internal 'keymap-tests-command) '([3 103]))))
|
||||||
|
|
||||||
|
(ert-deftest keymap-set-consistency ()
|
||||||
|
(let ((k (make-sparse-keymap)))
|
||||||
|
;; `keymap-set' returns the binding, `keymap-set-after' doesn't,
|
||||||
|
;; so we need to check for nil. <sigh>
|
||||||
|
(should (keymap-set k "a" "a"))
|
||||||
|
(should (equal (keymap-lookup k "a") (key-parse "a")))
|
||||||
|
(should-not (keymap-set-after k "b" "b"))
|
||||||
|
(should (equal (keymap-lookup k "b") (key-parse "b")))
|
||||||
|
(should-not (keymap-set-after k "d" "d" t))
|
||||||
|
(should (equal (keymap-lookup k "d") (key-parse "d")))
|
||||||
|
(should-not (keymap-set-after k "e" "e" nil))
|
||||||
|
(should (equal (keymap-lookup k "e") (key-parse "e")))
|
||||||
|
;; This doesn't fail, but it does not add the 'f' binding after 'a'
|
||||||
|
(should-not (keymap-set-after k "f" "f" "a"))
|
||||||
|
(should (equal (keymap-lookup k "f") (key-parse "f")))))
|
||||||
|
|
||||||
(ert-deftest keymap-test-duplicate-definitions ()
|
(ert-deftest keymap-test-duplicate-definitions ()
|
||||||
"Check that defvar-keymap rejects duplicate key definitions."
|
"Check that defvar-keymap rejects duplicate key definitions."
|
||||||
(should-error
|
(should-error
|
||||||
|
|
Loading…
Add table
Reference in a new issue