emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/aidermacs b105ca5e4a 257/466: feat: Add output history dis


From: ELPA Syncer
Subject: [nongnu] elpa/aidermacs b105ca5e4a 257/466: feat: Add output history display and last output copy functions
Date: Sat, 15 Mar 2025 19:15:31 -0400 (EDT)

branch: elpa/aidermacs
commit b105ca5e4a8979fff98e5238b6a9d59f5199f778
Author: Mingde (Matthew) Zeng <matthewzmd@posteo.net>
Commit: Mingde (Matthew) Zeng <matthewzmd@posteo.net>

    feat: Add output history display and last output copy functions
    
    refactor: Remove local variable scoping for aidermacs output history 
variables
---
 aidermacs-backends.el | 31 ++++++++++++++++++++++++++++---
 aidermacs.el          |  3 +++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/aidermacs-backends.el b/aidermacs-backends.el
index 1c10c30a7f..b320aff6da 100644
--- a/aidermacs-backends.el
+++ b/aidermacs-backends.el
@@ -32,14 +32,14 @@ of using a comint process."
   :type 'integer
   :group 'aidermacs-output)
 
-(defvar-local aidermacs--output-history nil
+(defvar aidermacs--output-history nil
   "List to store aidermacs output history.
 Each entry is a cons cell (timestamp . output-text).")
 
-(defvar-local aidermacs--last-command nil
+(defvar aidermacs--last-command nil
   "Store the last command sent to aidermacs.")
 
-(defvar-local aidermacs--current-output nil
+(defvar aidermacs--current-output nil
   "Accumulator for current output being captured.")
 
 (defun aidermacs-get-output-history (&optional limit)
@@ -59,6 +59,31 @@ 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 ca362976b6..240dfb2572 100644
--- a/aidermacs.el
+++ b/aidermacs.el
@@ -65,6 +65,7 @@ This is the file name without path."
 
 (defvar aidermacs-read-string-history nil
   "History list for aidermacs read string inputs.")
+
 (if (bound-and-true-p savehist-loaded)
     (add-to-list 'savehist-additional-variables 'aidermacs-read-string-history)
   (add-hook 'savehist-mode-hook
@@ -167,6 +168,8 @@ Affects the system message too.")
     ("Q" "Ask General Question"         aidermacs-general-question)
     ("p" "Open Prompt File"           aidermacs-open-prompt-file)
     ("h" "Help"                       aidermacs-help)
+    ("H" "Show Output History"        aidermacs-show-output-history)
+    ("C" "Copy Last Output"           aidermacs-copy-last-output)
     ]
    ])
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]