branch: elpa/gptel
commit d91675db959b18cded8afb4902a52b19fd476ac9
Author: Karthik Chikmagalur <karthikchikmaga...@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmaga...@gmail.com>

    gptel-org: Fix save-state to handle nil buffer bounds
    
    * gptel-org.el (gptel-org--save-state): Don't throw an error if
    there are no response regions in the buffer when saving the chat
    state.
---
 gptel-org.el | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gptel-org.el b/gptel-org.el
index 003e8af38a..caa870b62b 100644
--- a/gptel-org.el
+++ b/gptel-org.el
@@ -516,10 +516,10 @@ non-nil (default), display a message afterwards."
    ;; Save response boundaries
    (letrec ((write-bounds
              (lambda (attempts)
-               (let* ((bounds (gptel--get-buffer-bounds))
-                      ;; first value of ((prop . ((beg end val)...))...)
-                      (offset (caadar bounds))
-                      (offset-marker (set-marker (make-marker) offset)))
+               (when-let* ((bounds (gptel--get-buffer-bounds))
+                           ;; first value of ((prop . ((beg end val)...))...)
+                           (offset (caadar bounds))
+                           (offset-marker (set-marker (make-marker) offset)))
                  (org-entry-put (point-min) "GPTEL_BOUNDS"
                                 (prin1-to-string (gptel--get-buffer-bounds)))
                  (when (and (not (= (marker-position offset-marker) offset))

Reply via email to