aboutsummaryrefslogtreecommitdiff
path: root/modules/ai-rewrite.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-23 20:12:58 -0400
committerCraig Jennings <c@cjennings.net>2026-06-23 20:12:58 -0400
commite41c25068d0cec9434895a6d3e3a25d3a26f645f (patch)
tree5e30938a3fd6d80f501ffe3e6c1c187c5ddeb2c9 /modules/ai-rewrite.el
parenta936e081b7270fbd4f1e7e9cb67ca1d4c2291ce6 (diff)
downloaddotemacs-e41c25068d0cec9434895a6d3e3a25d3a26f645f.tar.gz
dotemacs-e41c25068d0cec9434895a6d3e3a25d3a26f645f.zip
chore(ai): archive gptel and remove it from the live config
I archived gptel to archive/gptel/ since I rarely use it. Moved there: the six gptel modules (ai-config, ai-conversations, ai-conversations-browser, ai-mcp, ai-quick-ask, ai-rewrite), the gptel-tools/ directory, custom/gptel-prompts.el, their test files and utilities, and the four gptel-only specs. Scrubbed from the live config: the ai-config require in init.el, which also drops the whole C-; a keymap; the gptel-mode emojify hook in font-config.el; the gptel-tools entries in the Makefile clean target and the coverage runner; and the gptel feature notes in README. Cancelled the open gptel tasks in todo.org (the AI Open Work issues, the feature-extension brainstorm, the velox gptel-magit bug). ai-term stays. It is the ghostel Claude launcher, independent of gptel. Verified: every module loads, a batch init launch reaches completion clean, and the full test suite shows only pre-existing coverage failures unrelated to this change.
Diffstat (limited to 'modules/ai-rewrite.el')
-rw-r--r--modules/ai-rewrite.el108
1 files changed, 0 insertions, 108 deletions
diff --git a/modules/ai-rewrite.el b/modules/ai-rewrite.el
deleted file mode 100644
index fb25c1379..000000000
--- a/modules/ai-rewrite.el
+++ /dev/null
@@ -1,108 +0,0 @@
-;;; ai-rewrite.el --- Directive-picker wrappers for gptel-rewrite -*- lexical-binding: t; coding: utf-8; -*-
-
-;; Author: Craig Jennings <c@cjennings.net>
-
-;;; Commentary:
-;; Adds two ergonomic wrappers around `gptel-rewrite':
-;;
-;; cj/gptel-rewrite-with-directive Pick a named directive,
-;; then rewrite the region.
-;; cj/gptel-rewrite-redo-with-different-directive
-;; Re-run the previous region
-;; with a different directive.
-;;
-;; A directive is a short system-message snippet attached to a name
-;; (e.g. "terse", "fix-grammar"). The directive body is injected
-;; into the rewrite via `gptel-rewrite-directives-hook' just for that
-;; call -- no global state changes.
-
-;;; Code:
-
-;; Declare the hook variable special so our `let'-binding below is
-;; dynamic (visible across the `call-interactively' that follows)
-;; rather than lexical when this file is byte-compiled.
-(defvar gptel-rewrite-directives-hook)
-
-(defcustom cj/gptel-rewrite-directives
- '(("terse"
- . "Rewrite the text to be as terse as possible without losing meaning.\nDo not add commentary. Return only the rewritten text.")
- ("fix-grammar"
- . "Fix grammar and spelling errors only. Do not rephrase, restructure,\nor change tone. Return only the corrected text.")
- ("refactor-readability"
- . "Refactor the code for readability. Improve naming, split long\nfunctions when appropriate, remove unnecessary complexity, and preserve\nbehavior exactly. Return only the refactored code.")
- ("add-docstring"
- . "Add or improve docstrings for every function in the region. Use the\nidiomatic docstring style for the language. Do not change executable\ncode. Return the whole region with the updated docstrings.")
- ("explain-as-comment"
- . "Replace the region with the original code, preceded by a concise\nblock comment explaining what the code does. Use the language's\nidiomatic comment syntax. Return code + comment, nothing else.")
- ("shorten"
- . "Shorten the text while preserving meaning, technical accuracy, and\nthe author's voice. Remove rhetorical padding. Return only the\nshortened text."))
- "Named system-message directives for `cj/gptel-rewrite-with-directive'.
-Each entry is a (NAME . BODY) pair where NAME is the directive label
-presented in the completing-read prompt and BODY is the system
-message injected into the next `gptel-rewrite' call."
- :type '(alist :key-type string :value-type string)
- :group 'cj)
-
-(defvar-local cj/gptel-rewrite--last-region nil
- "Cons (BEG-MARKER . END-MARKER) of the last directive-driven rewrite.")
-
-(defvar-local cj/gptel-rewrite--last-directive nil
- "Name of the directive used in the last directive-driven rewrite.")
-
-(defun cj/gptel-rewrite--call-with-directive (directive-name beg end)
- "Run `gptel-rewrite' over BEG..END with DIRECTIVE-NAME's system message.
-Stores the region (as markers) and directive name on buffer-local
-variables so `cj/gptel-rewrite-redo-with-different-directive' can
-revisit them."
- (let ((body (alist-get directive-name cj/gptel-rewrite-directives
- nil nil #'equal)))
- (unless body
- (user-error "Unknown rewrite directive: %s" directive-name))
- (setq-local cj/gptel-rewrite--last-region
- (cons (copy-marker beg) (copy-marker end)))
- (setq-local cj/gptel-rewrite--last-directive directive-name)
- (let ((gptel-rewrite-directives-hook
- (cons (lambda () body) gptel-rewrite-directives-hook)))
- (save-excursion
- (goto-char beg)
- (push-mark end t t)
- (call-interactively #'gptel-rewrite)))))
-
-;;;###autoload
-(defun cj/gptel-rewrite-with-directive (directive-name)
- "Pick DIRECTIVE-NAME from `cj/gptel-rewrite-directives' and rewrite the region.
-Requires an active region. The directive is applied only to this
-call -- it does not modify global `gptel-directives'."
- (interactive
- (progn
- (unless (use-region-p)
- (user-error "No region selected"))
- (list (completing-read
- "Rewrite directive: "
- (mapcar #'car cj/gptel-rewrite-directives) nil t))))
- (cj/gptel-rewrite--call-with-directive
- directive-name (region-beginning) (region-end)))
-
-;;;###autoload
-(defun cj/gptel-rewrite-redo-with-different-directive ()
- "Re-run the previous directive-driven rewrite with a different directive.
-The region is restored from the markers captured at the last call;
-the user picks a new directive from the remaining choices."
- (interactive)
- (unless cj/gptel-rewrite--last-region
- (user-error "No previous rewrite to redo in this buffer"))
- (let* ((beg-mk (car cj/gptel-rewrite--last-region))
- (end-mk (cdr cj/gptel-rewrite--last-region))
- (current cj/gptel-rewrite--last-directive)
- (others (cl-remove
- current
- (mapcar #'car cj/gptel-rewrite-directives)
- :test #'equal))
- (chosen (completing-read
- (format "Re-rewrite with (was %s): " current)
- others nil t)))
- (cj/gptel-rewrite--call-with-directive
- chosen (marker-position beg-mk) (marker-position end-mk))))
-
-(provide 'ai-rewrite)
-;;; ai-rewrite.el ends here