gptel: Tweak header line format

Add a status indicator to the header line.
This commit is contained in:
Karthik Chikmagalur 2023-03-06 00:58:32 -08:00
parent a5fe30312f
commit 33d8434f3e

View file

@ -81,6 +81,8 @@ key (more secure)."
(point-max))) (point-max)))
(push (set-marker (make-marker) (point-max)) (push (set-marker (make-marker) (point-max))
gptel--prompt-markers)) gptel--prompt-markers))
(setf (nth 1 header-line-format)
(propertize " Waiting..." 'face 'warning))
(let* ((gptel-buffer (current-buffer)) (let* ((gptel-buffer (current-buffer))
(full-prompt (full-prompt
(save-excursion (save-excursion
@ -113,7 +115,9 @@ key (more secure)."
(insert content-str) (insert content-str)
(push (set-marker (make-marker) (point)) (push (set-marker (make-marker) (point))
gptel--prompt-markers) gptel--prompt-markers)
(insert "\n\n" gptel-prompt-string)))) (insert "\n\n" gptel-prompt-string)
(setf (nth 1 header-line-format)
(propertize " Ready" 'face 'success)))))
(kill-buffer response-buffer)))) (kill-buffer response-buffer))))
(aio-defun gptel-get-response (prompts) (aio-defun gptel-get-response (prompts)
@ -178,9 +182,11 @@ Ask for API-KEY if `gptel-api-key' is unset."
(pop-to-buffer (current-buffer)) (pop-to-buffer (current-buffer))
(goto-char (point-max)) (goto-char (point-max))
(skip-chars-backward "\t\r\n") (skip-chars-backward "\t\r\n")
(setq header-line-format (or header-line-format
(concat (propertize " " 'display '(space :align-to 0)) (setq header-line-format
(format "ChatGPT session (%s)" (buffer-name)))) (list (concat (propertize " " 'display '(space :align-to 0))
(format "%s" (buffer-name)))
(propertize " Ready" 'face 'success))))
(message "Send your query with %s!" (message "Send your query with %s!"
(substitute-command-keys "\\[gptel-send]")))) (substitute-command-keys "\\[gptel-send]"))))