gptel-transient: Show descriptions of directives

* gptel-transient.el (gptel-system-prompt--setup): (Tentative
change) Show descriptions of directives next to the keys when
picking a directive from the system-prompt menu.
This commit is contained in:
Karthik Chikmagalur 2024-01-11 17:41:09 -08:00
parent 7c2e342f35
commit d6ef79f621

View file

@ -166,6 +166,7 @@ which see."
'gptel-system-prompt 'gptel-system-prompt
(cl-loop for (type . prompt) in gptel-directives (cl-loop for (type . prompt) in gptel-directives
with taken with taken
with width = (window-width)
for name = (symbol-name type) for name = (symbol-name type)
for key = for key =
(let ((idx 0) pos) (let ((idx 0) pos)
@ -179,7 +180,17 @@ which see."
;; are treated as suffixes when invoking `gptel-system-prompt' directly, ;; are treated as suffixes when invoking `gptel-system-prompt' directly,
;; and infixes when going through `gptel-menu'. ;; and infixes when going through `gptel-menu'.
;; TODO: Raise an issue with Transient. ;; TODO: Raise an issue with Transient.
collect (list (key-description key) (capitalize name) collect (list (key-description key)
(concat (capitalize name) " "
(propertize " " 'display '(space :align-to 20))
(propertize
(concat
"("
(string-replace
"\n" " "
(truncate-string-to-width prompt (- width 30) nil nil t))
")")
'face 'shadow))
`(lambda () (interactive) `(lambda () (interactive)
(message "Directive: %s" ,prompt) (message "Directive: %s" ,prompt)
(setq gptel--system-message ,prompt)) (setq gptel--system-message ,prompt))