emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gptel 226f8f0d90 208/273: gptel: Add customizable display-


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 226f8f0d90 208/273: gptel: Add customizable display-action (#216)
Date: Wed, 1 May 2024 10:02:24 -0400 (EDT)

branch: elpa/gptel
commit 226f8f0d9091e1feb113623ab6da5fdc471994e8
Author: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Commit: Karthik Chikmagalur <karthikchikmagalur@gmail.com>

    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.
---
 README.org | 17 +++++++++--------
 gptel.el   | 22 +++++++++++++++++++++-
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/README.org b/README.org
index dfec62f475..f5211fc35d 100644
--- a/README.org
+++ b/README.org
@@ -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.                   
 |
 |-------------------+---------------------------------------------------------|
 
-|-----------------------------+----------------------------------------|
-| *Chat UI options*             |                                        |
-|-----------------------------+----------------------------------------|
-| =gptel-default-mode=          | Major mode for dedicated chat buffers. |
-| =gptel-prompt-prefix-alist=   | Text inserted before queries.          |
-| =gptel-response-prefix-alist= | Text inserted before responses.        |
-| =gptel-use-header-line= | Display status messages in header-line (default) 
or minibuffer      |
-|-----------------------------+----------------------------------------|
+|-----------------------------+----------------------------------------------------------------|
+| *Chat UI options*             |                                              
                  |
+|-----------------------------+----------------------------------------------------------------|
+| =gptel-default-mode=          | Major mode for dedicated chat buffers.       
                  |
+| =gptel-prompt-prefix-alist=   | Text inserted before queries.                
                  |
+| =gptel-response-prefix-alist= | Text inserted before responses.              
                  |
+| =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?
 
diff --git a/gptel.el b/gptel.el
index 796634799b..2886e7b7ff 100644
--- a/gptel.el
+++ b/gptel.el
@@ -313,6 +313,26 @@ information and the echo area for messages."
   :type 'boolean
   :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
   (let ((cache-dir (or (getenv "XDG_CACHE_HOME")
                        (getenv "XDG_DATA_HOME")
@@ -1242,7 +1262,7 @@ INTERACTIVEP is t when gptel is called interactively."
     (skip-chars-backward "\t\r\n")
     (if (bobp) (insert (or initial (gptel-prompt-prefix-string))))
     (when interactivep
-      (pop-to-buffer (current-buffer))
+      (display-buffer (current-buffer) gptel-display-buffer-action)
       (message "Send your query with %s!"
                (substitute-command-keys "\\[gptel-send]")))
     (current-buffer)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]