gptel: Fix header-line-format update

* gptel.el (gptel--update-header-line): Only fix the
`header-line-format' when in gptel-mode.
This commit is contained in:
Karthik Chikmagalur 2023-04-04 22:20:06 -07:00
parent d77c8f37c5
commit 936c27e28b

View file

@ -215,13 +215,6 @@ By default, \"openai.com\" is used as HOST and \"apikey\" as USER."
((pred functionp) (funcall gptel-api-key)) ((pred functionp) (funcall gptel-api-key))
(_ (error "`gptel-api-key' is not set")))) (_ (error "`gptel-api-key' is not set"))))
(defun gptel--update-header-line (msg face)
"Update header line with status MSG in FACE."
(and header-line-format
(setf (nth 1 header-line-format)
(propertize msg 'face face))
(force-mode-line-update)))
(defsubst gptel--numberize (val) (defsubst gptel--numberize (val)
"Ensure VAL is a number." "Ensure VAL is a number."
(if (stringp val) (string-to-number val) val)) (if (stringp val) (string-to-number val) val))
@ -268,6 +261,13 @@ By default, \"openai.com\" is used as HOST and \"apikey\" as USER."
'help-echo "OpenAI GPT model in use")))))) 'help-echo "OpenAI GPT model in use"))))))
(setq header-line-format gptel--old-header-line))) (setq header-line-format gptel--old-header-line)))
(defun gptel--update-header-line (msg face)
"Update header line with status MSG in FACE."
(and gptel-mode (consp header-line-format)
(setf (nth 1 header-line-format)
(propertize msg 'face face))
(force-mode-line-update)))
;; TODO: Handle read-only buffers. Should we spawn a new buffer automatically? ;; TODO: Handle read-only buffers. Should we spawn a new buffer automatically?
;; TODO: Handle multiple requests(#15). (Only one request from one buffer at a time?) ;; TODO: Handle multiple requests(#15). (Only one request from one buffer at a time?)
;; TODO: Since we capture a marker for the insertion location, `gptel-buffer' no ;; TODO: Since we capture a marker for the insertion location, `gptel-buffer' no