gptel: Fix reading bounds in org files (#98)

* gptel.el (gptel--restore-state): When there is no "GPTEL_BOUNDS"
org property, `read' asks for stdin instead.  Fix by only calling
`read' when this property is non-nil.

Thanks to @Elilif for spotting this bug.
This commit is contained in:
Karthik Chikmagalur 2023-08-05 17:41:35 -07:00
parent 0f161a466b
commit c0ffce0849

View file

@ -331,11 +331,10 @@ Currently saving and restoring state is implemented only for
(widen)
(condition-case-unless-debug nil
(progn
(when-let ((bounds
(read (org-entry-get (point-min) "GPTEL_BOUNDS"))))
(when-let ((bounds (org-entry-get (point-min) "GPTEL_BOUNDS")))
(mapc (pcase-lambda (`(,beg . ,end))
(put-text-property beg end 'gptel 'response))
bounds)
(read bounds))
(message "gptel chat restored."))
(when-let ((model (org-entry-get (point-min) "GPTEL_MODEL")))
(setq-local gptel-model model))