gptel-transient: Exit gptel-system-prompt after selection (#96)

gptel-transient.el (gptel-menu, gptel-system-prompt--setup): Exit
the system prompt interface when picking a prompt. This saves the
user a `C-g`.
This commit is contained in:
Tianshu Wang 2023-08-14 02:08:47 +08:00 committed by GitHub
parent 6e4d95a70a
commit f0b18c5f8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,7 +114,7 @@ which see."
(lambda () (format "Directive: %s" (lambda () (format "Directive: %s"
(truncate-string-to-width (truncate-string-to-width
gptel--system-message (max (- (window-width) 14) 20) nil nil t))) gptel--system-message (max (- (window-width) 14) 20) nil nil t)))
("h" "Set directives for chat" gptel-system-prompt)] ("h" "Set directives for chat" gptel-system-prompt :transient t)]
[["Session Parameters" [["Session Parameters"
(gptel--infix-max-tokens) (gptel--infix-max-tokens)
(gptel--infix-num-messages-to-send) (gptel--infix-num-messages-to-send)
@ -173,15 +173,14 @@ which see."
collect (list (key-description key) (capitalize name) collect (list (key-description key) (capitalize name)
`(lambda () (interactive) `(lambda () (interactive)
(message "Directive: %s" ,prompt) (message "Directive: %s" ,prompt)
(setq gptel--system-message ,prompt)) (setq gptel--system-message ,prompt)))
:transient t)
into prompt-suffixes into prompt-suffixes
finally return finally return
(nconc (nconc
(list (list 'gptel--suffix-system-message)) (list (list 'gptel--suffix-system-message))
prompt-suffixes prompt-suffixes
(list (list "SPC" "Pick crowdsourced prompt" (list (list "SPC" "Pick crowdsourced prompt"
'gptel--read-crowdsourced-prompt)))))) 'gptel--read-crowdsourced-prompt :transient nil))))))
(transient-define-prefix gptel-system-prompt () (transient-define-prefix gptel-system-prompt ()
"Change the system prompt to send ChatGPT. "Change the system prompt to send ChatGPT.