gptel-transient: Improve suffix message editor
* gptel-transient.el (gptel--suffix-system-message): Improve the editing prompt for custom suffixes. Unset the "C-c C-c" and "C-c C-k" keys from text-mode. FIXME: This is fragile, instead add the keymap with these keys as a sticky text-property over the text.
This commit is contained in:
parent
e105a52541
commit
0ea3c7fb15
1 changed files with 25 additions and 18 deletions
|
@ -520,24 +520,29 @@ This uses the prompts in the variable
|
||||||
(let ((orig-buf (current-buffer))
|
(let ((orig-buf (current-buffer))
|
||||||
(msg-start (make-marker)))
|
(msg-start (make-marker)))
|
||||||
(with-current-buffer (get-buffer-create "*gptel-system*")
|
(with-current-buffer (get-buffer-create "*gptel-system*")
|
||||||
(erase-buffer)
|
(let ((inhibit-read-only t))
|
||||||
(text-mode)
|
(erase-buffer)
|
||||||
(insert
|
(text-mode)
|
||||||
"# Insert your system message below and press "
|
(insert
|
||||||
(propertize "C-c C-c" 'face 'help-key-binding)
|
"# Insert your system message below and press "
|
||||||
" when ready, or "
|
(propertize "C-c C-c" 'face 'help-key-binding)
|
||||||
(propertize "C-c C-k" 'face 'help-key-binding)
|
" when ready, or "
|
||||||
" to abort.\n"
|
(propertize "C-c C-k" 'face 'help-key-binding)
|
||||||
"# Example: You are a helpful assistant. Answer as concisely as possible.\n"
|
" to abort.\n"
|
||||||
"# Example: Reply only with shell commands and no prose.\n"
|
"# Example: You are a helpful assistant. Answer as concisely as possible.\n"
|
||||||
"# Example: You are a poet. Reply only in verse.\n\n")
|
"# Example: Reply only with shell commands and no prose.\n"
|
||||||
(set-marker msg-start (point))
|
"# Example: You are a poet. Reply only in verse.\n")
|
||||||
(insert (buffer-local-value 'gptel--system-message orig-buf))
|
(add-text-properties
|
||||||
(beginning-of-line)
|
(point-min) (point)
|
||||||
(push-mark)
|
(list 'read-only t 'face 'font-lock-comment-face))
|
||||||
(end-of-line)
|
(insert "\n")
|
||||||
(exchange-point-and-mark)
|
;; TODO: make-separator-line requires Emacs 28.1+.
|
||||||
(activate-mark)
|
;; (insert (propertize (make-separator-line) 'rear-nonsticky t))
|
||||||
|
(set-marker msg-start (point))
|
||||||
|
(insert (buffer-local-value 'gptel--system-message orig-buf))
|
||||||
|
(push-mark)
|
||||||
|
(beginning-of-line)
|
||||||
|
(activate-mark))
|
||||||
(display-buffer (current-buffer)
|
(display-buffer (current-buffer)
|
||||||
`((display-buffer-below-selected)
|
`((display-buffer-below-selected)
|
||||||
(body-function . ,#'select-window)
|
(body-function . ,#'select-window)
|
||||||
|
@ -545,6 +550,8 @@ This uses the prompts in the variable
|
||||||
(let ((quit-to-menu
|
(let ((quit-to-menu
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
(local-unset-key (kbd "C-c C-c"))
|
||||||
|
(local-unset-key (kbd "C-c C-k"))
|
||||||
(quit-window)
|
(quit-window)
|
||||||
(display-buffer
|
(display-buffer
|
||||||
orig-buf
|
orig-buf
|
||||||
|
|
Loading…
Add table
Reference in a new issue