From a8c7e8bf822535470d1a4621030b0edd07aaccb4 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 16 May 2026 01:42:30 -0500 Subject: feat(ai-conversations): add cj/gptel-autosave-toggle with [AS] mode-line indicator `cj/gptel-autosave-enabled` flipped to t inside the save/load entry points with no way back off short of editing the variable or clearing the buffer, and no visible indicator that it was on. Two pieces: - `cj/gptel-autosave-toggle` flips the buffer-local state in the current GPTel buffer. Bound to `C-; a A` via `cj/ai-keymap` (which-key: "toggle autosave"). When autosave is OFF and no filepath is configured yet, the command prompts to save the conversation first so a save target exists; otherwise it just flips the bit. - `cj/gptel-autosave-mode-line-format` surfaces " [AS]" in the mode-line when autosave is on, blank when off. Installed via a `gptel-mode-hook` so every GPTel buffer picks it up. The install helper is idempotent. 6 new tests cover enable/disable paths, the no-filepath prompt path, the not-a-gptel-buffer error path, the mode-line format evaluation, and the install idempotence. --- modules/ai-config.el | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/ai-config.el') diff --git a/modules/ai-config.el b/modules/ai-config.el index 0ffee799c..e7907e362 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -33,6 +33,7 @@ (autoload 'cj/gptel-save-conversation "ai-conversations" "Save the AI conversation to a file." t) (autoload 'cj/gptel-load-conversation "ai-conversations" "Load a saved AI conversation." t) (autoload 'cj/gptel-delete-conversation "ai-conversations" "Delete a saved AI conversation." t) +(autoload 'cj/gptel-autosave-toggle "ai-conversations" "Toggle autosave in the current GPTel buffer." t) ;;; ------------------------- AI Config Helper Functions ------------------------ @@ -498,6 +499,7 @@ Works for any buffer, whether it's visiting a file or not." (defvar-keymap cj/ai-keymap :doc "Keymap for gptel and other AI operations." + "A" #'cj/gptel-autosave-toggle ;; toggle autosave on the current GPTel buffer "B" #'cj/gptel-switch-backend ;; change the backend (OpenAI, Anthropic, etc. "M" #'gptel-menu ;; gptel's transient menu "d" #'cj/gptel-delete-conversation ;; delete conversation @@ -516,6 +518,7 @@ Works for any buffer, whether it's visiting a file or not." (with-eval-after-load 'which-key (which-key-add-key-based-replacements "C-; a" "AI assistant menu" + "C-; a A" "toggle autosave" "C-; a B" "switch backend" "C-; a M" "gptel menu" "C-; a d" "delete conversation" -- cgit v1.2.3