gptel: Add customizable display-action (#216)
* gptel.el (gptel-display-buffer-action, gptel): Add `gptel-display-buffer-action` to customize the display of the gptel buffer. * README: Mention new option.
This commit is contained in:
parent
5465271541
commit
226f8f0d90
2 changed files with 30 additions and 9 deletions
|
@ -553,14 +553,15 @@ Other Emacs clients for LLMs prescribe the format of the interaction (a comint s
|
||||||
| =gptel-temperature= | Randomness in response text, 0 to 2. |
|
| =gptel-temperature= | Randomness in response text, 0 to 2. |
|
||||||
|-------------------+---------------------------------------------------------|
|
|-------------------+---------------------------------------------------------|
|
||||||
|
|
||||||
|-----------------------------+----------------------------------------|
|
|-----------------------------+----------------------------------------------------------------|
|
||||||
| *Chat UI options* | |
|
| *Chat UI options* | |
|
||||||
|-----------------------------+----------------------------------------|
|
|-----------------------------+----------------------------------------------------------------|
|
||||||
| =gptel-default-mode= | Major mode for dedicated chat buffers. |
|
| =gptel-default-mode= | Major mode for dedicated chat buffers. |
|
||||||
| =gptel-prompt-prefix-alist= | Text inserted before queries. |
|
| =gptel-prompt-prefix-alist= | Text inserted before queries. |
|
||||||
| =gptel-response-prefix-alist= | Text inserted before responses. |
|
| =gptel-response-prefix-alist= | Text inserted before responses. |
|
||||||
| =gptel-use-header-line= | Display status messages in header-line (default) or minibuffer |
|
| =gptel-use-header-line= | Display status messages in header-line (default) or minibuffer |
|
||||||
|-----------------------------+----------------------------------------|
|
| =gptel-display-buffer-action= | Placement of the gptel chat buffer. |
|
||||||
|
|-----------------------------+----------------------------------------------------------------|
|
||||||
|
|
||||||
** COMMENT Will you add feature X?
|
** COMMENT Will you add feature X?
|
||||||
|
|
||||||
|
|
22
gptel.el
22
gptel.el
|
@ -313,6 +313,26 @@ information and the echo area for messages."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'gptel)
|
:group 'gptel)
|
||||||
|
|
||||||
|
(defcustom gptel-display-buffer-action '(pop-to-buffer)
|
||||||
|
"The action used to display gptel chat buffers.
|
||||||
|
|
||||||
|
The gptel buffer is displayed in a window using
|
||||||
|
|
||||||
|
(display-buffer BUFFER gptel-display-buffer-action)
|
||||||
|
|
||||||
|
The value of this option has the form (FUNCTION . ALIST),
|
||||||
|
where FUNCTION is a function or a list of functions. Each such
|
||||||
|
function should accept two arguments: a buffer to display and an
|
||||||
|
alist of the same form as ALIST. See info node `(elisp)Choosing
|
||||||
|
Window' for details."
|
||||||
|
:group 'gptel
|
||||||
|
:type '(choice
|
||||||
|
(const :tag "Use display-buffer defaults" nil)
|
||||||
|
(const :tag "Display in selected window" (pop-to-buffer-same-window))
|
||||||
|
(cons :tag "Specify display-buffer action"
|
||||||
|
(choice function (repeat :tag "Functions" function))
|
||||||
|
alist)))
|
||||||
|
|
||||||
(defcustom gptel-crowdsourced-prompts-file
|
(defcustom gptel-crowdsourced-prompts-file
|
||||||
(let ((cache-dir (or (getenv "XDG_CACHE_HOME")
|
(let ((cache-dir (or (getenv "XDG_CACHE_HOME")
|
||||||
(getenv "XDG_DATA_HOME")
|
(getenv "XDG_DATA_HOME")
|
||||||
|
@ -1242,7 +1262,7 @@ INTERACTIVEP is t when gptel is called interactively."
|
||||||
(skip-chars-backward "\t\r\n")
|
(skip-chars-backward "\t\r\n")
|
||||||
(if (bobp) (insert (or initial (gptel-prompt-prefix-string))))
|
(if (bobp) (insert (or initial (gptel-prompt-prefix-string))))
|
||||||
(when interactivep
|
(when interactivep
|
||||||
(pop-to-buffer (current-buffer))
|
(display-buffer (current-buffer) gptel-display-buffer-action)
|
||||||
(message "Send your query with %s!"
|
(message "Send your query with %s!"
|
||||||
(substitute-command-keys "\\[gptel-send]")))
|
(substitute-command-keys "\\[gptel-send]")))
|
||||||
(current-buffer)))
|
(current-buffer)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue