aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-11-16 08:02:22 +0100
committerLars Ingebrigtsen2021-11-16 08:26:24 +0100
commit560c921ed8d2d14e593aaee68b8be57b189128e5 (patch)
treef27bed157496a36ecee2d7ebac46cec8aa3513c5 /test/src
parentaa4cffccac0794870985c9d6cec82a0eb7bab137 (diff)
downloademacs-560c921ed8d2d14e593aaee68b8be57b189128e5.tar.gz
emacs-560c921ed8d2d14e593aaee68b8be57b189128e5.zip
Allow removing keymap definitions
* src/keymap.c (initial_define_lispy_key): Adjust caller. (store_in_keymap): Allow removing definitions in addition to setting them to nil. (Fdefine_key): Ditto. (define_as_prefix): Adjust caller. * src/term.c (term_get_fkeys_1): Adjust caller.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/keymap-tests.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index 8e28faf2b26..629d6c55849 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -373,6 +373,40 @@ g .. h foo
373 (should (eq (lookup-key (current-global-map) ["C-x C-f"]) 'find-file)) 373 (should (eq (lookup-key (current-global-map) ["C-x C-f"]) 'find-file))
374 (should (eq (lookup-key (current-global-map) [?\C-x ?\C-f]) 'find-file))) 374 (should (eq (lookup-key (current-global-map) [?\C-x ?\C-f]) 'find-file)))
375 375
376(ert-deftest keymap-removal ()
377 ;; Set to nil.
378 (let ((map (define-keymap "a" 'foo)))
379 (should (equal map '(keymap (97 . foo))))
380 (define-key map "a" nil)
381 (should (equal map '(keymap (97)))))
382 ;; Remove.
383 (let ((map (define-keymap "a" 'foo)))
384 (should (equal map '(keymap (97 . foo))))
385 (define-key map "a" nil t)
386 (should (equal map '(keymap)))))
387
388(ert-deftest keymap-removal-inherit ()
389 ;; Set to nil.
390 (let ((parent (make-sparse-keymap))
391 (child (make-keymap)))
392 (set-keymap-parent child parent)
393 (define-key parent [?a] 'foo)
394 (define-key child [?a] 'bar)
395
396 (should (eq (lookup-key child [?a]) 'bar))
397 (define-key child [?a] nil)
398 (should (eq (lookup-key child [?a]) nil)))
399 ;; Remove.
400 (let ((parent (make-sparse-keymap))
401 (child (make-keymap)))
402 (set-keymap-parent child parent)
403 (define-key parent [?a] 'foo)
404 (define-key child [?a] 'bar)
405
406 (should (eq (lookup-key child [?a]) 'bar))
407 (define-key child [?a] nil t)
408 (should (eq (lookup-key child [?a]) 'foo))))
409
376(provide 'keymap-tests) 410(provide 'keymap-tests)
377 411
378;;; keymap-tests.el ends here 412;;; keymap-tests.el ends here