aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/org-agenda-frame.el8
-rw-r--r--tests/test-org-agenda-frame.el10
2 files changed, 18 insertions, 0 deletions
diff --git a/modules/org-agenda-frame.el b/modules/org-agenda-frame.el
index 0d4f599e..1a19cc1b 100644
--- a/modules/org-agenda-frame.el
+++ b/modules/org-agenda-frame.el
@@ -276,6 +276,14 @@ The default binding for every key not on the allowlist."
[mouse-1] [down-mouse-1] [drag-mouse-1]
(kbd "C-h")))
(define-key map key nil))
+ ;; (e) Global chords that would pull focus out of the frame must be
+ ;; denied *explicitly*. The [t] catch-all can't reach them: a keymap's
+ ;; default binding does not shadow an *explicit* binding in a
+ ;; lower-priority map, and these are bound in the global map (M-SPC /
+ ;; M-S-SPC swap ai-term agents). Left to the catch-all, M-SPC follows
+ ;; its global binding and escapes the read-only frame into ai-term.
+ (dolist (key '("M-SPC" "M-S-SPC"))
+ (define-key map (kbd key) #'cj/--agenda-frame-denied-readonly))
;; View-changers get the distinct fixed-view message, not the read-only one.
(dolist (key '("w" "d" "y" "f" "b" "j"))
(define-key map (kbd key) #'cj/--agenda-frame-denied-fixed-view))
diff --git a/tests/test-org-agenda-frame.el b/tests/test-org-agenda-frame.el
index fc5b037b..fe4cee66 100644
--- a/tests/test-org-agenda-frame.el
+++ b/tests/test-org-agenda-frame.el
@@ -304,6 +304,16 @@ scroll spams the deny message."
;; global map); an unpunched key returns the catch-all deny handler.
(should (null (lookup-key cj/agenda-frame-mode-map key t)))))
+(ert-deftest test-org-agenda-frame-map-global-escape-chords-denied ()
+ "Boundary: global chords bound elsewhere (M-SPC / M-S-SPC swap ai-term
+agents) are denied by an explicit binding, not left to the [t] catch-all.
+A keymap's default binding does not shadow an explicit binding in a
+lower-priority map, so without an explicit deny here M-SPC follows its
+global binding and escapes the read-only frame into ai-term."
+ (dolist (key '("M-SPC" "M-S-SPC"))
+ (should (eq (lookup-key cj/agenda-frame-mode-map (kbd key))
+ 'cj/--agenda-frame-denied-readonly))))
+
(ert-deftest test-org-agenda-frame-map-unpunched-still-denied ()
"Normal: an ordinary unbound key still hits the catch-all after the punches."
(should (eq (lookup-key cj/agenda-frame-mode-map (kbd "t") t)