aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--modules/custom-buffer-file.el4
-rw-r--r--tests/test-custom-buffer-file-keymap-bindings.el30
-rw-r--r--todo.org10
3 files changed, 41 insertions, 3 deletions
diff --git a/modules/custom-buffer-file.el b/modules/custom-buffer-file.el
index 25b4a418..84faf01d 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 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
diff --git a/todo.org b/todo.org
index 20375335..7f105403 100644
--- a/todo.org
+++ b/todo.org
@@ -56,8 +56,10 @@ When a terminal fills the frame, =C-; b= then a right or down arrow should shrin
** TODO [#C] Dirvish: free D for hard-delete, move duplicate :feature:quick:
In dirvish, keep =d= = delete (=dired-do-delete=), move duplicate (=cj/dirvish-duplicate-file=, currently =D=) to another key, and bind =D= = =sudo rm -rf= for a forced hard delete — capital for the more destructive op. Craig's note says "duplicate on 2"; confirm that's the intended key, and guard the sudo path carefully before wiring. From the roam inbox.
-** TODO [#C] Swap buffer delete/diff keys — destructive on capital :refactor:quick:solo:
+** DONE [#C] Swap buffer delete/diff keys — destructive on capital :refactor:quick:solo:
+CLOSED: [2026-06-13 Sat]
=modules/custom-buffer-file.el:515= binds =d= = =cj/delete-buffer-and-file= and =D= = =cj/diff-buffer-with-file=. Destructive commands should be the capital, and diff is the one hit often (when saving a buffer changed on disk). Swap them: =D= = delete, =d= = diff. From the roam inbox.
+Swapped 2026-06-13: =cj/buffer-and-file-map= now binds =d= = =cj/diff-buffer-with-file=, =D= = =cj/delete-buffer-and-file=. keymap-lookup test added; live daemon re-bound by hand (defvar-keymap won't reassign a bound var on reload). Keypress check is a VERIFY under Manual testing and validation.
** TODO [#B] ai-term adaptive side/bottom window placement :feature:quick:solo:
:PROPERTIES:
@@ -4336,6 +4338,12 @@ From the 2026-06-11 messenger-unification brainstorm. Google Voice has no offici
** TODO Manual testing and validation
Exercised once the phases above land.
+*** VERIFY C-; b d diffs, C-; b D deletes
+What we're verifying: the buffer-and-file keymap now puts diff on the easy lowercase key and the destructive delete on the capital. Swapped in modules/custom-buffer-file.el and re-bound live in the daemon.
+- Open a file buffer and edit it without saving
+- Press C-; b d
+- Press C-; b D, then cancel at the delete confirmation
+Expected: C-; b d runs the diff (buffer vs saved file); C-; b D starts delete-buffer-and-file (offers to delete the file). Before the swap these were reversed.
*** TODO C-s C-s repeats the last search
What we're verifying: the second consecutive C-s repeats the previous consult-line search instead of erroring "No Vertico session". Fix in modules/selection-framework.el (vertico-repeat-save now on minibuffer-setup-hook), live in the daemon.
- Press C-s, type a search term, RET to dismiss (or just narrow then exit)