aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/ai-vterm.el6
-rw-r--r--tests/test-ai-vterm--f9-in-vterm.el13
2 files changed, 19 insertions, 0 deletions
diff --git a/modules/ai-vterm.el b/modules/ai-vterm.el
index 108a73ca..18320eee 100644
--- a/modules/ai-vterm.el
+++ b/modules/ai-vterm.el
@@ -53,6 +53,12 @@
(declare-function vterm-send-return "vterm" ())
(defvar vterm-mode-map)
+;; `cj/toggle-gptel' lives in ai-config.el. Declaring it as an interactive
+;; autoload (rather than `require'ing ai-config here) silences the byte-compile
+;; warning at line 685/696 while keeping ai-vterm.el free of a load-time
+;; dependency on the full ai-config stack.
+(autoload 'cj/toggle-gptel "ai-config" nil t)
+
(defgroup ai-vterm nil
"In-Emacs AI-agent launcher with vertical-split vterm."
:group 'tools)
diff --git a/tests/test-ai-vterm--f9-in-vterm.el b/tests/test-ai-vterm--f9-in-vterm.el
index ff8939c8..1901127e 100644
--- a/tests/test-ai-vterm--f9-in-vterm.el
+++ b/tests/test-ai-vterm--f9-in-vterm.el
@@ -43,5 +43,18 @@ the retired `cj/ai-vterm-pick-buffer')."
(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/toggle-gptel)))
+(ert-deftest test-ai-vterm-toggle-gptel-autoloaded-without-ai-config ()
+ "Regression: loading `ai-vterm.el' must not require `ai-config.el'.
+The M-F9 binding targets `cj/toggle-gptel', which lives in
+`ai-config.el'. The dependency is declared via `autoload' so that
+byte-compiling `ai-vterm.el' does not warn and so that requiring
+`ai-vterm' in isolation leaves `cj/toggle-gptel' fboundp as an
+autoload sigil pointing at `ai-config'. Without this, ai-vterm
+would either need a full `(require 'ai-config)' at load time or
+ship a known byte-compile warning."
+ (should-not (featurep 'ai-config))
+ (should (fboundp 'cj/toggle-gptel))
+ (should (autoloadp (symbol-function 'cj/toggle-gptel))))
+
(provide 'test-ai-vterm--f9-in-vterm)
;;; test-ai-vterm--f9-in-vterm.el ends here