From be772bc00530adab0d4bb2cedb0eb8fa3aec411c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 23 Jun 2026 21:16:27 -0400 Subject: feat(ai-term): move keybindings to C-; a and M-SPC, retire F9 I moved the ai-term family off the F9 keys onto the C-; a prefix, vacated when gptel was archived: a toggles the agent, s opens the project picker, n swaps to the next agent, k closes one. The frequent swap also gets M-SPC as a fast chord, bound in ghostel-mode-map and added to the semi-char exceptions so it reaches Emacs from inside an agent buffer. cj/ai-term-next now opens the project picker when no agent is running instead of erroring, so the swap key doubles as a "start an agent" key. To free M-SPC, I removed jumper's M-SPC binding. Jumper's commands stay reachable via M-x, with a cleverer home pending review. --- tests/test-ai-term--f9-in-term.el | 58 --------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 tests/test-ai-term--f9-in-term.el (limited to 'tests/test-ai-term--f9-in-term.el') diff --git a/tests/test-ai-term--f9-in-term.el b/tests/test-ai-term--f9-in-term.el deleted file mode 100644 index 0477f2517..000000000 --- a/tests/test-ai-term--f9-in-term.el +++ /dev/null @@ -1,58 +0,0 @@ -;;; test-ai-term--f9-in-term.el --- F9 reaches Emacs from inside an agent buffer -*- lexical-binding: t; -*- - -;;; Commentary: -;; ghostel's semi-char mode forwards keys not in `ghostel-keymap-exceptions' to -;; the terminal program, so a plain typed while point is in an agent -;; buffer would be sent to the program instead of toggling the agent -- exactly -;; the case when the agent buffer fills the frame. `ai-term.el' re-binds the F9 -;; family in `ghostel-mode-map'. These tests require ghostel (which defines -;; `ghostel-mode-map' and lets ai-term's `with-eval-after-load' fire) BEFORE -;; ai-term, then confirm the bindings landed (and the global ones are intact). -;; `(require 'ghostel)' does not load the native module, so this stays light. - -;;; Code: - -(require 'ert) -(require 'package) - -(setq package-user-dir (expand-file-name "elpa" user-emacs-directory)) -(package-initialize) -(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) -(require 'ghostel) -(require 'ai-term) - -(ert-deftest test-ai-term-f9-bound-in-ghostel-mode-map () - "Normal: in `ghostel-mode-map' runs the agent toggle." - (should (eq (keymap-lookup ghostel-mode-map "") #'cj/ai-term))) - -(ert-deftest test-ai-term-f9-family-bound-in-ghostel-mode-map () - "Normal: the C-/s-/M- F9 variants are bound in `ghostel-mode-map' too. -`s-' steps to the next agent; `M-' closes an agent via -`cj/ai-term-close'." - (should (eq (keymap-lookup ghostel-mode-map "C-") #'cj/ai-term-pick-project)) - (should (eq (keymap-lookup ghostel-mode-map "s-") #'cj/ai-term-next)) - (should (eq (keymap-lookup ghostel-mode-map "M-") #'cj/ai-term-close))) - -(ert-deftest test-ai-term-f9-still-bound-globally () - "Normal: the global F9 family bindings are intact. -`' toggles the ai-term agent window; `C-' picks a project -agent; `s-' steps to the next agent; `M-' closes an agent -via `cj/ai-term-close'." - (should (eq (lookup-key (current-global-map) (kbd "")) #'cj/ai-term)) - (should (eq (lookup-key (current-global-map) (kbd "C-")) #'cj/ai-term-pick-project)) - (should (eq (lookup-key (current-global-map) (kbd "s-")) #'cj/ai-term-next)) - (should (eq (lookup-key (current-global-map) (kbd "M-")) #'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 '("" "C-" "s-" "M-")) - (should (member key ghostel-keymap-exceptions))) - ;; The rebuilt semi-char map must no longer forward to the pty. - (should-not (eq (keymap-lookup ghostel-semi-char-mode-map "") - 'ghostel--send-event))) - -(provide 'test-ai-term--f9-in-term) -;;; test-ai-term--f9-in-term.el ends here -- cgit v1.2.3