From 1dbf5a4a2d2ce4277dc97a3e9783240324ad5f53 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 14 May 2026 19:05:43 -0500 Subject: refactor(org-config): surface narrowing + sparse-tree under C-; O Narrowing and sparse-tree commands existed in the `:bind' block on `C-c'-style shortcuts but nothing in `cj/org-map' surfaced them, so which-key never showed them and discoverability was poor. Add direct bindings under `C-; O', flat (no sub-prefixes for narrow / sparse-tree). Lowercase creates; capital of the same letter cancels: - `n' / `N' narrow-to-subtree / widen - `s' / `S' match-sparse-tree / show-all - `t' / `T' show-todo-tree / show-all - `>' / `<' forward / backward sibling narrow (kept as-is) - `R' reveal-context (no lowercase pair -- `r' is the table-row sub-prefix) Both `S' and `T' resolve to the same `org-show-all' command so the mental model is just "capital cancels the lowercase I just ran" without having to recall which letter the cancel actually lives on. Free up F2: the old `( . org-reveal)' binding in the org-mode `:bind' block is now redundant with `C-; O R'. Drop it; F2 becomes available for whatever wants it next. Four new ERT assertions in `test-org-config-keymap-ownership.el' lock the shape -- the old sparse-tree-submap test was rewritten for the flat layout and the narrow-submap test became narrow-bindings (also flat). --- tests/test-org-config-keymap-ownership.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/test-org-config-keymap-ownership.el b/tests/test-org-config-keymap-ownership.el index 7f08a172..729d497c 100644 --- a/tests/test-org-config-keymap-ownership.el +++ b/tests/test-org-config-keymap-ownership.el @@ -45,6 +45,31 @@ command (which moved to capital `C')." (should (eq (keymap-lookup cj/org-map "c i") #'org-table-insert-column)) (should (eq (keymap-lookup cj/org-map "c d") #'org-table-delete-column))) +(ert-deftest test-org-config-keymap-ownership-narrow-bindings () + "Narrow / widen sit directly under `C-; O' (flat, no sub-prefix). +Lowercase `n' narrows to the current subtree; capital `N' widens, +matching the lowercase-creates / uppercase-cancels pattern shared +with the sparse-tree sub-prefix. Sibling-stepping is on `>' / `<' +at the top level." + (should (eq (keymap-lookup cj/org-map "n") #'org-narrow-to-subtree)) + (should (eq (keymap-lookup cj/org-map "N") #'widen)) + (should (eq (keymap-lookup cj/org-map ">") #'cj/org-narrow-forward)) + (should (eq (keymap-lookup cj/org-map "<") #'cj/org-narrow-backwards))) + +(ert-deftest test-org-config-keymap-ownership-sparse-tree-bindings () + "Sparse-tree commands sit directly under `C-; O' (flat). +Lowercase creates, capital of the same letter cancels: `s' / +`S' for match-sparse-tree, `t' / `T' for show-todo-tree. Both +capitals resolve to `org-show-all' -- the user's mental model is +\"capital cancels the lowercase I just ran\" without having to +remember which letter the cancel actually lives on. `R' is +`org-reveal' (no lowercase pair -- `r' is the table-row sub-prefix)." + (should (eq (keymap-lookup cj/org-map "s") #'org-match-sparse-tree)) + (should (eq (keymap-lookup cj/org-map "S") #'org-show-all)) + (should (eq (keymap-lookup cj/org-map "t") #'org-show-todo-tree)) + (should (eq (keymap-lookup cj/org-map "T") #'org-show-all)) + (should (eq (keymap-lookup cj/org-map "R") #'org-reveal))) + (ert-deftest test-org-config-keymap-ownership-regression-no-duplicate-org-keymap () "The old duplicate `cj/org-keymap' binding should not exist." (should-not (boundp 'cj/org-keymap))) -- cgit v1.2.3