summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-15 23:48:20 -0500
committerCraig Jennings <c@cjennings.net>2026-05-15 23:48:20 -0500
commit3b4c8d8915d469b0bfbb148820bca7a31dcd734a (patch)
treeba2c480fb29d3308d59457235b49b3b0add62af3 /modules
parent2dd56761df8e6b6d7b5f99c5c7c6d20f5b2d6447 (diff)
downloaddotemacs-3b4c8d8915d469b0bfbb148820bca7a31dcd734a.tar.gz
dotemacs-3b4c8d8915d469b0bfbb148820bca7a31dcd734a.zip
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.
Diffstat (limited to 'modules')
-rw-r--r--modules/ai-config.el32
1 files changed, 16 insertions, 16 deletions
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 -----------------------------