emacs-elpa-diffs
[Top][All Lists]
Advanced

[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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]