Emacs: Read gptel key from disk

This commit is contained in:
Joseph Ferano 2024-06-06 14:39:48 +07:00
parent 26ea89d625
commit 263a8bec1a

View File

@ -246,6 +246,7 @@ Finish up
mu4e-alert
dirvish
restclient
gptel
disaster
magit))
@ -2315,8 +2316,20 @@ These help speed eglot up apparently [[https://www.reddit.com/r/emacs/comments/1
#+begin_src emacs-lisp
(setq gptel-default-mode #'org-mode)
(setq gptel-model "gpt-4")
(add-hook 'gptel-post-response-functions #'font-lock-ensure)
(setq gptel-api-key (with-temp-buffer
(insert-file-contents (expand-file-name "gptel-key" user-emacs-directory))
(buffer-string)))
(add-hook 'gptel-post-response-functions #'font-lock-ensure)
#+end_src
This function was suggested by Karthink in order to fix an issue where gptel
org-mode was jumping back up to the top anytime the buffer was saved. Keeping it
around just in case.
https://github.com/karthink/gptel/issues/199
#+begin_src emacs-lisp :tangle no
(defun gptel--save-state ()
"Write the gptel state to the buffer.