branch: elpa/aidermacs commit 13d5256e6c6d5d7b834133adcaeb694a5e7d8556 Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
Improve output parsing --- aidermacs-backend-comint.el | 3 ++- aidermacs-backend-vterm.el | 29 ++++++++++++++++------------- aidermacs-backends.el | 1 + 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/aidermacs-backend-comint.el b/aidermacs-backend-comint.el index 568fa1bfa5..0b2a87e965 100644 --- a/aidermacs-backend-comint.el +++ b/aidermacs-backend-comint.el @@ -274,7 +274,8 @@ PROC is the process to send to. STRING is the command to send." (aidermacs-reset-font-lock-state) ;; Store the command for tracking in the correct buffer (with-current-buffer (process-buffer proc) - (unless (member string '("" "y" "n" "d" "yes" "no")) + (if (member string '("" "y" "n" "d" "yes" "no")) + (aidermacs--parse-output-for-files aidermacs--comint-output-temp) (setq aidermacs--last-command string) ;; Always prepare for potential edits (aidermacs--prepare-for-code-edit))) diff --git a/aidermacs-backend-vterm.el b/aidermacs-backend-vterm.el index 767a933cfc..6cfcf33788 100644 --- a/aidermacs-backend-vterm.el +++ b/aidermacs-backend-vterm.el @@ -53,7 +53,7 @@ "Store the last position checked in the vterm buffer.") -(defvar-local aidermacs-vterm-check-interval 0.5 +(defvar-local aidermacs-vterm-check-interval 0.7 "Interval in seconds between checks for command completion in vterm.") @@ -99,22 +99,25 @@ If the finish sequence is detected, store the output via (point-min))) ;; Only get the prompt line, not the whole sequence (limit to 200 chars) (prompt-line-end (min (+ seq-start 200) (point-max))) - (prompt-line (buffer-substring-no-properties seq-start prompt-line-end))) + (prompt-line (buffer-substring-no-properties seq-start prompt-line-end)) + (output (buffer-substring-no-properties start-point seq-start))) + + ;; Parse output for files + (aidermacs--parse-output-for-files output) ;; If we found a shell prompt indicating output finished (when (string-match-p expected prompt-line) - (let ((output (buffer-substring-no-properties start-point seq-start))) - (setq-local aidermacs--vterm-processing-command nil) - (aidermacs--store-output (string-trim output)) - (let ((edited-files (aidermacs--detect-edited-files))) + (setq-local aidermacs--vterm-processing-command nil) + (aidermacs--store-output (string-trim output)) + (let ((edited-files (aidermacs--detect-edited-files))) ;; Check if any files were edited and show ediff if needed - (if edited-files - (aidermacs--show-ediff-for-edited-files edited-files) - (aidermacs--cleanup-temp-buffers)) - ;; Restore the original process filter now that we've finished processing - ;; this command's output. This returns vterm to its normal behavior. - (set-process-filter proc orig-filter) - (aidermacs--maybe-cancel-active-timer (process-buffer proc))))))))))) + (if edited-files + (aidermacs--show-ediff-for-edited-files edited-files) + (aidermacs--cleanup-temp-buffers)) + ;; Restore the original process filter now that we've finished processing + ;; this command's output. This returns vterm to its normal behavior. + (set-process-filter proc orig-filter) + (aidermacs--maybe-cancel-active-timer (process-buffer proc)))))))))) (defvar-local aidermacs--vterm-processing-command nil "Flag to indicate if we're currently processing a command.") diff --git a/aidermacs-backends.el b/aidermacs-backends.el index 6563c66747..4a4879e1fb 100644 --- a/aidermacs-backends.el +++ b/aidermacs-backends.el @@ -29,6 +29,7 @@ (declare-function aidermacs-run-vterm "aidermacs-backend-vterm" (program args buffer-name)) (declare-function aidermacs--send-command-vterm "aidermacs-backend-vterm" (buffer command)) (declare-function aidermacs-project-root "aidermacs" ()) +(declare-function aidermacs--prepare-for-code-edit "aidermacs" ()) (declare-function aidermacs--get-files-in-session "aidermacs" (callback)) (defgroup aidermacs-backends nil