-
Notifications
You must be signed in to change notification settings - Fork 234
gptel-transient: Use width of the full frame instead of window #630
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
base: master
Are you sure you want to change the base?
Conversation
A-ha, apologies for not checking closed PRs for such an obvious improvement idea. Would it be too hacky approach if ;; the current default value not likely changing often?
(equal transient-display-buffer-action
'(display-buffer-in-side-wi ndow
(side . bottom)
(dedicated . t)
(inhibit-same-window . t))) Just thinking that most likely folks annoyed by this truncating behavior outnumber the ones who want to customize the variable. |
Yup, I think that's too hacky. Technically you want (equal transient-display-buffer-action
(apply #'eval (get 'transient-display-buffer-action 'standard-value))) but this is the kind of "fix" that feels mighty clever in the present, and leaves you scratching your head and cursing yourself in the future. So I want to avoid it. This can also break in many ways, such as with a display buffer action that still uses the full frame but differs from the default. The correct solution is to find a way to get the width of the transient window before truncating the system message. I haven't had the time or inclination to investigate this in |
Isn't` this just a fancy way of saying (default-value 'transient-display-buffer-action) But what if tarsius decides to change it in some subtle way.. so that
Well, then
Challenge accepted. But oh boy |
No, these are completely different things.
See
👍 I've found understanding it to be straightforward, but remembering how transient works is impossible. If it's been a couple of months since i last looked at it I have to read the whole file again. |
* gptel-transient.el: (gptel-system-prompt--format, gptel--setup-directive-menu, gptel-tools): When discovering the width of the transient window, use `transient--window' as an argument. Otherwise, `window-width' will return the width of the active window where the transient was launched from, and if the frame has been split horizontally, things get truncated incorrectly. If `transient-display-buffer-action' has been set to open windows on the left or right hand side, it also works since transient always fits the window to the buffer.
Okay, I believe I finally figured it out. Of course can't promise some weird |
(Okay not quite there yet but after a good night sleep I'll get there. Turns out the horizontal use case is more tricky + need to check for window-live-p) |
Things I've learned so far trying to get this working:
So, I can get the normal case with transient in the bottom working correctly each time, but it is already in current state broken when the transient is displayed in the right/left (well actually tested just right but assuming the problem is symmetrical). Perhaps we could just hardcode the width of the system message etc to be the same as the transient menu items when transient menu is on the side? Please note that this is already broken as is. EDIT: Testing on Emacs 28.2 and 29.4 with transient 0.8.4. Perhaps the transient version in MELPA has improved, but presumably we're not going to rely on bleeding edge MELPA version. |
Wow, thanks for the comprehensive investigation. I'll test when I can. gptel currently requires a minimum transient version of 0.7.4, so we don't need to worry about the peculiarities/bugs in older versions. |
My conclusion is that at least with transient.el 0.8.4 getting the correct window width is very hard if not impossible, since the contents is rendered to the " transient" buffer before the window is created. and then it eventually calls I'd say the sensible thing is to hard code the width of the system message to be roughly the same as the transient is at the default state. Or to check if BTW Emacs starts with 80×35 frame by default and the current main transient does not really fit into that nicely. |
If the default is set to If the default is set to
This sounds very finicky, I'd prefer not to do this. It's going to break if using
Windows can be narrower than that. Are we back to "there is no good solution"? |
Okay, what kind of
Of course you would check for that setting and change the behavior accordingly.
Sure, but then the current transient will wrap no matter what. Actually, like I said, it already looks like that with the default frame size of Emacs, doesn't need to be narrower than 80 characters:
Yes I don't think there is a perfect or elegant solution, but I don't think it is a reason not to try to improve the current situation with some compromise. Right not even the most common use case is broken. |
One option is the default main menu be adjusted to two columns instead of three to better fit an 80-character width. However, this change would result in a taller layout that could feel somewhat crowded. It appears that transient is primarily optimized for use with Magit and generally favors narrow menus, avoiding any lengthy dynamic text fields for the user. I believe it's essential to keep the system message visible in some capacity. Could we explore a different approach where it isn't displayed in the transient itself but instead appears in a separate window on top of the transient? |
It doesn't make a difference since we don't use
What is the most common use case? I don't think many people are using Emacs at a frame width of 80 chars?
Yes, the current layout is a compromise between width and height chosen after a lot of testing.
Transient menus used by Forge, also by Tarisus, are large:
I'm satisfied by the preview of the system message you currently see. If you are using a single column layout or a very narrow window showing a long system message will take up a big chunk of the frame height no matter how you show it. |
While it’s probably rare for users to utilize 80-column frames on modern wide and large monitors — despite it being the default setting in Emacs — my reference to the "most common use case" primarily points to the fact that many users likely retain the default However, the conclusion still stands that given the current functioning of Transient, there likely isn't an ideal solution to this issue. But we can expect new PRs trying to fix this arrive from time to time from new contributors... |
frame-width' instead of
window-width' when truncating things when using the minibuffer. Otherwise they get truncated too early when the user has horizontally split windows.