diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-16 01:48:59 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-16 01:48:59 -0500 |
| commit | 670117cccdbae4706dfaa5e05144c256c3a657f0 (patch) | |
| tree | 481e3e9db64473c26c9aa52502d17e202304a3b6 /modules/ai-config.el | |
| parent | a8c7e8bf822535470d1a4621030b0edd07aaccb4 (diff) | |
| download | dotemacs-670117cccdbae4706dfaa5e05144c256c3a657f0.tar.gz dotemacs-670117cccdbae4706dfaa5e05144c256c3a657f0.zip | |
feat(ai-quick-ask): add cj/gptel-quick-ask one-shot command
New module `modules/ai-quick-ask.el`. Bound to `C-; a q` via
`cj/ai-keymap` ("quick ask").
`cj/gptel-quick-ask` reads a prompt in the minibuffer, creates a
transient `*GPTel-Quick*` buffer in `cj/gptel-quick-mode` (a
special-mode derivative with `q` / `escape` / `c` bindings), inserts
"Q: <prompt>" plus a response marker, then calls `gptel-request`
with `:stream t` so the answer streams into the buffer. Doesn't
touch `*AI-Assistant*`, doesn't autosave.
Two follow-up commands work in the buffer:
- `cj/gptel-quick-dismiss` (`q` / `escape`): delete the window and
kill the buffer. Idempotent when the buffer is absent.
- `cj/gptel-quick-continue` (`c`): extract the prompt + response,
seed them into `*AI-Assistant*` under proper org headings (matching
the `cj/gptel--fresh-org-prefix` shape), display the side window,
then dismiss the quick buffer.
13 tests cover the pure helpers (initial-text shape, response
extraction across normal / multi-line / no-marker / empty inputs,
seed-text shape), the ask path (buffer created in right mode,
prompt recorded, gptel-request called, empty-prompt error), the
dismiss path (kills buffer / no-op when absent), and the continue
path (seeds `*AI-Assistant*`, dismisses quick buffer, errors
outside a quick buffer). `gptel-request` is stubbed in tests so
nothing hits the network.
Diffstat (limited to 'modules/ai-config.el')
| -rw-r--r-- | modules/ai-config.el | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el index e7907e36..6eff1ba6 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -34,6 +34,7 @@ (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) +(autoload 'cj/gptel-quick-ask "ai-quick-ask" "One-shot quick-ask in a transient buffer." t) ;;; ------------------------- AI Config Helper Functions ------------------------ @@ -508,6 +509,7 @@ Works for any buffer, whether it's visiting a file or not." "l" #'cj/gptel-load-conversation ;; load and continue conversation "m" #'cj/gptel-change-model ;; change the LLM model "p" #'gptel-system-prompt ;; change prompt + "q" #'cj/gptel-quick-ask ;; one-shot quick ask "r" #'gptel-rewrite ;; rewrite a region of code/text "c" #'cj/gptel-context-clear ;; clear all context "s" #'cj/gptel-save-conversation ;; save conversation @@ -527,6 +529,7 @@ Works for any buffer, whether it's visiting a file or not." "C-; a l" "load conversation" "C-; a m" "change model" "C-; a p" "change prompt" + "C-; a q" "quick ask" "C-; a r" "rewrite region" "C-; a c" "clear context" "C-; a s" "save conversation" |
