From d77c8f37c56515bf53213f3e32a5ed99d6041a6d Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Mon, 3 Apr 2023 14:06:43 -0700 Subject: [PATCH] gptel: Improve header-line-format * gptel.el (gptel-mode): Show the model and context in the header line. --- gptel.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gptel.el b/gptel.el index 7f634b2..fad1194 100644 --- a/gptel.el +++ b/gptel.el @@ -243,7 +243,29 @@ By default, \"openai.com\" is used as HOST and \"apikey\" as USER." header-line-format (list (concat (propertize " " 'display '(space :align-to 0)) (format "%s" (buffer-name))) - (propertize " Ready" 'face 'success))) + (propertize " Ready" 'face 'success) + '(:eval + (let* ((l1 (length gptel-model)) + (num-exchanges + (if gptel--num-messages-to-send + (format "[Send: %s exchanges]" gptel--num-messages-to-send) + "[Send: buffer]")) + (l2 (length num-exchanges))) + (concat + (propertize + " " 'display `(space :align-to ,(max 1 (- (window-width) (+ 2 l1 l2))))) + (propertize + (button-buttonize num-exchanges + (lambda (&rest _) (gptel-send-menu))) + 'mouse-face 'highlight + 'help-echo + "Number of past exchanges to include with each request") + " " + (propertize + (button-buttonize (concat "[" gptel-model "]") + (lambda (&rest _) (gptel-send-menu))) + 'mouse-face 'highlight + 'help-echo "OpenAI GPT model in use")))))) (setq header-line-format gptel--old-header-line))) ;; TODO: Handle read-only buffers. Should we spawn a new buffer automatically?