branch: elpa/gptel commit 3722942363b26befd35e9c259de3f42e9ed704a7 Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com> Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
gptel-org: Set org-complex-heading-regexp in prompt buffer * gptel-org.el (gptel-org--create-prompt-buffer): Copy `org-complex-heading-regexp' from the request buffer to the prompt construction buffer. This is required for `org-element-context' to run when parsing links. (#947) Note that the more robust way to do this is to run `org-set-regexps-and-options' instead. But I'm not happy with the performance of this function, it does a surprising amount of consing for something that ostensibly just sets a few variables. We can move to this mitigation if other problems arise as a result of not calling `org-mode' in the prompt construction buffer. --- gptel-org.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gptel-org.el b/gptel-org.el index 6d1d6e68dc..19bc62e9b2 100644 --- a/gptel-org.el +++ b/gptel-org.el @@ -248,6 +248,8 @@ depend on the value of `gptel-org-branching-context', which see." (gptel-org--unescape-tool-results) (gptel-org--strip-block-headers) (when gptel-org-ignore-elements (gptel-org--strip-elements)) + (setq org-complex-heading-regexp ;For org-element-context to run + (buffer-local-value 'org-complex-heading-regexp org-buf)) (current-buffer)))) ;; Create prompt the usual way (let ((org-buf (current-buffer)) @@ -256,6 +258,8 @@ depend on the value of `gptel-org-branching-context', which see." (gptel-org--unescape-tool-results) (gptel-org--strip-block-headers) (when gptel-org-ignore-elements (gptel-org--strip-elements)) + (setq org-complex-heading-regexp ;For org-element-context to run + (buffer-local-value 'org-complex-heading-regexp org-buf)) (current-buffer)))))) (defun gptel-org--strip-elements ()