diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-18 02:24:30 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-18 02:24:30 -0400 |
| commit | b3d41f9a0c63b13ad497a48677de933a3fb5a5cf (patch) | |
| tree | 7ae88ce89ace3a3ada41f3673703f740b51c0093 /modules | |
| parent | 3aa577665329200c90c17db2c949acb45514c29b (diff) | |
| download | dotemacs-b3d41f9a0c63b13ad497a48677de933a3fb5a5cf.tar.gz dotemacs-b3d41f9a0c63b13ad497a48677de933a3fb5a5cf.zip | |
refactor(ai-config): switch gptel to local fork, drop tab-width advice
I switched the gptel use-package form to `:load-path "~/code/gptel"`
with `:ensure nil` so Emacs loads from the fork instead of the MELPA
release. The fork now carries the narrow `tab-width' copy in
`gptel-org--create-prompt' that karthink redirected the upstream PR
to, which replaces the local `:around' advice on
`gptel--with-buffer-copy-internal' I'd been carrying.
I also dropped the stale test file
`tests/test-ai-config-gptel-prompt-tab-width.el' and the matching
stub in `tests/testutil-ai-config.el'. Both existed only to test the
advice I removed.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ai-config.el | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el index 050efbd4..ddbe91b8 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -361,6 +361,8 @@ Works for any buffer, whether it's visiting a file or not." ;;; ---------------------------- GPTel Configuration ---------------------------- (use-package gptel + :load-path "~/code/gptel" + :ensure nil :defer t :commands (gptel gptel-send gptel-menu) :bind @@ -391,28 +393,6 @@ Works for any buffer, whether it's visiting a file or not." (advice-add 'gptel-send :before #'cj/gptel--refresh-org-prefix) (add-hook 'gptel-post-response-functions #'cj/gptel-insert-model-heading)) -;; Workaround: gptel's `gptel--with-buffer-copy-internal' copies the -;; source buffer's `major-mode' symbol into the prompt buffer but does -;; not run mode hooks, so `org-mode-hook' never fires there. In this -;; config the global `tab-width' default is 4, while `org-mode-hook' -;; sets it to 8 — so an inherited-org-mode prompt buffer keeps -;; `tab-width=4', and Org's `org-element--list-struct' guard raises -;; "Tab width in Org files must be 8" when gptel later parses it. -;; -;; Triggered in practice by `gptel-magit-generate-message' run from -;; COMMIT_EDITMSG with `git-commit-major-mode' set to `org-mode' (see -;; modules/vc-config.el). Force `tab-width=8' before `body-thunk' -;; runs so the prompt buffer satisfies Org's invariant. -(define-advice gptel--with-buffer-copy-internal - (:around (orig buf start end body-thunk) cj/fix-org-tab-width) - "Force `tab-width=8' in the gptel prompt buffer when its inherited -`major-mode' is `org-mode'." - (funcall orig buf start end - (lambda () - (when (eq major-mode 'org-mode) - (setq-local tab-width 8)) - (funcall body-thunk)))) - ;;; ---------------------------- Toggle GPTel Window ---------------------------- (defun cj/toggle-gptel () |
