From d6ef79f6213778266f7e6e57edbe69274ff94705 Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Thu, 11 Jan 2024 17:41:09 -0800 Subject: [PATCH] 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. --- gptel-transient.el | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gptel-transient.el b/gptel-transient.el index f1c7e1b..75c70a8 100644 --- a/gptel-transient.el +++ b/gptel-transient.el @@ -166,6 +166,7 @@ which see." 'gptel-system-prompt (cl-loop for (type . prompt) in gptel-directives with taken + with width = (window-width) for name = (symbol-name type) for key = (let ((idx 0) pos) @@ -179,11 +180,21 @@ which see." ;; 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)) - :transient 'transient--do-return) + 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) + (message "Directive: %s" ,prompt) + (setq gptel--system-message ,prompt)) + :transient 'transient--do-return) into prompt-suffixes finally return (nconc