aboutsummaryrefslogtreecommitdiff
path: root/modules/ai-conversations.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-20 12:21:40 -0400
committerCraig Jennings <c@cjennings.net>2026-06-20 12:21:40 -0400
commit55ca0d6f157e34372fe21539551bee797056d906 (patch)
tree3f3e444eacdfb0a09988417969c0b610eee521f2 /modules/ai-conversations.el
parent654d1a0c6f4acd05ca88ea30bf304ac008fd2f7a (diff)
downloaddotemacs-55ca0d6f157e34372fe21539551bee797056d906.tar.gz
dotemacs-55ca0d6f157e34372fe21539551bee797056d906.zip
refactor(ai-conversations): reuse the autosave-active predicate in the hooks
cj/gptel--autosave-after-send and cj/gptel--autosave-after-response re-inlined the four-clause "should we autosave?" boolean that cj/gptel--autosave-active-p already encapsulates. Call the helper instead (after-send keeps its extra autosave-on-send flag). Behavior unchanged; one predicate to maintain.
Diffstat (limited to 'modules/ai-conversations.el')
-rw-r--r--modules/ai-conversations.el10
1 files changed, 2 insertions, 8 deletions
diff --git a/modules/ai-conversations.el b/modules/ai-conversations.el
index 839af9ad3..8061051a8 100644
--- a/modules/ai-conversations.el
+++ b/modules/ai-conversations.el
@@ -140,10 +140,7 @@ so a path exists to autosave to."
(defun cj/gptel--autosave-after-send (&rest _args)
"Auto-save current GPTel buffer right after `gptel-send' if enabled."
(when (and cj/gptel-conversations-autosave-on-send
- (bound-and-true-p gptel-mode)
- cj/gptel-autosave-enabled
- (stringp cj/gptel-autosave-filepath)
- (> (length cj/gptel-autosave-filepath) 0))
+ (cj/gptel--autosave-active-p))
(condition-case err
(cj/gptel--save-buffer-to-file (current-buffer) cj/gptel-autosave-filepath)
(error (message "cj/gptel autosave-on-send failed: %s" (error-message-string err))))))
@@ -359,10 +356,7 @@ enable autosave."
(defun cj/gptel--autosave-after-response (&rest _args)
"Auto-save the current GPTel buffer when enabled."
- (when (and (bound-and-true-p gptel-mode)
- cj/gptel-autosave-enabled
- (stringp cj/gptel-autosave-filepath)
- (> (length cj/gptel-autosave-filepath) 0))
+ (when (cj/gptel--autosave-active-p)
(condition-case err
(cj/gptel--save-buffer-to-file (current-buffer) cj/gptel-autosave-filepath)
(error (message "cj/gptel autosave failed: %s" (error-message-string err))))))