From d11f3d5a18271ffd8e4b9822988ccc2fd2e0bcde Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 20 Jul 2026 15:56:56 -0500 Subject: fix(agenda): make C-x C-c close the agenda frame, not the daemon The catch-all denied it before, and letting the global through would be worse: save-buffers-kill-terminal on a make-frame frame has no client to close, so it kills the daemon. Inside the frame the gesture now runs the frame close. --- modules/org-agenda-frame.el | 5 +++++ tests/test-org-agenda-frame.el | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/modules/org-agenda-frame.el b/modules/org-agenda-frame.el index 8c3659f5..ef541c2f 100644 --- a/modules/org-agenda-frame.el +++ b/modules/org-agenda-frame.el @@ -237,6 +237,11 @@ The default binding for every key not on the allowlist." (define-key map (kbd "r") #'cj/--agenda-frame-safe-redo) (define-key map (kbd "S-") #'cj/agenda-frame-toggle) (define-key map (kbd "C-M-") #'cj/org-agenda-refresh-files) + ;; C-x C-c means "close this frame" here. The global + ;; `save-buffers-kill-terminal' must never run in this frame: it was made + ;; by `make-frame', not emacsclient, so with no client to close it falls + ;; back to killing the daemon itself. + (define-key map (kbd "C-x C-c") #'cj/--agenda-frame-close) ;; (d) Input machinery punched through the catch-all. An explicit nil ;; shadows the [t] default in this map, so these fall through to their ;; global bindings. Without the punches, every frame-focus change diff --git a/tests/test-org-agenda-frame.el b/tests/test-org-agenda-frame.el index 0b1062a1..19dab74b 100644 --- a/tests/test-org-agenda-frame.el +++ b/tests/test-org-agenda-frame.el @@ -232,6 +232,14 @@ catch-all denies them and the frame can't be closed by its own key." (should (eq (lookup-key cj/agenda-frame-mode-map (kbd "C-M-")) 'cj/org-agenda-refresh-files))) +(ert-deftest test-org-agenda-frame-map-C-x-C-c-closes-frame () + "Normal: C-x C-c in the agenda frame closes the frame, not the daemon. +The global save-buffers-kill-terminal would kill Emacs itself here (a +make-frame frame has no client), so the intuitive close gesture must be +remapped to the frame close." + (should (eq (lookup-key cj/agenda-frame-mode-map (kbd "C-x C-c")) + 'cj/--agenda-frame-close))) + (ert-deftest test-org-agenda-frame-map-machinery-punched-through () "Boundary: input machinery is punched through the [t] catch-all. switch-frame events, mouse-wheel scrolling, mouse-1 clicks, and the help -- cgit v1.2.3