branch: elpa/aidermacs commit 2235d0379a14d070b2632041cda0597b715544f9 Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
Fix more linting Signed-off-by: Mingde (Matthew) Zeng <matthew...@posteo.net> --- aidermacs-backend-comint.el | 9 ++++++++- aidermacs-backend-vterm.el | 9 +++------ aidermacs.el | 30 +++++++++++++++--------------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/aidermacs-backend-comint.el b/aidermacs-backend-comint.el index 4446d5997b..64a7512eb9 100644 --- a/aidermacs-backend-comint.el +++ b/aidermacs-backend-comint.el @@ -31,6 +31,11 @@ (declare-function aidermacs--show-ediff-for-edited-files "aidermacs") (declare-function aidermacs--detect-edited-files "aidermacs") (declare-function aidermacs--process-message-if-multi-line "aidermacs" (str)) +(declare-function aidermacs--parse-output-for-files "aidermacs-backends" (output)) +(declare-function aidermacs--store-output "aidermacs-backends" (output)) +(declare-function aidermacs--is-aidermacs-buffer-p "aidermacs-backends" (&optional buffer)) + +(defvar aidermacs--last-command) (defgroup aidermacs-backend-comint nil "Comint backend for Aidermacs." @@ -45,6 +50,8 @@ :type '(alist :key-type (string :tag "Language Name/Alias") :value-type (string :tag "Mode Name (without -mode)"))) +;; FIXME: Hmm... seems to use standard diff3 markers. Maybe some code ++;; in `smerge-mode.el' could be (re)used? (defconst aidermacs-search-marker "<<<<<<< SEARCH") (defconst aidermacs-diff-marker "=======") (defconst aidermacs-replace-marker ">>>>>>> REPLACE") @@ -67,7 +74,7 @@ This allows for multi-line input without sending the command." "Face for commands sent to aidermacs buffer.") (defface aidermacs-search-replace-block - '((t :inherit 'diff-refine-added :bold t)) + '((t :inherit diff-refine-added :bold t)) "Face for search/replace block content.") (defvar aidermacs-font-lock-keywords diff --git a/aidermacs-backend-vterm.el b/aidermacs-backend-vterm.el index 697846c507..5f059499f6 100644 --- a/aidermacs-backend-vterm.el +++ b/aidermacs-backend-vterm.el @@ -47,9 +47,10 @@ (declare-function aidermacs--is-aidermacs-buffer-p "aidermacs") (declare-function aidermacs-get-buffer-name "aidermacs") -;; useful because we want to override "RET" key for evil mode insert state (declare-function evil-define-minor-mode-key "evil-core") +(defvar aidermacs-prompt-regexp) + (defgroup aidermacs-backend-vterm nil "VTerm backend for Aidermacs." :group 'aidermacs) @@ -60,17 +61,13 @@ (defvar-local aidermacs--vterm-last-check-point nil "Store the last position checked in the vterm buffer.") - (defvar-local aidermacs-vterm-check-interval 0.7 "Interval in seconds between checks for command completion in vterm.") - (defcustom aidermacs-vterm-multiline-newline-key "S-<return>" "Key binding to enter a newline without sending in vterm." :type 'string) -(defvar aidermacs-prompt-regexp) - (defun aidermacs--vterm-check-finish-sequence-repeated (proc orig-filter start-point) "Check for the finish sequence in PROC's buffer. PROC is the process to check. ORIG-FILTER is the original process filter. @@ -149,7 +146,7 @@ after each output chunk, reducing the need for timers." (defun aidermacs--maybe-cancel-active-timer (&optional buffer) "Cancel the active timer if it exists. Use BUFFER if provided, otherwise retrieve it from `aidermacs-get-buffer-name'." - (when-let ((buf (get-buffer (or buffer (aidermacs-get-buffer-name))))) + (when-let* ((buf (get-buffer (or buffer (aidermacs-get-buffer-name))))) (with-current-buffer buf (when (timerp aidermacs--vterm-active-timer) (cancel-timer aidermacs--vterm-active-timer) diff --git a/aidermacs.el b/aidermacs.el index 36575085f2..0a81eff179 100644 --- a/aidermacs.el +++ b/aidermacs.el @@ -86,7 +86,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-let ((proj (project-current))) + (or (when-let* ((proj (project-current))) (project-root proj)) (vc-git-root default-directory) (when buffer-file-name @@ -381,7 +381,7 @@ Returns a list of files that have been modified according to the output." ;; Case 1: Find "Applied edit to" lines (while (search-forward "Applied edit to" nil t) (beginning-of-line) - (when-let ((file (and (looking-at ".*Applied edit to \\(\\./\\)?\\([^[:space:]]+\\)") + (when-let* ((file (and (looking-at ".*Applied edit to \\(\\./\\)?\\([^[:space:]]+\\)") (match-string-no-properties 2)))) (push file edited-files)) (forward-line 1)) @@ -724,7 +724,7 @@ Use highlighted region as context unless IGNORE-CONTEXT is set to non-nil." (let* ((region-text (when (and (use-region-p) (not ignore-context)) (buffer-substring-no-properties (region-beginning) (region-end)))) (context (when region-text - (format " regarding this section:\n```\n%s\n```\n" region-text))) + (format " in %s regarding this section:\n```\n%s\n```\n" (buffer-name) region-text))) (user-command (read-string (concat command " " prompt-prefix context (when guide (format " (%s)" guide)) ": ")))) (concat command (and (not (string-empty-p user-command)) @@ -733,7 +733,7 @@ Use highlighted region as context unless IGNORE-CONTEXT is set to non-nil." (defun aidermacs-direct-change () "Prompt the user for an input and send it to aidemracs prefixed with \"/code \"." (interactive) - (when-let ((command (aidermacs--form-prompt "/code" "Make this change" "will edit file"))) + (when-let* ((command (aidermacs--form-prompt "/code" "Make this change" "will edit file"))) (aidermacs--ensure-current-file-tracked) (aidermacs--send-command command))) @@ -743,7 +743,7 @@ If a region is active, include the region text in the question. If cursor is inside a function, include the function name as context. If called from the aidermacs buffer, use general question instead." (interactive) - (when-let ((command (aidermacs--form-prompt "/ask" "Propose a solution" "won't edit file"))) + (when-let* ((command (aidermacs--form-prompt "/ask" "Propose a solution" "won't edit file"))) (aidermacs--ensure-current-file-tracked) (aidermacs--send-command command))) @@ -752,26 +752,26 @@ If called from the aidermacs buffer, use general question instead." If region is active, inspect that region. If point is in a function, inspect that function." (interactive) - (when-let ((command (aidermacs--form-prompt "/architect" "Design a solution" "confirm before edit"))) + (when-let* ((command (aidermacs--form-prompt "/architect" "Design a solution" "confirm before edit"))) (aidermacs--ensure-current-file-tracked) (aidermacs--send-command command))) (defun aidermacs-question-general () "Prompt the user for a general question without code context." (interactive) - (when-let ((command (aidermacs--form-prompt "/ask" nil "empty for ask mode" t))) + (when-let* ((command (aidermacs--form-prompt "/ask" nil "empty for ask mode" t))) (aidermacs--send-command command))) (defun aidermacs-help () "Prompt the user for an input prefixed with \"/help \"." (interactive) - (when-let ((command (aidermacs--form-prompt "/help" nil "question how to use aider, empty for all commands" t))) + (when-let* ((command (aidermacs--form-prompt "/help" nil "question how to use aider, empty for all commands" t))) (aidermacs--send-command command))) (defun aidermacs-debug-exception () "Prompt the user for an input and send it to aidemracs prefixed with \"/debug \"." (interactive) - (when-let ((command (aidermacs--form-prompt "/ask" "Debug exception"))) + (when-let* ((command (aidermacs--form-prompt "/ask" "Debug exception"))) (aidermacs--send-command command))) (defun aidermacs-accept-change () @@ -977,7 +977,7 @@ Otherwise: "Report the current test failure to aidermacs and ask it to fix the code. This function assumes the cursor is on or inside a test function." (interactive) - (if-let ((test-function-name (which-function))) + (if-let* ((test-function-name (which-function))) (let* ((initial-input (format "The test '%s' is failing. Please analyze and fix the code to make the test pass. Don't break any other test" test-function-name)) (command (aidermacs--form-prompt "/architect" initial-input))) @@ -1051,7 +1051,7 @@ Otherwise implement TODOs for the entire current file." (message "Current buffer is not visiting a file.") (let* ((current-line (string-trim (thing-at-point 'line t))) (is-comment (aidermacs--is-comment-line current-line))) - (when-let ((command (aidermacs--form-prompt + (when-let* ((command (aidermacs--form-prompt "/architect" (concat "Please implement the TODO items." (and is-comment @@ -1124,10 +1124,10 @@ sample prompt." ;;;###autoload (defvar aidermacs-minor-mode-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-c C-n") 'aidermacs-send-line-or-region) - (define-key map (kbd "C-<return>") 'aidermacs-send-line-or-region) - (define-key map (kbd "C-c C-c") 'aidermacs-send-block-or-region) - (define-key map (kbd "C-c C-z") 'aidermacs-switch-to-buffer) + (define-key map (kbd "C-c C-n") #'aidermacs-send-line-or-region) + (define-key map (kbd "C-<return>") #'aidermacs-send-line-or-region) + (define-key map (kbd "C-c C-c") #'aidermacs-send-block-or-region) + (define-key map (kbd "C-c C-z") #'aidermacs-switch-to-buffer) map) "Keymap for `aidermacs-minor-mode'.")