aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-13 12:12:32 -0500
committerCraig Jennings <c@cjennings.net>2026-06-13 12:12:32 -0500
commitcd9e1dd61e53c13e2a6f56633fbaa43853932ab8 (patch)
tree981e1bbbc21afedd2758277d792f5843b38f2ac2 /tests
parentdebd33f69d07117f2a46f3b8a03b86b9882896a6 (diff)
downloaddotemacs-cd9e1dd61e53c13e2a6f56633fbaa43853932ab8.tar.gz
dotemacs-cd9e1dd61e53c13e2a6f56633fbaa43853932ab8.zip
fix(keys): destructive delete on capital D, diff on lowercase d
C-; b d now runs cj/diff-buffer-with-file (the op I hit most, comparing a buffer against the saved file) and C-; b D runs cj/delete-buffer-and-file. The destructive command sat on the easy lowercase key and diff on the capital. A keymap-lookup test guards the swap.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-custom-buffer-file-keymap-bindings.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test-custom-buffer-file-keymap-bindings.el b/tests/test-custom-buffer-file-keymap-bindings.el
new file mode 100644
index 00000000..ea9ceb26
--- /dev/null
+++ b/tests/test-custom-buffer-file-keymap-bindings.el
@@ -0,0 +1,30 @@
+;;; test-custom-buffer-file-keymap-bindings.el --- d/D bindings in the buffer-and-file keymap -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; `cj/buffer-and-file-map' should put the destructive op on the capital key and
+;; the frequently-used op on the easy lowercase key: D = delete-buffer-and-file,
+;; d = diff-buffer-with-file. Guards the swap against silently reverting.
+
+;;; Code:
+
+(require 'ert)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+
+;; Stub dependencies before loading the module (mirrors the sibling tests).
+(defvar cj/custom-keymap (make-sparse-keymap)
+ "Stub keymap for testing.")
+(provide 'ps-print)
+
+(require 'custom-buffer-file)
+
+(ert-deftest test-custom-buffer-file-keymap-diff-on-lowercase-d ()
+ "Normal: lowercase d runs diff -- the frequently-used, non-destructive op."
+ (should (eq (keymap-lookup cj/buffer-and-file-map "d") #'cj/diff-buffer-with-file)))
+
+(ert-deftest test-custom-buffer-file-keymap-delete-on-capital-d ()
+ "Normal: capital D runs delete -- the destructive op on the capital key."
+ (should (eq (keymap-lookup cj/buffer-and-file-map "D") #'cj/delete-buffer-and-file)))
+
+(provide 'test-custom-buffer-file-keymap-bindings)
+;;; test-custom-buffer-file-keymap-bindings.el ends here