From fa1e63e4b3e4dbe3841247c8efd2096d2d75390c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 3 Aug 2026 09:59:58 -0500 Subject: feat(recording): put the video and audio toggles on F9 and Shift-F9 The two toggles were only on C-; r v and C-; r a. F9 has been free since ai-term moved its family to M-SPC, so it goes to what I reach for mid-work. Both keep their prefix argument, so C-u F9 still prompts for a location. Reaching them from inside a terminal buffer turns on which key categories each EAT input mode claims. My first read of that was backwards. Semi-char mode is the default and where agent buffers sit. It's built from :ascii, :arrow and :navigation, so it never claims function keys and F9 already reached Emacs there. That entry is redundant. Char mode is the one that mattered. It adds :function, binding f1 through f63 to eat-self-input. It's also a minor mode, so its map outranks eat-mode-map. Worse, :function claims only the unmodified keys. Leaving char mode alone would have split the pair rather than broken it: Shift-F9 toggling audio while F9 went to the program under the cursor. That is a recording I believe I started and didn't. Both chords are claimed in eat-char-mode-map and eat-eshell-char-mode-map, which costs a char-mode program the use of F9. I'd rather pay that than ship a toggle that half works. The tests resolve the char-mode cases through key-binding in a fixture that reproduces minor-mode precedence, not by reading the binding back out of the map the module just wrote. A positive control asserts F8 still reaches eat-self-input, since F8 sits in the same category and nothing here touches it. Without that control the fixture could be inert and every assertion would still pass, because F9 resolves through the global map either way. --- modules/video-audio-recording.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'modules/video-audio-recording.el') diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el index 10c10854..65a8612f 100644 --- a/modules/video-audio-recording.el +++ b/modules/video-audio-recording.el @@ -300,6 +300,41 @@ Changes take effect on the next recording (not the current one)." (cj/register-prefix-map "r" cj/record-map) +;; Fast chords for the two toggles, alongside C-; r v and C-; r a. F9 is free: +;; ai-term vacated the F9 family when its swap moved to M-SPC, and +;; `test-ai-term-f9-family-removed-globally' keeps it vacated. Both commands +;; still take a prefix argument, so C-u F9 prompts for the recording location. +(keymap-global-set "" #'cj/video-recording-toggle) +(keymap-global-set "S-" #'cj/audio-recording-toggle) + +(defvar eat-mode-map) +(defvar eat-semi-char-mode-map) +(defvar eat-char-mode-map) +(defvar eat-eshell-char-mode-map) + +;; EAT builds each input mode's keymap from key categories, and which categories +;; a mode claims is what decides whether a chord reaches Emacs at all. +;; +;; Semi-char mode -- the default, and where every agent buffer sits -- is built +;; from :ascii, :arrow and :navigation. It never claims function keys, so F9 +;; already fell through to the global map. The semi-char entry below is +;; belt-and-braces rather than the fix, which is why it reads as redundant. +;; +;; Char mode is the one that swallows F9. It adds :function, binding f1 through +;; f63 to eat-self-input, and it is a minor mode, so its map outranks +;; eat-mode-map. Without an entry here the pair splits in the worst possible +;; way: :function claims only the unmodified keys, so S-F9 would toggle audio in +;; a char-mode buffer while F9 went to the program under the cursor. That is a +;; recording you believe you started and didn't. +;; +;; Claiming both costs a char-mode program the use of F9. I would rather pay +;; that than ship a toggle that works for audio and silently fails for video. +(with-eval-after-load 'eat + (dolist (map (list eat-semi-char-mode-map eat-mode-map + eat-char-mode-map eat-eshell-char-mode-map)) + (keymap-set map "" #'cj/video-recording-toggle) + (keymap-set map "S-" #'cj/audio-recording-toggle))) + (with-eval-after-load 'which-key (which-key-add-key-based-replacements "C-; r" "recording menu" -- cgit v1.2.3