|
32 | 32 | (require 'ring)
|
33 | 33 | (require 'flymake)
|
34 | 34 | (require 'shell-maker)
|
| 35 | +(require 'transient) |
35 | 36 |
|
36 | 37 | (declare-function chatgpt-shell-previous-source-block "chatgpt-shell")
|
37 | 38 | (declare-function chatgpt-shell-next-source-block "chatgpt-shell")
|
|
50 | 51 | (declare-function chatgpt-shell--pretty-smerge-insert "chatgpt-shell")
|
51 | 52 | (declare-function chatgpt-shell-markdown-block-at-point "chatgpt-shell")
|
52 | 53 | (declare-function chatgpt-shell-view-block-at-point "chatgpt-shell")
|
| 54 | +(declare-function chatgpt-shell-copy-block-at-point "chatgpt-shell") |
| 55 | + |
| 56 | +(defcustom chatgpt-shell-compose-auto-transient t |
| 57 | + "When non-nil automatically display transient menu post compose submission." |
| 58 | + :type 'boolean |
| 59 | + :group 'chatgpt-shell) |
53 | 60 |
|
54 | 61 | (defvar-local chatgpt-shell-prompt-compose--exit-on-submit nil
|
55 | 62 | "Whether or not compose buffer should close after submission.
|
@@ -109,6 +116,27 @@ t if invoked from a transient frame (quitting closes the frame).")
|
109 | 116 | map)
|
110 | 117 | "Keymap for `chatgpt-shell-prompt-compose-view-mode'.")
|
111 | 118 |
|
| 119 | +(transient-define-prefix chatgpt-shell-prompt-compose-transient () |
| 120 | + "ChatGPT Shell Compose Transient." |
| 121 | + [["Navigation" |
| 122 | + ("n" "Next item" chatgpt-shell-prompt-compose-next-item :transient t) |
| 123 | + ("p" "Previous item" chatgpt-shell-prompt-compose-previous-item :transient t) |
| 124 | + ("f" "Next interaction" chatgpt-shell-prompt-compose-next-interaction :transient t) |
| 125 | + ("b" "Previous interaction" chatgpt-shell-prompt-compose-previous-interaction :transient t) |
| 126 | + ("o" "View other shell buffer" chatgpt-shell-prompt-compose-other-buffer)] |
| 127 | + ["Prompts" |
| 128 | + ("g" "Retry" chatgpt-shell-prompt-compose-retry) |
| 129 | + ("r" "Reply with followup" chatgpt-shell-prompt-compose-reply) |
| 130 | + ("m" "Request more" chatgpt-shell-prompt-compose-request-more) |
| 131 | + ("e" "Request entire snippet" chatgpt-shell-prompt-compose-request-entire-snippet)] |
| 132 | + ["Blocks" |
| 133 | + ("v" "View block at point" chatgpt-shell-view-block-at-point) |
| 134 | + ("i" "Insert block at point" chatgpt-shell-prompt-compose-insert-block-at-point) |
| 135 | + ("w" "Copy block at point" chatgpt-shell-copy-block-at-point) |
| 136 | + ("C-c C-c" "Execute block at point" chatgpt-shell-execute-block-action-at-point)] |
| 137 | + ["Quit" |
| 138 | + ("q" "Quit shell compose buffer" chatgpt-shell-prompt-compose-quit-and-close-frame)]]) |
| 139 | + |
112 | 140 | (define-minor-mode chatgpt-shell-prompt-compose-view-mode
|
113 | 141 | "Like `view-mode`, but extended for ChatGPT Compose."
|
114 | 142 | :lighter " ChatGPT view"
|
@@ -366,7 +394,9 @@ Optionally set its PROMPT."
|
366 | 394 | (lambda (_input _output _success)
|
367 | 395 | (with-current-buffer (chatgpt-shell-prompt-compose-buffer)
|
368 | 396 | (let ((inhibit-read-only t))
|
369 |
| - (chatgpt-shell--put-source-block-overlays)))) |
| 397 | + (chatgpt-shell--put-source-block-overlays))) |
| 398 | + (when chatgpt-shell-compose-auto-transient |
| 399 | + (chatgpt-shell-prompt-compose-transient))) |
370 | 400 | 'inline))
|
371 | 401 | ;; Point should go to beginning of response after submission.
|
372 | 402 | (goto-char (point-min))
|
|
0 commit comments