diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-05 05:43:43 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-05 05:43:43 -0500 |
| commit | 806dbd321ce0748309c974e98dba0ea146e9d0f4 (patch) | |
| tree | 0741fc5a5ca78128af8511e126b8001a10a04ec3 /tests/test-ai-term--f9-in-term.el | |
| parent | 25da8650f12a90e622aa804d604a02e39f1867ef (diff) | |
| download | dotemacs-806dbd321ce0748309c974e98dba0ea146e9d0f4.tar.gz dotemacs-806dbd321ce0748309c974e98dba0ea146e9d0f4.zip | |
fix(term): make F9 and F12 reach Emacs inside ghostel buffers
F9 did nothing in an agent buffer: ghostel's semi-char mode forwards every key not in ghostel-keymap-exceptions to the pty, and ghostel-semi-char-mode-map outranks the major-mode map, so the F9-family and F12 bindings I'd put in ghostel-mode-map never fired. The keys went to Claude/the shell, which ignored them.
I added the F9 family (in ai-term) and F12 plus C-; (in term-config) to ghostel-keymap-exceptions and rebuilt the semi-char map with ghostel--rebuild-semi-char-keymap. add-to-list updates the list but not the already-built map, so the rebuild is what actually lets the keys through. C-; had the same latent bug for the same reason.
Two regression tests assert the keys are in the exceptions and that the rebuilt semi-char map no longer forwards them. I also corrected the spec note that claimed binding in ghostel-mode-map was enough (true for vterm, wrong for ghostel) and codified the gotcha.
Diffstat (limited to 'tests/test-ai-term--f9-in-term.el')
| -rw-r--r-- | tests/test-ai-term--f9-in-term.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test-ai-term--f9-in-term.el b/tests/test-ai-term--f9-in-term.el index 53e1c4e7..dad11ffc 100644 --- a/tests/test-ai-term--f9-in-term.el +++ b/tests/test-ai-term--f9-in-term.el @@ -41,5 +41,16 @@ agent; `M-<f9>' and `C-S-<f9>' close an agent via `cj/ai-term-close'." (should (eq (lookup-key (current-global-map) (kbd "M-<f9>")) #'cj/ai-term-close)) (should (eq (lookup-key (current-global-map) (kbd "C-S-<f9>")) #'cj/ai-term-close))) +(ert-deftest test-ai-term-f9-family-in-keymap-exceptions () + "Regression: the F9 family is in `ghostel-keymap-exceptions' so semi-char +mode lets it reach Emacs instead of forwarding it to the terminal program. +Binding in `ghostel-mode-map' alone is not enough -- the semi-char map outranks +it and forwards any key not in the exceptions to the pty." + (dolist (key '("<f9>" "C-<f9>" "M-<f9>" "C-S-<f9>")) + (should (member key ghostel-keymap-exceptions))) + ;; The rebuilt semi-char map must no longer forward <f9> to the pty. + (should-not (eq (keymap-lookup ghostel-semi-char-mode-map "<f9>") + 'ghostel--send-event))) + (provide 'test-ai-term--f9-in-term) ;;; test-ai-term--f9-in-term.el ends here |
