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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/aidermacs b3450f17b0 112/466: Merge branch 'main' of githu


From: ELPA Syncer
Subject: [nongnu] elpa/aidermacs b3450f17b0 112/466: Merge branch 'main' of github.com:tninja/aider.el
Date: Sat, 15 Mar 2025 19:12:18 -0400 (EDT)

branch: elpa/aidermacs
commit b3450f17b046da27332a7d9c682ec71659eca073
Merge: 2cf6150925 0742aa2666
Author: Kang Tu <kang_tu@apple.com>
Commit: Kang Tu <kang_tu@apple.com>

    Merge branch 'main' of github.com:tninja/aider.el
---
 README.org | 16 +++++++++++++++-
 aider.el   | 44 ++++++++++++++++++++++++++++++--------------
 2 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/README.org b/README.org
index 5382646e3a..4701442037 100644
--- a/README.org
+++ b/README.org
@@ -41,7 +41,21 @@
 
 ** Optional
 
-- If you use helm, maybe you can load the helm-aider.el manually. That file 
added support of command history and completion from helm.
+- Maybe you might want to try helm-aider.el. That file added support of 
command history and completion from helm.
+
+- If you enjoy writing aider command in a separate file and send them to aider 
session, just like working on python or R script and send code block into REPL, 
you might want to try aider-minor-mode. It by default bind C-c C-n to send 
current line to aider session, and C-c C-c to send current region to aider 
session.
+
+- To automatically enable aider-minor-mode to any file with aider inside 
filename
+
+#+BEGIN_SRC emacs-lisp
+  (add-hook 'find-file-hook
+            (lambda ()
+              (when (and (buffer-file-name)
+                         (string-match-p "aider" (buffer-file-name)))
+                (aider-minor-mode 1))))
+
+  (provide 'aider)
+#+END_SRC
 
 * Screenshot
 
diff --git a/aider.el b/aider.el
index 730b5b1d3a..94b8e39ec5 100644
--- a/aider.el
+++ b/aider.el
@@ -55,8 +55,9 @@ This function can be customized or redefined by the user."
     ]
    ["Add file to aider"
     ("f" "Add Current File" aider-add-current-file)
-    ("F" "Find Files in the Git Repo" aider-repo-find-name-dired)
+    ("w" "Add All Files in Current Window" aider-add-files-in-current-window)
     ("b" "Batch Add Dired Marked Files" aider-batch-add-dired-marked-files)
+    ("F" "Find Files in the Git Repo" aider-repo-find-name-dired)
     ("R" "Open Git Repo Root Dired" aider-git-repo-root-dired)
     ]
    ["Code change"
@@ -294,19 +295,34 @@ The command will be formatted as \"/architect \" followed 
by the user command an
                       (point)))))
     (aider--send-command (string-trim paragraph) t)))
 
-(defun aider-mode-setup ()
-  "Setup key bindings for Aider mode."
-  (local-set-key (kbd "C-c C-n") 'aider-send-line-under-cursor)
-  (local-set-key (kbd "C-c C-c") 'aider-send-paragraph))
-
-(add-hook 'aider-mode-hook 'aider-mode-setup)
-
-(define-derived-mode aider-mode fundamental-mode "Aider"
-  "Major mode for editing Aider files."
-  ;; Add any additional setup for aider-mode here
-  )
-
-(add-to-list 'auto-mode-alist '("\\.aider\\'" . aider-mode))
+;; Define the keymap for Aider Minor Mode
+(defvar aider-minor-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c C-n") 'aider-send-line-under-cursor)
+    (define-key map (kbd "C-c C-c") 'aider-send-paragraph)
+    map)
+  "Keymap for Aider Minor Mode.")
+
+;; New function to add files in all buffers in current emacs window
+(defun aider-add-files-in-current-window ()
+  "Add files in all buffers in the current Emacs window to the Aider buffer."
+  (interactive)
+  (let ((files (mapcar (lambda (buffer)
+                         (with-current-buffer buffer
+                           (when buffer-file-name
+                             (expand-file-name buffer-file-name))))
+                       (mapcar 'window-buffer (window-list)))))
+    (setq files (delq nil files))
+    (if files
+        (let ((command (concat "/add " (mapconcat 'identity files " "))))
+          (aider--send-command command nil))
+      (message "No files found in the current window."))))
+
+;; Define the Aider Minor Mode
+(define-minor-mode aider-minor-mode
+  "Minor mode for Aider with keybindings."
+  :lighter " Aider"
+  :keymap aider-minor-mode-map)
 
 (provide 'aider)
 



reply via email to

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