From 263a8bec1a4d7f21abc9114e236d035300d837bf Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Thu, 6 Jun 2024 14:39:48 +0700 Subject: [PATCH] Emacs: Read gptel key from disk --- .config/emacs/init.org | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 89f87bc..babf3f0 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -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.