branch: elpa/aidermacs commit 21ad2f803d025388f36e2c8b8b3770fc37608b09 Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
Fix melpazoid warnings --- README.md | 14 ++++++++++++++ aidermacs-backend-comint.el | 23 ++++++++++++++--------- aidermacs-backend-vterm.el | 11 ++++++++--- aidermacs-backends.el | 5 +++++ aidermacs-doom.el | 13 +++++++++---- aidermacs-models.el | 5 +++++ aidermacs.el | 30 +++++++++++++++++------------- 7 files changed, 72 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 0745e0ce35..5198a9757f 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,20 @@ The main interface to Aidermacs is through its transient menu system. Here's a b - `l`: Clear Buffer - `h`: Aider Help +### Doom Emacs Integration + +When using Aidermacs with Doom Emacs, you can enable Doom-specific keybindings by calling `(aidermacs-doom-enable)`. This sets up Evil-friendly keybindings under the SPC leader key: + +- `SPC A` - Aidermacs prefix + - `a` - Start/Open Session + - `.` - Start in Current Dir + - `o` - Change Solo Model + - `s` - Reset Session + - `x` - Exit Session + - And more... + +The keybindings are only activated in buffers that are part of a Git repository, keeping your global keybinding space clean. + ### Working with Prompt Blocks in `.aider*` files When editing `.aider.prompt.org` or other `.aider*` files, these keybindings are available: diff --git a/aidermacs-backend-comint.el b/aidermacs-backend-comint.el index c7f52a423b..462e12649c 100644 --- a/aidermacs-backend-comint.el +++ b/aidermacs-backend-comint.el @@ -16,6 +16,11 @@ (require 'comint) +(declare-function aidermacs--process-message-if-multi-line "aidermacs" (str)) + +(defvar aidermacs-language-name-map nil + "Map external language names to Emacs names.") + (defconst aidermacs-search-marker "<<<<<<< SEARCH") (defconst aidermacs-diff-marker "=======") (defconst aidermacs-replace-marker ">>>>>>> REPLACE") @@ -115,14 +120,14 @@ OUTPUT is the text to be processed." (unless aidermacs--syntax-last-output-pos ;; Set up new block state - (setq marker (match-string 1)) - (setq aidermacs--syntax-block-start-pos (line-end-position) - aidermacs--syntax-block-end-pos (line-end-position) - aidermacs--syntax-block-delimiter - (pcase marker - ((pred (equal aidermacs-search-marker)) aidermacs-diff-marker) - ((pred (equal aidermacs-diff-marker)) aidermacs-replace-marker) - ((pred (equal aidermacs-fence-marker)) aidermacs-fence-marker))) + (let ((block-marker (match-string 1))) + (setq aidermacs--syntax-block-start-pos (line-end-position) + aidermacs--syntax-block-end-pos (line-end-position) + aidermacs--syntax-block-delimiter + (pcase block-marker + ((pred (equal aidermacs-search-marker)) aidermacs-diff-marker) + ((pred (equal aidermacs-diff-marker)) aidermacs-replace-marker) + ((pred (equal aidermacs-fence-marker)) aidermacs-fence-marker)))) (with-current-buffer aidermacs--syntax-work-buffer (erase-buffer)) @@ -232,7 +237,7 @@ BUFFER-NAME is the name for the aidermacs buffer." (let ((comint-terminfo-terminal "eterm-color") (args (append args (list "--no-pretty" "--no-fancy-input")))) (unless (comint-check-proc buffer-name) - (apply 'make-comint-in-buffer "aidermacs" buffer-name program nil args) + (apply #'make-comint-in-buffer "aidermacs" buffer-name program nil args) (with-current-buffer buffer-name (comint-mode) (setq-local comint-prompt-regexp "[^[:space:]]*>[[:space:]]$") diff --git a/aidermacs-backend-vterm.el b/aidermacs-backend-vterm.el index b861dd1f6d..43fe2a4814 100644 --- a/aidermacs-backend-vterm.el +++ b/aidermacs-backend-vterm.el @@ -23,13 +23,18 @@ ;; Forward declaration to avoid compiler warnings (declare-function vterm--render "vterm") (declare-function vterm--get-prompt-point "vterm") +(declare-function vterm-other-window "vterm") +(declare-function vterm-send-string "vterm") +(declare-function vterm-send-return "vterm") +(declare-function vterm-insert "vterm") + (defun aidermacs--is-aidermacs-vterm-buffer-p (&optional buffer) "Check if BUFFER is an aidermacs vterm buffer. If BUFFER is nil, check the current buffer. Returns non-nil if the buffer name matches the aidermacs buffer pattern." (let ((buf (or buffer (current-buffer)))) - (and (eq major-mode 'vterm-mode) + (and (derived-mode-p 'vterm-mode) (string-match-p "^\\*aidermacs:" (buffer-name buf))))) (defun aidermacs--vterm-check-finish-sequence-repeated (proc orig-filter start-point expected) @@ -118,12 +123,12 @@ after each output chunk, reducing the need for timers." PROGRAM is the command to run. ARGS is a list of command line arguments. BUFFER-NAME is the name for the vterm buffer." (unless (require 'vterm nil t) - (error "vterm package is not available")) + (error "Vterm package is not available")) (unless (get-buffer buffer-name) (let* ((mode (if (eq (frame-parameter nil 'background-mode) 'dark) "--dark-mode" "--light-mode")) - (cmd (mapconcat 'identity (append (list program mode) args) " ")) + (cmd (mapconcat #'identity (append (list program mode) args) " ")) (vterm-buffer-name buffer-name) (vterm-shell cmd)) (with-current-buffer (vterm-other-window) diff --git a/aidermacs-backends.el b/aidermacs-backends.el index e5944c5a47..dacd39d71e 100644 --- a/aidermacs-backends.el +++ b/aidermacs-backends.el @@ -18,6 +18,11 @@ (when (commandp 'vterm) (require 'aidermacs-backend-vterm)) +(declare-function aidermacs-run-vterm "aidermacs-backend-vterm" + (program args buffer-name)) +(declare-function aidermacs--send-command-vterm "aidermacs-backend-vterm" + (buffer command)) + (defgroup aidermacs-backends nil "Backend customization for aidermacs." :group 'aidermacs) diff --git a/aidermacs-doom.el b/aidermacs-doom.el index 7a49ea7395..2400925a09 100644 --- a/aidermacs-doom.el +++ b/aidermacs-doom.el @@ -74,10 +74,15 @@ :desc "Clear Buffer" "l" #'aidermacs-clear :desc "Aider Help" "h" #'aidermacs-help)))) -;; Add the setup function to appropriate hooks -(add-hook 'find-file-hook #'aidermacs-doom-setup-keys) -(add-hook 'dired-mode-hook #'aidermacs-doom-setup-keys) -(add-hook 'after-change-major-mode-hook #'aidermacs-doom-setup-keys) +;;;###autoload +(defun aidermacs-doom-enable () + "Enable Doom keybindings for aidermacs. +This adds the key setup function to relevant hooks. +Call this from your Doom config to enable the keybindings." + (interactive) + (add-hook 'find-file-hook #'aidermacs-doom-setup-keys) + (add-hook 'dired-mode-hook #'aidermacs-doom-setup-keys) + (add-hook 'after-change-major-mode-hook #'aidermacs-doom-setup-keys)) (provide 'aidermacs-doom) ;;; aidermacs-doom.el ends here diff --git a/aidermacs-models.el b/aidermacs-models.el index fffe9cd035..0ff48146ea 100644 --- a/aidermacs-models.el +++ b/aidermacs-models.el @@ -17,6 +17,11 @@ (require 'json) (require 'url) +(declare-function aidermacs--send-command "aidermacs" (command &optional switch-to-buffer)) +(declare-function aidermacs--send-command-redirect "aidermacs" (command callback)) +(declare-function aidermacs-buffer-name "aidermacs" ()) +(declare-function aidermacs-exit "aidermacs" ()) + (defgroup aidermacs-models nil "Model selection customization for aidermacs." :group 'aidermacs) diff --git a/aidermacs.el b/aidermacs.el index 67b45fb455..7630797442 100644 --- a/aidermacs.el +++ b/aidermacs.el @@ -11,12 +11,14 @@ ;; ;;; Commentary: ;; -;; This package provides an interactive interface to communicate with https://github.com/paul-gauthier/aidermacs. +;; This package provides an interactive interface to communicate +;; with https://github.com/paul-gauthier/aidermacs. ;; ;;; Code: (require 'comint) (require 'dired) +(require 'project) (require 'transient) (require 'vc-git) (require 'which-func) @@ -28,6 +30,8 @@ (when (featurep 'doom) (require 'aidermacs-doom)) +(declare-function magit-show-commit "magit-diff" (rev &optional noselect module)) + (defgroup aidermacs nil "Customization group for the aidermacs package." :prefix "aidermacs-" @@ -69,8 +73,7 @@ When nil, disable auto-commits requiring manual git commits." (defun aidermacs-project-root () "Get the project root using project.el, VC, or fallback to file directory. This function tries multiple methods to determine the project root." - (or (when (and (fboundp 'project-current) (project-current)) - (project-root (project-current))) + (or (project-root (project-current)) (vc-git-root default-directory) (when buffer-file-name (file-name-directory buffer-file-name)) @@ -103,11 +106,11 @@ PROMPT is the text to display. INITIAL-INPUT is the default value." (read-string prompt initial-input 'aidermacs-read-string-history)) ;;;###autoload -(defalias 'aidermacs-read-string 'aidermacs-plain-read-string) +(defalias 'aidermacs-read-string #'aidermacs-plain-read-string) (eval-and-compile ;; Ensure the alias is always available in both compiled and interpreted modes. - (defalias 'aidermacs-read-string 'aidermacs-plain-read-string)) + (defalias 'aidermacs-read-string #'aidermacs-plain-read-string)) ;; Transient menu for aidermacs commands ;; The instruction in the autoload comment is needed, see @@ -485,7 +488,7 @@ Sends the \"/ls\" command and returns the list of files via callback." (erase-buffer) (display-line-numbers-mode 1) (dolist (entry history) - (let ((timestamp (format-time-string "%Y-%m-%d %H:%M:%S" (car entry))) + (let ((timestamp (format-time-string "%F %T" (car entry))) (output (cdr entry))) (insert (format "* %s\n#+BEGIN_SRC\n%s\n#+END_SRC\n" timestamp output)))) (goto-char (point-min)) @@ -511,7 +514,7 @@ If cursor is inside a function, include the function name as context." (interactive) ;; Dispatch to general question if in aidermacs buffer (when (string= (buffer-name) (aidermacs-buffer-name)) - (call-interactively 'aidermacs-ask-question-general) + (call-interactively #'aidermacs-ask-question-general) (cl-return-from aidermacs-ask-question-context)) (aidermacs-add-current-file) (when-let ((command (aidermacs--form-prompt "/ask" "Ask"))) @@ -551,6 +554,7 @@ If cursor is inside a function, include the function name as context." (interactive) (aidermacs--send-command "go ahead" t)) + ;;;###autoload (defun aidermacs-magit-show-last-commit () "Show the last commit message using Magit. @@ -630,7 +634,7 @@ as read-only. Optional MESSAGE can override the default success message." (if files (progn (aidermacs--send-command (format "%s %s" cmd - (mapconcat 'identity files " ")) t) + (mapconcat #'identity files " ")) t) (message (or message (format "Added %d files as %s" (length files) @@ -656,10 +660,10 @@ With prefix argument `C-u', add as read-only." With prefix argument `C-u', add as read-only." (interactive "P") (let* ((files (mapcar (lambda (buffer) - (with-current-buffer buffer - (when buffer-file-name - (expand-file-name buffer-file-name)))) - (mapcar 'window-buffer (window-list)))) + (with-current-buffer buffer + (when buffer-file-name + (expand-file-name buffer-file-name)))) + (mapcar #'window-buffer (window-list)))) (filtered-files (delq nil files))) (aidermacs--add-files-helper filtered-files read-only))) @@ -890,7 +894,7 @@ Returns t if the file matches any of the patterns in (let ((base-name (file-name-nondirectory filename))) (member base-name aidermacs-auto-mode-files)))) -(add-hook 'find-file-hook +(add-hook #'find-file-hook (lambda () (when (and buffer-file-name (aidermacs--should-enable-minor-mode-p buffer-file-name))