-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gptel asks user to select a buffer if many are open #311
Conversation
This commit modifies the behavior of the gptel function so that, in the case where the function is called interactively, and multiple gptel sessions already exist (as judged by there being multiple buffers with the minor mode gptel-mode enabled), then the function prompts the user to select one of those buffers. This replaces the previous behavior in this case, which was just to switch to the buffer named `backend-name` if it already existed, or else to create a new buffer with that name. So, after this comit, the gptel function behaves as follows: - (NEW). When called interactively and multiple gptel-mode buffers exists, it prompts the user to choose a buffer to switch to. - when called interactively and no gptel-mode buffers exist, it creates a buffer named `backend-name` - when called interactively and 1 gptel-mode buffers exists, it switches to the buffer named `backend-name` or creates it if it does not exist. - when called interactively with a prefix arg, it behaves as before, and prompts the user to acknowledge or input the name of a buffer to create. - when called programmatically, it behaves as before.
@algal This looks good. After trying it for a bit, I think we can simplify the behavior of
You also don't need to use (read-buffer "Create or choose gptel buffer: "
backend-name nil ; DEFAULT and REQUIRE-MATCH
(lambda (b) ; PREDICATE
(buffer-local-value 'gptel-mode
(get-buffer (or (car-safe b) b))))) The prefix-arg behavior will then be unnecessary, and we can use it to bring up a transient menu where the user can choose the gptel buffer name, backend, system message and other model parameters to use in the new session. This is a feature that's been asked for a couple of times, and I can add it after this PR. What do you think? |
@karthink Yes, I think the behavior you describe is better than what I proposed in my original PR. My new commits above implement what you describe, based on your code snippet, and this feels like a better user experience. (Of course, please feel free to just to implement as you like if you want to keep your history clean.) I also like the consistency of the second idea -- of using the prefix arg for I think this would be especially handy for selecting a system directive early, since usually you know what kind of assistance you require at buffer-creation time, even if you might want to experiment with different models at query-submission time. I suppose it would have to be only roughly the same transient menu, since it looks like some of the options there now would not make sense when creating a buffer. |
gptel.el
Outdated
@@ -3,7 +3,7 @@ | |||
;; Copyright (C) 2023 Karthik Chikmagalur | |||
|
|||
;; Author: Karthik Chikmagalur <[email protected]> | |||
;; Version: 0.8.6 | |||
;; Version: 999.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change, the version stays unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Will merge after you fix the version change.
Yeah, I can't reuse the menu, I'll have to reuse some of the pieces to make a new one. |
Looks good, merging. Thanks for the PR! |
This commit modifies the behavior of the gptel function so that, in the case where the function is called interactively, and multiple gptel sessions already exist (as judged by there being multiple buffers with the minor mode gptel-mode enabled), then the function prompts the user to select one of those buffers.
This replaces the previous behavior in this case, which was just to switch to the buffer named
backend-name
if it already existed, or else to create a new buffer with that name.So, after this comit, the gptel function behaves as follows:
(NEW). When called interactively and multiple gptel-mode buffers exists, it prompts the user to choose a buffer to switch to.
when called interactively and no gptel-mode buffers exist, it creates a buffer named
backend-name
when called interactively and 1 gptel-mode buffers exists, it switches to the buffer named
backend-name
or creates it if it does not exist.when called interactively with a prefix arg, it behaves as before, and prompts the user to acknowledge or input the name of a buffer to create.
when called programmatically, it behaves as before.