Function: eca-rewrite
eca-rewrite is an interactive and natively compiled function defined
in eca-rewrite.el.
Signature
(eca-rewrite &optional PROMPT)
Documentation
Rewrite a text with a new LLM generated one.
- If on an existing rewrite overlay, re-iterate
- Else if region active, rewrite that region
- Else try to detect defun/paragraph boundaries
PROMPT is the instructions prompt for the LLM.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-rewrite.el
;;;###autoload
(defun eca-rewrite (&optional prompt)
"Rewrite a text with a new LLM generated one.
- If on an existing rewrite overlay, re-iterate
- Else if region active, rewrite that region
- Else try to detect defun/paragraph boundaries
PROMPT is the instructions prompt for the LLM."
(interactive)
(eca-assert-session-running (eca-session))
(let* ((prompt (or prompt
(read-string "Rewrite prompt: " (or eca-rewrite--last-prompt
eca-rewrite-prompt-prefix))))
(existing-ov (eca-rewrite--overlay-at-point))
(start (cond (existing-ov (overlay-start existing-ov))
((use-region-p) (eca-rewrite--normalize-start-region (region-beginning)))
(t (or (car (bounds-of-thing-at-point 'defun))
(car (bounds-of-thing-at-point 'paragraph))
(user-error "No region selected or existing-ov rewrite overlay")))))
(end (cond (existing-ov (overlay-end existing-ov))
((use-region-p) (region-end))
(t (or (cdr (bounds-of-thing-at-point 'defun))
(cdr (bounds-of-thing-at-point 'paragraph))
start))))
(text (if existing-ov
(overlay-get existing-ov 'eca-text)
(buffer-substring-no-properties start end))))
(eca-rewrite--rewrite existing-ov (eca-session) text (buffer-file-name) start end prompt)))