-
Notifications
You must be signed in to change notification settings - Fork 26
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
Customise window size and fit content to it #48
Comments
i think the answer here is (magic and tricky) configuration using for example, for me new windows (including those opened by the pytest output is adapted to the available window size (i think due to |
(closing since none of this seems caused by |
Rather than via the buffer list, would it be possible to expose a hook for when the buffer is open and the tests are running. I saw that the package defines a bunch of hooks, one of which I thought would achieve this, defining a hook to resize after them didn't work as I'd expected.
Interesting, when I do this, I get the output rendered to the same width as the maximised screen. Any idea how one could force it to observe the window width? Thanks |
if you leave the window open, and from that window execute because that works automatically for me, but only if the window was already open (i think |
Aha, yes, this now works, but only if I call Any idea what's going on here? |
nope, sorry. this is something low level related to comint and terminal emulation, combined with timings/order of emacs window layout, etc. please do report if you manage to figure out though 🙃 |
One simple solution could be to map the key bindings I use to call the associated commands in the pytest buffer, rather than the current, if it exists. I'm pretty new to emacs, so am not totally sure if this is possible/would work. What do you think @wbolster? |
@wbolster Here's an interesting observation I noticed while trying to debug this: The width of the content in the comint-mode pytest interpreter buffer is actually set to the width of the window in which the python-pytest command was run. For me this can be repro'd by setting the width of current buffer (containing the test) to something small, like say 40, and then dispatching a test. When I run this the resulting pytest buffer then attempts to render to a width of 40 characters where possible. I am not familiar enough with the source code or comint mode to know how to propagate this information to the appropriate comint function call, but presumably it should be possible? |
Looking at the comint mode source code, it seems like this would be best addressed by having the pytest window selected just before I have tested this and with some added hooks I can get a limited version of the solution working. When one only has two windows open, adding the following hooks solves the problem: (defun focus-on-other-window ()
(other-window 1))
(add-hook 'python-pytest-setup-hook 'focus-on-other-window)
(add-hook 'python-pytest-started-hook 'focus-on-other-window) But obviously this will not work if there are more windows involved, so this could be addressed with some simple functions that select and deselect the pytest window before and after the As an Emacs newbie I am not sure how to test such a change on a development version of the package locally, but I believe it would be a small change and would have exactly the desired effect 🙂 |
Hi, The solution from @sammorley-short did not work for me. I managed to solve the issue in a slightly different way, and I want to share my solution with others that might encounter a similar issue: (add-hook 'python-pytest-setup-hook (lambda () (switch-to-buffer-other-window (python-pytest--get-buffer)))) The new hook will display the buffer and switch to to it before actually calling I haven't yet looked at the source code and I have no experience in writing proper Emacs packages, but I think the problem might be with |
seems like this is the right approach indeed 👍🏼 |
It would be really great if one were able to define the size of the window created to display the pytest buffer. Often half of the screen is more than enough when running a test, and in my case I'd like to limit the width of the created buffer to some maximum size.
Similarly, the content inside the buffer is formatted to match the size of the fully maximised window size. This means when the tests are running, they run off the window and out of view. Similarly, the progress percentages are never in view because of this. It would be preferable if the shell running pytest was initially aware of the size of the window it's filling, so that the content can be printed accordingly, similarly to how it works in an actual terminal session.
Thanks!
The text was updated successfully, but these errors were encountered: