branch: elpa/aidermacs
commit 6ae6becbfb5ed279343793640e8eaf5176525e69
Author: Mingde (Matthew) Zeng <[email protected]>
Commit: Mingde (Matthew) Zeng <[email protected]>
Simplify UI to ask question and explain this code
---
README.md | 1 -
aidermacs-doom.el | 5 ++---
aidermacs.el | 41 +++++++++++++++--------------------------
3 files changed, 17 insertions(+), 30 deletions(-)
diff --git a/README.md b/README.md
index 00e3f5423a..ac3966df81 100644
--- a/README.md
+++ b/README.md
@@ -274,7 +274,6 @@ The main interface to Aidermacs is through its transient
menu system. Here's a b
##### Understanding
- `m`: Show Last Commit
-- `Q`: Ask General Question
- `q`: Ask Question
- `e`: Explain This Code
- `p`: Explain This Symbol
diff --git a/aidermacs-doom.el b/aidermacs-doom.el
index 2400925a09..f62ba3a11f 100644
--- a/aidermacs-doom.el
+++ b/aidermacs-doom.el
@@ -61,9 +61,8 @@
;; Understanding
:desc "Show Last Commit" "m"
#'aidermacs-magit-show-last-commit
- :desc "Ask General Question" "Q"
#'aidermacs-ask-question-general
- :desc "Ask Question" "q" #'aidermacs-ask-question-context
- :desc "Explain This Code" "e"
#'aidermacs-function-or-region-explain
+ :desc "Ask Question" "q" #'aidermacs-ask-question
+ :desc "Explain This Code" "e" #'aidermacs-explain-this-code
:desc "Explain This Symbol" "p"
#'aidermacs-explain-symbol-under-point
;; Others
diff --git a/aidermacs.el b/aidermacs.el
index ed821ec8e3..311b3b3254 100644
--- a/aidermacs.el
+++ b/aidermacs.el
@@ -164,9 +164,8 @@ PROMPT is the text to display. INITIAL-INPUT is the
default value."
["Understanding"
("m" "Show Last Commit" aidermacs-magit-show-last-commit)
- ("Q" "Ask General Question" aidermacs-ask-question-general)
- ("q" "Ask Question" aidermacs-ask-question-context)
- ("e" "Explain This Code" aidermacs-function-or-region-explain)
+ ("q" "Ask Question" aidermacs-ask-question)
+ ("e" "Explain This Code" aidermacs-explain-this-code)
("p" "Explain This Symbol" aidermacs-explain-symbol-under-point)]
["Others"
@@ -496,24 +495,24 @@ Sends the \"/ls\" command and returns the list of files
via callback."
;;;###autoload
-(defun aidermacs-ask-question-context ()
- "Prompt the user for a question.
-If a region is active, append the region text to the question.
-If cursor is inside a function, include the function name as context."
+(defun aidermacs-explain-this-code ()
+ "Ask a question about the code at point or region.
+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)
;; Dispatch to general question if in aidermacs buffer
- (when (string= (buffer-name) (aidermacs-buffer-name))
- (call-interactively #'aidermacs-ask-question-general)
- (cl-return-from aidermacs-ask-question-context))
- (aidermacs-add-current-file)
- (when-let ((command (aidermacs--form-prompt "/ask" "Ask")))
- (aidermacs--send-command command t)))
+ (if (string= (buffer-name) (aidermacs-buffer-name))
+ (call-interactively #'aidermacs-ask-question)
+ (when-let ((command (aidermacs--form-prompt "/ask" "Question")))
+ (aidermacs-add-current-file)
+ (aidermacs--send-command command t))))
;;;###autoload
-(defun aidermacs-ask-question-general ()
- "Prompt the user for a general question prefixed with \"/ask \"."
+(defun aidermacs-ask-question ()
+ "Prompt the user for a general question without code context."
(interactive)
- (when-let ((command (aidermacs--form-prompt "/ask" "Ask question" t)))
+ (when-let ((command (aidermacs--form-prompt "/ask" "Question" t)))
(aidermacs--send-command command t)))
;;;###autoload
@@ -585,16 +584,6 @@ If point is in a function, refactor that function."
(aidermacs-add-current-file)
(aidermacs--send-command command t)))
-;;;###autoload
-(defun aidermacs-function-or-region-explain ()
- "Explain code at point or region.
-If region is active, explain that region.
-If point is in a function, explain that function."
- (interactive)
- (when-let ((command (aidermacs--form-prompt "/ask" "Explain")))
- (aidermacs-add-current-file)
- (aidermacs--send-command command t)))
-
;;;###autoload
(defun aidermacs-explain-symbol-under-point ()
"Ask aidermacs to explain symbol under point."