gptel-transient: Fix system-message setting function
gptel-transient.el (gptel--suffix-system-message): Removing the `(setf (buffer-local-value ...))` construct (as instructed to by the byte compiler) introduced a bug where custom system message were set from the wrong buffer. Handle this correctly to fix #138 and possibly #140.
This commit is contained in:
parent
17a58d38e7
commit
de6d8089cd
1 changed files with 22 additions and 14 deletions
|
@ -525,7 +525,9 @@ This uses the prompts in the variable
|
||||||
(insert
|
(insert
|
||||||
"# Insert your system message below and press "
|
"# Insert your system message below and press "
|
||||||
(propertize "C-c C-c" 'face 'help-key-binding)
|
(propertize "C-c C-c" 'face 'help-key-binding)
|
||||||
" when ready.\n"
|
" when ready, or "
|
||||||
|
(propertize "C-c C-k" 'face 'help-key-binding)
|
||||||
|
" to abort.\n"
|
||||||
"# Example: You are a helpful assistant. Answer as concisely as possible.\n"
|
"# Example: You are a helpful assistant. Answer as concisely as possible.\n"
|
||||||
"# Example: Reply only with shell commands and no prose.\n"
|
"# Example: Reply only with shell commands and no prose.\n"
|
||||||
"# Example: You are a poet. Reply only in verse.\n\n")
|
"# Example: You are a poet. Reply only in verse.\n\n")
|
||||||
|
@ -540,19 +542,25 @@ This uses the prompts in the variable
|
||||||
`((display-buffer-below-selected)
|
`((display-buffer-below-selected)
|
||||||
(body-function . ,#'select-window)
|
(body-function . ,#'select-window)
|
||||||
(window-height . ,#'fit-window-to-buffer)))
|
(window-height . ,#'fit-window-to-buffer)))
|
||||||
(local-set-key (kbd "C-c C-c")
|
(let ((quit-to-menu
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(with-current-buffer orig-buf
|
(quit-window)
|
||||||
(setq gptel--system-message
|
(display-buffer
|
||||||
(buffer-substring msg-start (point-max))))
|
orig-buf
|
||||||
(quit-window)
|
`((display-buffer-reuse-window
|
||||||
(display-buffer
|
display-buffer-use-some-window)
|
||||||
orig-buf
|
(body-function . ,#'select-window)))
|
||||||
`((display-buffer-reuse-window
|
(call-interactively #'gptel-menu))))
|
||||||
display-buffer-use-some-window)
|
(local-set-key (kbd "C-c C-c")
|
||||||
(body-function . ,#'select-window)))
|
(lambda ()
|
||||||
(call-interactively #'gptel-menu))))))
|
(interactive)
|
||||||
|
(let ((system-message
|
||||||
|
(buffer-substring msg-start (point-max))))
|
||||||
|
(with-current-buffer orig-buf
|
||||||
|
(setq gptel--system-message system-message)))
|
||||||
|
(funcall quit-to-menu)))
|
||||||
|
(local-set-key (kbd "C-c C-k") quit-to-menu)))))
|
||||||
|
|
||||||
;; ** Suffixes for rewriting/refactoring
|
;; ** Suffixes for rewriting/refactoring
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue