branch: elpa/gptel
commit 9b454b5ef3a74aa4f9fef7a7786af9926f16ea7c
Author: Karthik Chikmagalur <[email protected]>
Commit: Karthik Chikmagalur <[email protected]>
gptel: Edge case when attaching response history
* gptel.el (gptel--attach-response-history): Handle edge case when
beg and/or end for not available in
`gptel-post-response-functions'.
---
gptel.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/gptel.el b/gptel.el
index ab214cf26e..a04939dbca 100644
--- a/gptel.el
+++ b/gptel.el
@@ -1982,9 +1982,11 @@ against if required."
(with-current-buffer (or buf (current-buffer))
(letrec ((gptel--attach-after
(lambda (b e)
- (put-text-property b e 'gptel-history
- (append (ensure-list history)
- (get-char-property (1- e)
'gptel-history)))
+ (when (and b e)
+ (put-text-property
+ b e 'gptel-history
+ (append (ensure-list history)
+ (get-char-property (1- e) 'gptel-history))))
(remove-hook 'gptel-post-response-functions
gptel--attach-after 'local))))
(add-hook 'gptel-post-response-functions gptel--attach-after