From 32017dc068d7579e789c5e753ae35f6f10c3d5b3 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 21 Jul 2026 23:12:02 -0500 Subject: fix: make the Full Agenda frame's default-deny actually deny The frame's read-only policy leaned on a [t] catch-all, but a keymap's default binding never shadows an explicit binding in a lower-priority map. So every key org-agenda-mode-map binds sailed through the catch-all and could mutate source files from the "read-only" frame: t (todo), I (clock-in), k (capture), z (add-note), s (save-all), the C-c schedule/deadline/clock mutators, C-x C-s. Walk org-agenda-mode-map recursively on load and explicitly deny every sequence not on the frame's allowlist, so the catch-all's intent holds. Navigation, engage, refresh, d/w, and C-c C-o still work, and M-x is unaffected. --- tests/test-org-agenda-frame.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests') diff --git a/tests/test-org-agenda-frame.el b/tests/test-org-agenda-frame.el index 92dd5ddc..fd8bd839 100644 --- a/tests/test-org-agenda-frame.el +++ b/tests/test-org-agenda-frame.el @@ -315,6 +315,34 @@ d shrinks the frame to the current day, w restores the seven-day span." (should (eq (lookup-key cj/agenda-frame-mode-map (kbd "w")) 'cj/--agenda-frame-week-view))) +(ert-deftest test-org-agenda-frame-shadow-denies-org-mutations-preserves-allowlist () + "Boundary: with the frame mode active over `org-agenda-mode-map', mutating +org-agenda keys are denied and the allowlist still works. +The `[t]' default cannot shadow org-agenda-mode-map's explicit bindings, so +the shadow walk must add explicit denies for every non-allowlisted key -- +single keys (t/I/k/z/s/.), the C-c mutators (schedule/deadline/clock), and +C-x (save-all) -- while leaving the allowlist (navigation, engage, refresh, +d/w, C-c C-o) intact." + (require 'org-agenda) + (cj/--agenda-frame-shadow-mutations) + (with-temp-buffer + (use-local-map org-agenda-mode-map) + (cj/agenda-frame-mode 1) + ;; escaping mutators are now explicitly denied (not org's commands) + (dolist (chord '("t" "I" "k" "z" "s" "." "C-c C-s" "C-c C-d" + "C-c C-x C-i" "C-x C-s")) + (should (eq (key-binding (kbd chord)) + 'cj/--agenda-frame-denied-readonly))) + ;; the allowlist survives the walk + (should (eq (key-binding (kbd "n")) 'org-agenda-next-line)) + (should (eq (key-binding (kbd "p")) 'org-agenda-previous-line)) + (should (eq (key-binding (kbd "RET")) 'cj/--agenda-frame-engage-open)) + (should (eq (key-binding (kbd "g")) 'cj/--agenda-frame-safe-redo)) + (should (eq (key-binding (kbd "d")) 'cj/--agenda-frame-day-view)) + (should (eq (key-binding (kbd "w")) 'cj/--agenda-frame-week-view)) + (should (eq (key-binding (kbd "C-c C-o")) 'cj/--agenda-frame-open-link)) + (should (eq (key-binding (kbd "q")) 'cj/--agenda-frame-close)))) + (ert-deftest test-org-agenda-frame-map-frame-controls-bound () "Normal: the frame's own controls work from inside the frame. S- must close/toggle and C-M- must force-rescan; unbound, the -- cgit v1.2.3