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

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

[nongnu] elpa/aidermacs cbb9bada03 6/6: Add aidermacs-common-prompts and


From: ELPA Syncer
Subject: [nongnu] elpa/aidermacs cbb9bada03 6/6: Add aidermacs-common-prompts and history completion
Date: Sat, 22 Mar 2025 16:01:03 -0400 (EDT)

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

    Add aidermacs-common-prompts and history completion
    
    Inspired from tninja/aider.el#111
    
    Signed-off-by: Mingde (Matthew) Zeng <matthewzmd@posteo.net>
---
 README.md    | 13 +++++++++++++
 aidermacs.el | 30 ++++++++++++++++++++++++++----
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 37bf16b4c5..c8c8645a49 100644
--- a/README.md
+++ b/README.md
@@ -248,6 +248,19 @@ Example usage:
 M-x aidermacs-transient-menu
 ```
 
+### Prompt Selection and History
+
+Aidermacs makes it easy to reuse prompts through:
+
+1. **Prompt History** - Your previously used prompts are saved and can be 
quickly selected
+2. **Common Prompts** - A curated list of frequently used prompts for common 
tasks defined in `aidermacs-common-prompts`:
+
+When entering a prompt, you can:
+- Select from your history or common prompts using completion
+- Still type custom prompts when needed
+
+The prompt history and common prompts are available across all sessions.
+
 ### Diff and Change Review
 
 Control whether to show diffs for AI-generated changes with 
`aidermacs-show-diff-after-change`:
diff --git a/aidermacs.el b/aidermacs.el
index 9cac2ac379..cd42f9b91f 100644
--- a/aidermacs.el
+++ b/aidermacs.el
@@ -91,6 +91,19 @@ When nil, require explicit confirmation before applying 
changes."
 (defvar aidermacs--read-string-history nil
   "History list for aidermacs read string inputs.")
 
+(defcustom aidermacs-common-prompts
+  '("What does this code do? Explain the logic step by step"
+    "Explain the overall architecture of this codebase"
+    "Simplify this code while preserving functionality"
+    "Extract this logic into separate helper functions"
+    "Optimize this code for better performance"
+    "Are there any edge cases not handled in this code?"
+    "Refactor to reduce complexity and improve readability"
+    "How could we make this code more maintainable?")
+  "List of common prompts to use with aidermacs.
+These will be available for selection when using aidermacs commands."
+  :type '(repeat string))
+
 (defvar aidermacs--cached-version nil
   "Cached aider version to avoid repeated version checks.")
 
@@ -552,10 +565,19 @@ Use highlighted region as context unless IGNORE-CONTEXT 
is set to non-nil."
                         (buffer-substring-no-properties (region-beginning) 
(region-end))))
          (context (when 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)) ": ")
-                                    nil
-                                    'aidermacs--read-string-history)))
+         ;; Create completion table from common prompts and history
+         (completion-candidates
+          (delete-dups (append aidermacs-common-prompts
+                               aidermacs--read-string-history)))
+         ;; Read user input with completion
+         (user-command (completing-read
+                        (concat command " " prompt-prefix context
+                                (when guide (format " (%s)" guide)) ": ")
+                        completion-candidates nil nil nil
+                        'aidermacs--read-string-history)))
+    ;; Add to history if not already there, removing any duplicates
+    (setq aidermacs--read-string-history
+          (delete-dups (cons user-command aidermacs--read-string-history)))
     (concat command (and (not (string-empty-p user-command))
                          (concat " " prompt-prefix context ": " 
user-command)))))
 



reply via email to

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