Skip to content

Propose a setting to run tmux foreground jobs in a separate window when possible #209

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

Merged
merged 1 commit into from
Jun 2, 2018

Conversation

shym
Copy link
Contributor

@shym shym commented Jul 22, 2017

Propose to extend the meaningful settings for the height of the tmux split for foreground jobs with 0, to state that it should be run in a different (background) window when the GUI subsystem is enabled (so that the job will be able to call back when it finishes).
With this setting, one can obtain the same behaviour with tmux than with screen.
I find this especially convenient whenever I use compilers which takes a long time to start and output eventual messages in one go at the end.

This PR consists of one real commit, but it’s based on #208 since it modifies related lines.
I’d be happy to reorganise (and document) all this if there’s a better way.

Edit: changed the commit number to a reference to the PR.

@shym
Copy link
Contributor Author

shym commented Jun 2, 2018

I rebased this PR on master now that #210 has landed, in order to use the new has_callback.

@tpope
Copy link
Owner

tpope commented Jun 2, 2018

So if height is zero and dispatch#has_callback() is false, it just ... breaks? In the not too distant future I will make dispatch#has_callback() mandatory but until then I want to handle this case gracefully.

Edit: (height <= 0 ? 10 : height) would be adequate.

@shym
Copy link
Contributor Author

shym commented Jun 2, 2018

In all my tests, tmux split -l 0 (or 1, for that matter) creates a 2-line split, just like tmux split -l 2. It’s been like this since tmux v2.5 at least, so I didn’t force the height to another value when dispatch#has_callback() is false. You think we should?
If the height is negative, it breaks, so it might be a reason to fix it (even if setting a negative height is a bit weird).

@tpope
Copy link
Owner

tpope commented Jun 2, 2018

Oooh how about (height < 0 ? -height : height) so you can provide your own fallback. I love dumb clever shit like that.

@shym
Copy link
Contributor Author

shym commented Jun 2, 2018

Nice ;-) I updated.

@tpope
Copy link
Owner

tpope commented Jun 2, 2018

abs() was added in 7.3, let's stick to the ternary.

When the requested height for a tmux split is 0 or less and that the
spawned job will be able to call back, spawn the foreground job in a new
background window, just as if it were a background job
If no callback mechanism is available, use a split of -height lines
@shym
Copy link
Contributor Author

shym commented Jun 2, 2018

Ok, done.

@tpope tpope merged commit 47729b7 into tpope:master Jun 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants