From c551230df1cb644d1d97c34a7fbdf9e3d8ca8c78 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 15 May 2026 02:21:57 -0500 Subject: fix(ai-vterm): autoload cj/toggle-gptel to silence cross-module warning make compile warned that cj/toggle-gptel is not known to be defined when ai-vterm.el is byte-compiled. The M-F9 binding still worked during normal startup because init.el loads ai-config.el after ai-vterm.el, but the dependency was implicit -- byte-compile saw the function symbol unresolved, and loading ai-vterm.el in isolation left M-F9 bound to an undefined function. Declare cj/toggle-gptel as an interactive autoload pointing at ai-config. This silences the warning, keeps ai-vterm.el free of a load-time (require 'ai-config), and makes the load-order contract explicit: the binding works as long as ai-config eventually loads. Test asserts that requiring ai-vterm in isolation leaves cj/toggle-gptel fboundp as an autoload sigil (not a real function). A regression that adds (require 'ai-config) at the top of ai-vterm.el would flip this, and a regression that drops the autoload form would leave fboundp nil. --- tests/test-ai-vterm--f9-in-vterm.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') 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-")) #'cj/ai-vterm-pick-project)) (should (eq (lookup-key (current-global-map) (kbd "M-")) #'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 -- cgit v1.2.3