diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-23 21:16:27 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-23 21:16:27 -0400 |
| commit | e62ea922c07dc9a2d82d71f23e52a44034fd165d (patch) | |
| tree | 6b5e821302aa9f24e694ee370799b564b2b2c4bc /tests/test-ai-term--next-no-agents.el | |
| parent | 10fa6f4e2e7150ad99827721ada1ae4badcc5e90 (diff) | |
| download | dotemacs-e62ea922c07dc9a2d82d71f23e52a44034fd165d.tar.gz dotemacs-e62ea922c07dc9a2d82d71f23e52a44034fd165d.zip | |
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.
Diffstat (limited to 'tests/test-ai-term--next-no-agents.el')
| -rw-r--r-- | tests/test-ai-term--next-no-agents.el | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test-ai-term--next-no-agents.el b/tests/test-ai-term--next-no-agents.el new file mode 100644 index 00000000..ef87d71e --- /dev/null +++ b/tests/test-ai-term--next-no-agents.el @@ -0,0 +1,34 @@ +;;; test-ai-term--next-no-agents.el --- cj/ai-term-next no-agents fallback -*- lexical-binding: t; -*- + +;;; Commentary: +;; When no agent buffers are open, `cj/ai-term-next' (bound to M-SPC) launches +;; the project picker (`cj/ai-term-pick-project') to start the first agent, +;; instead of signalling a `user-error'. The swap key thus doubles as a +;; "start an agent" key when there is nothing to swap to. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'ai-term) + +(ert-deftest test-ai-term-next-no-agents-launches-picker () + "Error: no agents open -> launches the picker instead of erroring." + (let ((picked 0)) + (cl-letf (((symbol-function 'cj/--ai-term-agent-buffers) (lambda (&rest _) nil)) + ((symbol-function 'cj/--ai-term-displayed-agent-window) (lambda (&rest _) nil)) + ((symbol-function 'cj/ai-term-pick-project) (lambda (&rest _) (setq picked (1+ picked))))) + (cj/ai-term-next) + (should (= picked 1))))) + +(ert-deftest test-ai-term-next-no-agents-does-not-signal () + "Error: no agents open -> returns normally, no user-error raised." + (cl-letf (((symbol-function 'cj/--ai-term-agent-buffers) (lambda (&rest _) nil)) + ((symbol-function 'cj/--ai-term-displayed-agent-window) (lambda (&rest _) nil)) + ((symbol-function 'cj/ai-term-pick-project) (lambda (&rest _) nil))) + (should (progn (cj/ai-term-next) t)))) + +(provide 'test-ai-term--next-no-agents) +;;; test-ai-term--next-no-agents.el ends here |
