aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-14 23:59:34 -0500
committerCraig Jennings <c@cjennings.net>2026-05-14 23:59:34 -0500
commit6551b17f4735e0ca375319f07f249abefafde892 (patch)
tree1cddf6c8f5be54cdb73c01857cefa8fcff17083b /tests
parentc055f9e4befdbd3ffb9429e6a02c45bfdfdae6a5 (diff)
downloaddotemacs-6551b17f4735e0ca375319f07f249abefafde892.tar.gz
dotemacs-6551b17f4735e0ca375319f07f249abefafde892.zip
refactor(ai-vterm): retire M-F9 buffer picker; bind to cj/toggle-gptel
M-F9 used to invoke `cj/ai-vterm-pick-buffer' (a buffer picker narrowed to alive AI-agent buffers). In practice the F9 plain-key toggle + C-F9 project picker covered the common cases, and the buffer picker rarely earned its keystroke. Rebind M-F9 to `cj/toggle-gptel' so the F9 family covers the two main in-Emacs AI surfaces at one keystroke each: <f9> ai-vterm toggle (unchanged) C-<f9> ai-vterm picker (unchanged) M-<f9> gptel *AI-Assistant* (NEW) Removed entirely: - `cj/ai-vterm-pick-buffer' (the command itself). - `cj/--ai-vterm-pick-buffer-candidates' (its helper). - `tests/test-ai-vterm--pick-buffer-candidates.el' (deleted). Updated: - `tests/test-ai-vterm--f9-in-vterm.el' binding assertions (vterm-mode-map and global) flipped to `cj/toggle-gptel'. - Module commentary + `cj/ai-vterm' docstring describe the new M-F9 behavior. - `cj/toggle-gptel' lives in `modules/ai-config.el'; the binding stays in `ai-vterm.el' next to the rest of the F9 family so the dispatch shape is visible in one place.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-ai-vterm--f9-in-vterm.el13
-rw-r--r--tests/test-ai-vterm--pick-buffer-candidates.el80
2 files changed, 9 insertions, 84 deletions
diff --git a/tests/test-ai-vterm--f9-in-vterm.el b/tests/test-ai-vterm--f9-in-vterm.el
index 1355bd6a..ff8939c8 100644
--- a/tests/test-ai-vterm--f9-in-vterm.el
+++ b/tests/test-ai-vterm--f9-in-vterm.el
@@ -24,19 +24,24 @@
(should (eq (keymap-lookup vterm-mode-map "<f9>") #'cj/ai-vterm)))
(ert-deftest test-ai-vterm-f9-family-bound-in-vterm-mode-map ()
- "Normal: the C-/M- F9 variants are bound in `vterm-mode-map' too."
+ "Normal: the C-/M- F9 variants are bound in `vterm-mode-map' too.
+`M-<f9>' toggles gptel's *AI-Assistant* window (rebound here from
+the old `cj/ai-vterm-pick-buffer' command, which was removed)."
(should (eq (keymap-lookup vterm-mode-map "C-<f9>") #'cj/ai-vterm-pick-project))
- (should (eq (keymap-lookup vterm-mode-map "M-<f9>") #'cj/ai-vterm-pick-buffer)))
+ (should (eq (keymap-lookup vterm-mode-map "M-<f9>") #'cj/toggle-gptel)))
(ert-deftest test-ai-vterm-f9-not-self-insert-in-vterm ()
"Boundary: vterm's default <f9> -> `vterm--self-insert' was overridden."
(should-not (eq (keymap-lookup vterm-mode-map "<f9>") 'vterm--self-insert)))
(ert-deftest test-ai-vterm-f9-still-bound-globally ()
- "Normal: the global F9 family bindings are intact."
+ "Normal: the global F9 family bindings are intact.
+`<f9>' toggles the ai-vterm agent window; `C-<f9>' picks a project
+agent; `M-<f9>' toggles gptel's *AI-Assistant* window (rebound from
+the retired `cj/ai-vterm-pick-buffer')."
(should (eq (lookup-key (current-global-map) (kbd "<f9>")) #'cj/ai-vterm))
(should (eq (lookup-key (current-global-map) (kbd "C-<f9>")) #'cj/ai-vterm-pick-project))
- (should (eq (lookup-key (current-global-map) (kbd "M-<f9>")) #'cj/ai-vterm-pick-buffer)))
+ (should (eq (lookup-key (current-global-map) (kbd "M-<f9>")) #'cj/toggle-gptel)))
(provide 'test-ai-vterm--f9-in-vterm)
;;; test-ai-vterm--f9-in-vterm.el ends here
diff --git a/tests/test-ai-vterm--pick-buffer-candidates.el b/tests/test-ai-vterm--pick-buffer-candidates.el
deleted file mode 100644
index c32039de..00000000
--- a/tests/test-ai-vterm--pick-buffer-candidates.el
+++ /dev/null
@@ -1,80 +0,0 @@
-;;; test-ai-vterm--pick-buffer-candidates.el --- Tests for the M-F9 candidate builder -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; The candidate builder is a pure function: given an MRU list of
-;; alive AI-vterm buffers and the currently-displayed buffer (or
-;; nil), it returns an alist of (DISPLAY-NAME . BUFFER) cells.
-;;
-;; Sort rule: non-shown buffers come first in their input order,
-;; then the shown buffer (if it's in the list) appears last with a
-;; \" [shown]\" suffix. The intent is that the default `completing-
-;; read' selection lands on a non-shown candidate so RET means
-;; \"give me the other one\".
-
-;;; Code:
-
-(require 'ert)
-
-(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
-(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory))
-(require 'ai-vterm)
-(require 'testutil-vterm-buffers)
-
-(ert-deftest test-ai-vterm--pick-buffer-candidates-empty-buffers ()
- "Boundary: empty buffer list -> empty alist regardless of shown."
- (cj/test--kill-agent-buffers)
- (should (null (cj/--ai-vterm-pick-buffer-candidates nil nil)))
- (should (null (cj/--ai-vterm-pick-buffer-candidates nil 'sentinel))))
-
-(ert-deftest test-ai-vterm--pick-buffer-candidates-shown-nil ()
- "Normal: shown is nil -> straight alist in input order, no marker."
- (cj/test--kill-agent-buffers)
- (let ((b1 (get-buffer-create "agent [a]"))
- (b2 (get-buffer-create "agent [b]")))
- (unwind-protect
- (let ((result (cj/--ai-vterm-pick-buffer-candidates (list b1 b2) nil)))
- (should (equal result `(("agent [a]" . ,b1)
- ("agent [b]" . ,b2)))))
- (kill-buffer b1)
- (kill-buffer b2))))
-
-(ert-deftest test-ai-vterm--pick-buffer-candidates-shown-promotes-non-shown ()
- "Normal: shown buffer sorts last with [shown] suffix; others first."
- (cj/test--kill-agent-buffers)
- (let ((b1 (get-buffer-create "agent [a]"))
- (b2 (get-buffer-create "agent [b]"))
- (b3 (get-buffer-create "agent [c]")))
- (unwind-protect
- (let ((result (cj/--ai-vterm-pick-buffer-candidates
- (list b1 b2 b3) b1)))
- (should (equal result
- `(("agent [b]" . ,b2)
- ("agent [c]" . ,b3)
- ("agent [a] [shown]" . ,b1)))))
- (kill-buffer b1)
- (kill-buffer b2)
- (kill-buffer b3))))
-
-(ert-deftest test-ai-vterm--pick-buffer-candidates-shown-only-buffer ()
- "Boundary: shown is the only entry -> single cell with [shown] marker."
- (cj/test--kill-agent-buffers)
- (let ((b1 (get-buffer-create "agent [a]")))
- (unwind-protect
- (let ((result (cj/--ai-vterm-pick-buffer-candidates (list b1) b1)))
- (should (equal result `(("agent [a] [shown]" . ,b1)))))
- (kill-buffer b1))))
-
-(ert-deftest test-ai-vterm--pick-buffer-candidates-shown-not-in-buffers ()
- "Boundary: stale shown buffer not in list -> all cells are non-shown."
- (cj/test--kill-agent-buffers)
- (let ((b1 (get-buffer-create "agent [a]"))
- (b-stale (get-buffer-create "agent [stale]")))
- (unwind-protect
- (let ((result (cj/--ai-vterm-pick-buffer-candidates
- (list b1) b-stale)))
- (should (equal result `(("agent [a]" . ,b1)))))
- (kill-buffer b1)
- (kill-buffer b-stale))))
-
-(provide 'test-ai-vterm--pick-buffer-candidates)
-;;; test-ai-vterm--pick-buffer-candidates.el ends here