branch: elpa/gptel commit ba88c841e39e819c4c40ba44835da39672ed7dc0 Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com> Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
gptel: Fix prompt-creation marker usage bug (#1018) * gptel.el (gptel-request): Don't use gptel-request's POSITION argument as the position to create prompts from, use (point) instead. POSITION is meant to encode where the response will be inserted. * gptel-org.el (gptel-org--create-prompt-buffer): Handle regions correctly when creating prompts. --- gptel-org.el | 7 +++---- gptel.el | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gptel-org.el b/gptel-org.el index af0e442b095..2f26df9f10b 100644 --- a/gptel-org.el +++ b/gptel-org.el @@ -200,10 +200,9 @@ Otherwise the prompt text is constructed from the contents of the current buffer up to point, or PROMPT-END if provided. Its contents depend on the value of `gptel-org-branching-context', which see." (when (use-region-p) - (narrow-to-region (region-beginning) (region-end))) - (if prompt-end - (goto-char prompt-end) - (setq prompt-end (point))) + (narrow-to-region (region-beginning) (region-end)) + (setq prompt-end (point-max))) + (goto-char (or prompt-end (setq prompt-end (point)))) (let ((topic-start (gptel-org--get-topic-start))) (when topic-start ;; narrow to GPTEL_TOPIC property scope diff --git a/gptel.el b/gptel.el index c3636287eba..d44317ef716 100644 --- a/gptel.el +++ b/gptel.el @@ -2651,7 +2651,7 @@ be used to rerun or continue the request at a later time." (prompt-buffer (cond ;prompt from buffer or explicitly supplied ((null prompt) - (gptel--create-prompt-buffer start-marker)) + (gptel--create-prompt-buffer (point))) ((stringp prompt) (gptel--with-buffer-copy buffer nil nil (insert prompt)