branch: elpa/aidermacs commit a24188313ae19da8475b37deea44ea972e1e7166 Author: Mingde (Matthew) Zeng <matthew...@posteo.net> Commit: Mingde (Matthew) Zeng <matthew...@posteo.net>
Improve aidermacs-show-output-history Signed-off-by: Mingde (Matthew) Zeng <matthew...@posteo.net> --- aidermacs-backends.el | 25 ------------------------- aidermacs.el | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/aidermacs-backends.el b/aidermacs-backends.el index b320aff6da..8742607ad4 100644 --- a/aidermacs-backends.el +++ b/aidermacs-backends.el @@ -59,31 +59,6 @@ Returns a list of (timestamp . output-text) pairs, most recent first." (interactive) (setq aidermacs--output-history nil)) - -(defun aidermacs-show-output-history () - "Display the AI output history in a new buffer." - (interactive) - (let ((buf (get-buffer-create "*aidermacs-history*")) - (history aidermacs--output-history)) ; Get history from current buffer - (with-current-buffer buf - (erase-buffer) - (display-line-numbers-mode 1) - (dolist (entry history) ; Use passed history - (let ((timestamp (format-time-string "%Y-%m-%d %H:%M:%S" (car entry))) - (output (cdr entry))) - (insert (format "=== %s ===\n%s\n\n" timestamp output)))) - (goto-char (point-min))) - (display-buffer buf))) - -(defun aidermacs-copy-last-output () - "Copy the most recent AI output to the kill ring." - (interactive) - (if-let ((last-output (cdr (aidermacs-get-last-output)))) - (progn - (kill-new last-output) - (message "Copied last AI output to kill ring")) - (message "No AI output available"))) - (defun aidermacs--store-output (output) "Store OUTPUT in the history with timestamp." (setq aidermacs--current-output output) diff --git a/aidermacs.el b/aidermacs.el index 91f2461053..33702ae74a 100644 --- a/aidermacs.el +++ b/aidermacs.el @@ -322,6 +322,38 @@ wrap it in {aidermacs\nstr\naidermacs}. Otherwise return STR unchanged." (let ((command (aidermacs-read-string "Enter code change requirement: "))) (aidermacs-send-command-with-prefix "/code " command))) +;;;###autoload +(defun aidermacs-show-output-history () + "Display the AI output history in a new buffer." + (interactive) + (let ((buf (get-buffer-create "*aidermacs-history*")) + (history aidermacs--output-history)) + (with-current-buffer buf + (org-mode) + (setq buffer-read-only nil) + (erase-buffer) + (display-line-numbers-mode 1) + (dolist (entry history) + (let ((timestamp (format-time-string "%Y-%m-%d %H:%M:%S" (car entry))) + (output (cdr entry))) + (insert (format "* %s\n#+BEGIN_SRC\n%s\n#+END_SRC\n" timestamp output)))) + (goto-char (point-min)) + (setq buffer-read-only t) + (local-set-key (kbd "q") 'kill-this-buffer) + (switch-to-buffer-other-frame buf)))) + +;;;###autoload +(defun aidermacs-copy-last-output () + "Copy the most recent AI output to the kill ring." + (interactive) + (if-let ((last-output (cdr (aidermacs-get-last-output)))) + (progn + (kill-new last-output) + (message "Copied last AI output to kill ring")) + (message "No AI output available"))) + + + ;; New function to get command from user and send it prefixed with "/ask " ;;;###autoload (defun aidermacs-ask-question ()