Skip to content

Commit

Permalink
feat: Add display method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Nov 12, 2023
1 parent 1f3b8c3 commit 3dba661
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ to insert a newline like a normal browser!
- `chatgpt-model` - ID of the model to use. (Default: `"gpt-3.5-turbo"`)
- `chatgpt-max-tokens` - The maximum number of tokens to generate in the completion. (Default: `2000`)
- `chatgpt-temperature` - What sampling temperature to use. (Default: `1.0`)
- `chatgpt-input-method` - Method to receive input. (Default: `'window`)
- `chatgpt-input-method` - The method to receive input. (Default: `'window`)
- `chatgpt-display-method` - The method to display buffer. (Default: `nil`)
- `chatgpt-spinner-type` - Type of the spinner. (Default: `'moon`)
- `chatgpt-display-tokens-info` - Non-nil we display tokens information for each request. (Default: `t`)
- `chatgpt-animate-text` - Display text gradually instead of output it all at once. (Default: `t`)
Expand Down
12 changes: 10 additions & 2 deletions chatgpt.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
(const :tag "Read inside new window" window))
:group 'chatgpt)

(defcustom chatgpt-display-method nil
"The method to display buffer."
:type '(choice (const :tag "Target display function." function)
(const :tag "Use default function." nil))
:group 'chatgpt)

(defcustom chatgpt-window-prompt "Type response here..."
"Text inserted when window is created."
:type 'string
Expand Down Expand Up @@ -218,8 +224,10 @@
"Wrapper to function `pop-to-buffer'.
Display buffer from BUFFER-OR-NAME."
(pop-to-buffer buffer-or-name `((display-buffer-in-direction)
(dedicated . t))))
(if (functionp chatgpt-display-method)
(funcall chatgpt-display-method buffer-or-name)
(pop-to-buffer buffer-or-name `((display-buffer-in-direction)
(dedicated . t)))))

(defun chatgpt-busy-p ()
"Return non-nil if session is busy."
Expand Down

0 comments on commit 3dba661

Please sign in to comment.