[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/aidermacs 3b9f5b5dd5 437/466: Introduce aidermacs-show-dif
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/aidermacs 3b9f5b5dd5 437/466: Introduce aidermacs-show-diff-after-change to control diff |
Date: |
Sat, 15 Mar 2025 19:19:41 -0400 (EDT) |
branch: elpa/aidermacs
commit 3b9f5b5dd518adcf13ebcfee1168df5333f20c4b
Author: Mingde (Matthew) Zeng <matthewzmd@posteo.net>
Commit: Mingde (Matthew) Zeng <matthewzmd@posteo.net>
Introduce aidermacs-show-diff-after-change to control diff
Resolves #57
---
README.md | 14 ++++++++++++++
aidermacs.el | 49 +++++++++++++++++++++++++++++--------------------
2 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 65b9c5072d..9cc1625618 100644
--- a/README.md
+++ b/README.md
@@ -141,6 +141,20 @@ You can customize keybindings for multiline input, this
key allows you to enter
(setq aidermacs-vterm-multiline-newline-key "S-<return>")
```
+### Diff and Change Review
+
+Control whether to show diffs for AI-generated changes with
`aidermacs-show-diff-after-change`:
+
+```emacs-lisp
+;; Enable/disable showing diffs after changes (default: t)
+(setq aidermacs-show-diff-after-change t)
+```
+
+When enabled, Aidermacs will:
+- Capture the state of files before AI edits
+- Show diffs using Emacs' built-in ediff interface
+- Allow you to review and accept/reject changes
+
### Re-Enable Auto-Commits
Aider automatically commits AI-generated changes by default. We consider this
behavior *very* intrusive, so we've disabled it. You can re-enable auto-commits
by setting `aidermacs-auto-commits` to `t`:
diff --git a/aidermacs.el b/aidermacs.el
index 1a8a04fa47..42cbcd4e5f 100644
--- a/aidermacs.el
+++ b/aidermacs.el
@@ -49,6 +49,12 @@ Possible values: `code', `ask', `architect', `help'.")
:prefix "aidermacs-"
:group 'convenience)
+(defcustom aidermacs-show-diff-after-change t
+ "When non-nil, enable ediff for reviewing AI-generated changes.
+When nil, skip preparing temp buffers and showing ediff comparisons."
+ :type 'boolean
+ :group 'aidermacs)
+
(defcustom aidermacs-program "aider"
"The name or path of the aidermacs program."
:type 'string
@@ -345,24 +351,26 @@ Kills all pre-edit buffers that were created to store
original file content."
(defun aidermacs--prepare-for-code-edit ()
"Prepare for code edits by capturing current file states in memory buffers.
-Creates temporary buffers containing the original content of all tracked
files."
- (let ((files aidermacs--tracked-files))
- (when files
- (setq aidermacs--pre-edit-file-buffers
- (cl-remove-duplicates
- (mapcar (lambda (file)
- (let* ((clean-file (replace-regexp-in-string "
(read-only)$" "" file))
- (full-path (expand-file-name clean-file
(aidermacs-project-root))))
- ;; Only capture state if we don't already have it
- (or (assoc full-path aidermacs--pre-edit-file-buffers)
- (aidermacs--capture-file-state full-path))))
- files)
- :test (lambda (a b) (equal (car a) (car b)))))
- ;; Remove nil entries from the list (where capture failed or was skipped)
- (setq aidermacs--pre-edit-file-buffers (delq nil
aidermacs--pre-edit-file-buffers))
- ;; Run again if it's nil
- (unless aidermacs--pre-edit-file-buffers
- (aidermacs--prepare-for-code-edit)))))
+Creates temporary buffers containing the original content of all tracked files.
+This is skipped if `aidermacs-show-diff-after-change' is nil."
+ (when aidermacs-show-diff-after-change
+ (let ((files aidermacs--tracked-files))
+ (when files
+ (setq aidermacs--pre-edit-file-buffers
+ (cl-remove-duplicates
+ (mapcar (lambda (file)
+ (let* ((clean-file (replace-regexp-in-string "
(read-only)$" "" file))
+ (full-path (expand-file-name clean-file
(aidermacs-project-root))))
+ ;; Only capture state if we don't already have it
+ (or (assoc full-path
aidermacs--pre-edit-file-buffers)
+ (aidermacs--capture-file-state full-path))))
+ files)
+ :test (lambda (a b) (equal (car a) (car b)))))
+ ;; Remove nil entries from the list (where capture failed or was
skipped)
+ (setq aidermacs--pre-edit-file-buffers (delq nil
aidermacs--pre-edit-file-buffers))
+ ;; Run again if it's nil
+ (unless aidermacs--pre-edit-file-buffers
+ (aidermacs--prepare-for-code-edit))))))
(defun aidermacs--ediff-quit-handler ()
"Handle ediff session cleanup and process next files in queue.
@@ -460,8 +468,9 @@ Returns a list of files that have been modified according
to the output."
(aidermacs--process-next-ediff-file))))
(defun aidermacs--show-ediff-for-edited-files (edited-files)
- "Show ediff for each file in EDITED-FILES."
- (when edited-files
+ "Show ediff for each file in EDITED-FILES.
+This is skipped if `aidermacs-show-diff-after-change' is nil."
+ (when (and aidermacs-show-diff-after-change edited-files)
;; Display a message about which files were changed
(message "Modified %d file(s): %s"
(length edited-files)
- [nongnu] elpa/aidermacs 5b812f26e5 419/466: Check udiff cases, (continued)
- [nongnu] elpa/aidermacs 5b812f26e5 419/466: Check udiff cases, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 0c236ac3d6 421/466: Fix aidermacs-prompt-regexp and fix aidermacs--parse-ls-output, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs ddd8000e17 424/466: Add Melpa!, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs b4a771c777 425/466: Fix #52, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 9a8575e7de 430/466: Use minor mode for relevant functions, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 389d69fddb 428/466: refactor: add aidermacs-comint-mode minor mode., ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 66d04629bc 431/466: Fix linting, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 1971d48717 432/466: Fix linting, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 9644836022 434/466: Do not suggest auto commit, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 47327b96d2 435/466: fix(aidermacs-models): ensure correct parsing by moving to end of headers, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 3b9f5b5dd5 437/466: Introduce aidermacs-show-diff-after-change to control diff,
ELPA Syncer <=
- [nongnu] elpa/aidermacs 4af8c4283d 436/466: Merge pull request #55 from zsxh/fix/fetch-models, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 22f59e2b8a 441/466: Update README with Tramp support, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 77ed294a6f 444/466: The Community Speaks, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 1c2d4ac340 443/466: Fix typo, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 15a01a9b42 445/466: Improve API_KEY documentation, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 7848604a82 447/466: load api key from secrets, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs cdb15637ab 452/466: Fix linting, refactor, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 7614cb6542 463/466: Add aidermacs-refresh-repo-map, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs 58b3fc29f5 458/466: Match space before ```, ELPA Syncer, 2025/03/15
- [nongnu] elpa/aidermacs f3d308a068 460/466: Drop marked files from Dired buffer, ELPA Syncer, 2025/03/15