From 3b4c8d8915d469b0bfbb148820bca7a31dcd734a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 15 May 2026 23:48:20 -0500 Subject: fix(ai-config): Ensure gptel-magit is installed via use-package Replace raw autoload calls with a `use-package` declaration so `use-package-always-ensure` installs gptel-magit on machines that haven't run `package-install`, fixing the "Cannot open load file" error on transient setup. --- modules/ai-config.el | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'modules') diff --git a/modules/ai-config.el b/modules/ai-config.el index 92992aa7..4a3d6a82 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -426,27 +426,27 @@ Works for any buffer, whether it's visiting a file or not." ;;; -------------------------------- GPTel-Magit -------------------------------- -;; Lazy gptel-magit integration (replaces use-package gptel-magit block). +;; `:init' wires the bindings as soon as magit loads, so M-g and the transient +;; suffixes are ready before any keystroke. `:commands' + `:defer t' delays +;; loading gptel-magit itself until one of the entry points is invoked. ;; -;; The original `(magit-mode . gptel-magit-install)' hook ran on every magit -;; buffer, repeatedly re-installing keybindings and loading gptel eagerly. -;; -;; Instead, we register autoloads and wire up keybindings once when magit -;; loads. gptel-magit (and gptel) are only loaded when you actually press -;; one of these keys: +;; Keys: ;; M-g — generate commit message (in commit message buffer) ;; g — generate commit (in magit-commit transient) ;; x — explain diff (in magit-diff transient) -(with-eval-after-load 'magit - (autoload 'gptel-magit-generate-message "gptel-magit" nil t) - (autoload 'gptel-magit-commit-generate "gptel-magit" nil t) - (autoload 'gptel-magit-diff-explain "gptel-magit" nil t) - (define-key git-commit-mode-map (kbd "M-g") #'gptel-magit-generate-message) - (transient-append-suffix 'magit-commit #'magit-commit-create - '("g" "Generate commit" gptel-magit-commit-generate)) - (transient-append-suffix 'magit-diff #'magit-stash-show - '("x" "Explain" gptel-magit-diff-explain))) +(use-package gptel-magit + :defer t + :commands (gptel-magit-generate-message + gptel-magit-commit-generate + gptel-magit-diff-explain) + :init + (with-eval-after-load 'magit + (define-key git-commit-mode-map (kbd "M-g") #'gptel-magit-generate-message) + (transient-append-suffix 'magit-commit #'magit-commit-create + '("g" "Generate commit" gptel-magit-commit-generate)) + (transient-append-suffix 'magit-diff #'magit-stash-show + '("x" "Explain" gptel-magit-diff-explain)))) ;; ------------------------------ GPTel Directives ----------------------------- -- cgit v1.2.3