]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tests for Bug#62207
authorRobert Pluim <rpluim@gmail.com>
Sat, 18 Mar 2023 09:33:39 +0000 (10:33 +0100)
committerRobert Pluim <rpluim@gmail.com>
Sat, 18 Mar 2023 09:37:15 +0000 (10:37 +0100)
* test/src/keymap-tests.el (keymap-unset-test-remove-and-inheritance):
New test.

test/src/keymap-tests.el

index aa7105198259e96655164dd2a6e700d0f04348c1..29220c95395d5d346c0bfa615d28943edf58bd7d 100644 (file)
@@ -475,6 +475,24 @@ g .. h             foo
        "a" #'next-line
        "a" #'previous-line)))
 
+(ert-deftest keymap-unset-test-remove-and-inheritance ()
+  "Check various behaviors of keymap-unset.  (Bug#62207)"
+  (let ((map (make-sparse-keymap))
+        (parent (make-sparse-keymap)))
+    (set-keymap-parent map parent)
+    ;; Removing an unset key should not add a key.
+    (keymap-set parent "u" #'undo)
+    (keymap-unset map "u" t)
+    (should (equal (keymap-lookup map "u") #'undo))
+    ;; Non-removed child bindings should shadow parent
+    (keymap-set map "u" #'identity)
+    (keymap-unset map "u")
+    ;; From the child, but nil.
+    (should-not (keymap-lookup map "u"))
+    (keymap-unset map "u" t)
+    ;; From the parent this time/
+    (should (equal (keymap-lookup map "u") #'undo))))
+
 (provide 'keymap-tests)
 
 ;;; keymap-tests.el ends here