gptel-transient: Set suffix-state explicitly for directives
* gptel-transient.el (gptel-system-prompt--setup): In Transient v0.5 and up, some suffixes defined dynamically using `gptel-system-prompt--setup' are being treated as infix commands, see #140. Set the `:transient' key of these suffixes to `transient--do-return' explicitly to avoid this problem. TODO: This fix will work but it's not clear why this is needed, this needs some investigation.
This commit is contained in:
parent
8d3e08faa8
commit
c3ca4fd0a0
1 changed files with 9 additions and 2 deletions
|
@ -171,17 +171,24 @@ which see."
|
|||
(cl-incf idx))
|
||||
(push pos taken)
|
||||
pos)
|
||||
;; The explicit declaration ":transient transient--do-return" here
|
||||
;; appears to be required for Transient v0.5 and up. Without it, these
|
||||
;; are treated as suffixes when invoking `gptel-system-prompt' directly,
|
||||
;; and infixes when going through `gptel-menu'.
|
||||
;; TODO: Raise an issue with Transient.
|
||||
collect (list (key-description key) (capitalize name)
|
||||
`(lambda () (interactive)
|
||||
(message "Directive: %s" ,prompt)
|
||||
(setq gptel--system-message ,prompt)))
|
||||
(setq gptel--system-message ,prompt))
|
||||
:transient 'transient--do-return)
|
||||
into prompt-suffixes
|
||||
finally return
|
||||
(nconc
|
||||
(list (list 'gptel--suffix-system-message))
|
||||
prompt-suffixes
|
||||
(list (list "SPC" "Pick crowdsourced prompt"
|
||||
'gptel--read-crowdsourced-prompt :transient nil))))))
|
||||
'gptel--read-crowdsourced-prompt
|
||||
:transient nil))))))
|
||||
|
||||
(transient-define-prefix gptel-system-prompt ()
|
||||
"Change the system prompt to send ChatGPT.
|
||||
|
|
Loading…
Add table
Reference in a new issue