gptel: Handle insertion with region-active correctly
gptel.el (gptel-send, gptel--url-parse-response): Handle insertion better when region is active. Decode utf-8 encoded response when using url-retrieve (instead of curl).
This commit is contained in:
parent
c8f87f5554
commit
1ada9c9214
1 changed files with 5 additions and 2 deletions
7
gptel.el
7
gptel.el
|
@ -157,7 +157,10 @@ return the transformed string."
|
|||
(call-interactively #'gptel-send-menu)
|
||||
(message "Querying ChatGPT...")
|
||||
(gptel--update-header-line " Waiting..." 'warning)
|
||||
(let* ((response-pt (point-marker))
|
||||
(let* ((response-pt
|
||||
(if (use-region-p)
|
||||
(set-marker (make-marker) (region-end))
|
||||
(point-marker)))
|
||||
(gptel-buffer (current-buffer))
|
||||
(full-prompt (gptel--create-prompt response-pt))
|
||||
(response (aio-await
|
||||
|
@ -308,7 +311,7 @@ Return the message received."
|
|||
(json-read)))
|
||||
(content (map-nested-elt
|
||||
response '(:choices 0 :message :content))))
|
||||
(list :content (string-trim content)
|
||||
(list :content (string-trim (decode-coding-string content 'utf-8))
|
||||
:status status)
|
||||
(list :content nil :status status)))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue