branch: elpa/gptel
commit f342b3010f135ca4a38b02564b50b2d3e66554cf
Author: Craig Jennings <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel-org: Copy tab-width into the prompt buffer
* gptel-org.el (gptel-org--create-prompt-buffer): Fix Org mode
parsing of lists in the prompt buffer caused by tab-width
mismatches by copying tab-width from the source Org buffer.
This bug surfaced for users with
1. git-commit-major-mode set to org-mode,
2. running gptel-magit-generate-message
3. on diffs that org-element parsed as list structures.
* NEWS (Notable bug fixes): Mention bug fix
---
NEWS | 3 +++
gptel-org.el | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/NEWS b/NEWS
index 200e46d3c3..f916680e07 100644
--- a/NEWS
+++ b/NEWS
@@ -54,6 +54,9 @@
- Fix bounds issues when using the gptel transient menu with =evil-mode=
visual selections.
+- Fix org-mode parsing issues involving =tab-width= when sending
+ queries.
+
* 0.9.9.5 2026-05-03
** Breaking changes
diff --git a/gptel-org.el b/gptel-org.el
index a5682ade47..eebad98e25 100644
--- a/gptel-org.el
+++ b/gptel-org.el
@@ -285,6 +285,8 @@ depend on the value of `gptel-org-branching-context', which
see."
(gptel-org--strip-elements))
(setq org-complex-heading-regexp ;For org-element-context to run
(buffer-local-value 'org-complex-heading-regexp org-buf))
+ (setq tab-width ;Match source indentation for list parsing
+ (buffer-local-value 'tab-width org-buf))
(current-buffer))))
;; Create prompt the usual way
(let ((org-buf (current-buffer))
@@ -298,6 +300,8 @@ depend on the value of `gptel-org-branching-context', which
see."
(gptel-org--strip-elements))
(setq org-complex-heading-regexp ;For org-element-context to run
(buffer-local-value 'org-complex-heading-regexp org-buf))
+ (setq tab-width ;Match source indentation for list parsing
+ (buffer-local-value 'tab-width org-buf))
(current-buffer))))))
(defun gptel-org--strip-elements ()