Add gptel-chat-with-buffer function and keybinding

This commit introduces the gptel-chat-with-buffer function, allowing users to start a chat with the buffer content. It also updates keybindings, assigning "b" to the new function and moving gptel-select-backend to "B".
This commit is contained in:
Jeremy Dormitzer 2024-07-25 21:10:14 -04:00
parent e63466ca1f
commit a47f4e537d

View File

@ -57,6 +57,17 @@
(gptel buffer nil initial interactivep))
(with-current-buffer buffer
(setq-local gptel--system-message (alist-get 'org-mode gptel-directives))))
(defun gptel-chat-with-buffer (&optional arg interactivep)
(interactive (list current-prefix-arg t))
(let* ((name (format "*gptel: %s*"(buffer-name)))
(buffer (if arg
(generate-new-buffer name)
name)))
(gptel buffer nil (buffer-string) interactivep)
(with-current-buffer buffer
(goto-char (point-max))
(newline)
(insert (gptel-prompt-prefix-string)))))
:general
("C-c RET" #'gptel-send
"C-c C-<return>" #'gptel-menu)
@ -65,7 +76,8 @@
"o" #'gptel-org
"s" #'gptel-send
"m" #'gptel-menu
"b" #'gptel-select-backend
"b" #'gptel-chat-with-buffer
"B" #'gptel-select-backend
"a" #'gptel-context-add
"f" #'gptel-context-add-file
"k" #'gptel-abort))