aboutsummaryrefslogtreecommitdiff
path: root/modules
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
commit5923a140cdf9de4fc9cf47e6cbf7bfedbcdbb62a (patch)
tree94c841fd7fac2274220d86b91e5031783b84cb7d /modules
parent2df185f7160f5884a5349044f2c471b6899d996d (diff)
downloaddotemacs-5923a140cdf9de4fc9cf47e6cbf7bfedbcdbb62a.tar.gz
dotemacs-5923a140cdf9de4fc9cf47e6cbf7bfedbcdbb62a.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')
-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))))))