diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-13 12:12:32 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-13 12:12:32 -0500 |
| commit | eb793eca294fdef76898fb491d179340c5c51ef5 (patch) | |
| tree | 9dd87fb1f4e9b712f10451543e19e0ab9e3bf71d | |
| parent | d5406e3c2179d879590007311da0aff7ed4706af (diff) | |
| download | dotemacs-eb793eca294fdef76898fb491d179340c5c51ef5.tar.gz dotemacs-eb793eca294fdef76898fb491d179340c5c51ef5.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.
| -rw-r--r-- | modules/custom-buffer-file.el | 4 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-keymap-bindings.el | 30 |
2 files changed, 32 insertions, 2 deletions
diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el index 25b4a418e..84faf01d8 100644 --- a/modules/custom-buffer-file.el +++ b/modules/custom-buffer-file.el @@ -512,8 +512,8 @@ Signals an error if: "m" #'cj/move-buffer-and-file "r" #'cj/rename-buffer-and-file "p" #'cj/copy-buffer-source-as-kill - "d" #'cj/delete-buffer-and-file - "D" #'cj/diff-buffer-with-file + "d" #'cj/diff-buffer-with-file + "D" #'cj/delete-buffer-and-file "c" cj/copy-buffer-content-map "n" #'cj/copy-buffer-name "l" #'cj/copy-link-to-buffer-file 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 000000000..ea9ceb263 --- /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 |
