branch: elpa/aidermacs
commit dbcc393ba0a03225844bc9c9fdc0498489ea5d8b
Author: Kang Tu <[email protected]>
Commit: GitHub <[email protected]>
Feat: aider-minor-mode (#10)
* add aider-send-line-under-cursor
* feat: add Aider mode with key binding for .aider files
* add scratch.aider, for batch / reproducible of aider command
* make switch buffer shortcut for aider-mode
* feat: add aider-send-paragraph function and key binding in aider-mode
* reorder function, change short-cut to fit ess key binding
* feat: add function to batch add Dired marked files to Aider buffer
* feat: add interactive function to run find-name-dired from Git repository
root
* update menu
* refactor: Rename parameter in aider--send-command for clarity and update
calls
* update place to invoke aider--send-command. remove dup
* refactor: Replace Aider major mode with minor mode and keybindings setup
* update README. make aider minor mode manual
fix typo
---------
Co-authored-by: Kang Tu <[email protected]>
---
README.org | 16 +++++++++++++++-
aider.el | 27 +++++++++++++--------------
2 files changed, 28 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..26d044986b 100644
--- a/aider.el
+++ b/aider.el
@@ -294,20 +294,19 @@ 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))
+;; 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.")
+
+;; Define the Aider Minor Mode
+(define-minor-mode aider-minor-mode
+ "Minor mode for Aider with keybindings."
+ :lighter " Aider"
+ :keymap aider-minor-mode-map)
-(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))
-
-(provide 'aider)
;;; aider.el ends here