Discussion:
move-window doesn't work with -r
Jan Larres
2015-03-31 03:24:58 UTC
Permalink
Hi,

there seems to be a bug in the move-window command when using the -r option.

Let's assume I have a session "0" with two windows and a session "1" with one
window. In of the windows from session 0 I run the command:

tmux move-window -t 1:

which correctly moves the window to session 1. The same works the other way
around to move it back to session 0. However, if I run it like this:

tmux move-window -r -t 1:

then it doesn't work -- it doesn't do anything, the window remains in session
0, no error message is printed and no non-zero exit code is returned. So there
must be something going wrong with the command.

This is with the most recent Git version, commit 7536d69.

-Jan
Thomas Adam
2015-03-31 06:53:53 UTC
Permalink
Hi,

This is because -r is a separate operation to how the rest of movew works.

Thomas Adam
Post by Jan Larres
Hi,
there seems to be a bug in the move-window command when using the -r option.
Let's assume I have a session "0" with two windows and a session "1" with one
which correctly moves the window to session 1. The same works the other way
then it doesn't work -- it doesn't do anything, the window remains in session
0, no error message is printed and no non-zero exit code is returned. So there
must be something going wrong with the command.
This is with the most recent Git version, commit 7536d69.
-Jan
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for
all
things parallel software development, from weekly thought leadership blogs
to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Jan Larres
2015-03-31 23:22:27 UTC
Permalink
Hi,
Post by Thomas Adam
Post by Jan Larres
there seems to be a bug in the move-window command when using the -r option.
Let's assume I have a session "0" with two windows and a session "1" with one
which correctly moves the window to session 1. The same works the other way
then it doesn't work -- it doesn't do anything, the window remains in session
0, no error message is printed and no non-zero exit code is returned. So there
must be something going wrong with the command.
This is because -r is a separate operation to how the rest of movew works.
Are you saying that "move-window -r" is essentially a completely different
command that doesn't actually involve moving windows? That is not made clear
in the man page, and is not exactly intuitive. I had interpreted the option to
mean that after moving a window it would automatically renumber the windows
independent of the renumber-windows option.

This would be especially useful since
https://sourceforge.net/p/tmux/tickets/150/ isn't fixed yet. I am trying to
create a mapping like this for easy window moving:

bind-key m command-prompt -I 'move-window -t '

But this doesn't renumber the windows, and writing it like this also doesn't
seem to work:

bind-key m command-prompt -I 'move-window -t ' \; move-window -r

So is there a way to move a window and renumber the windows in one operation,
either with a single command or a mapping?

If the option really works like you say then actually having it as a separate
command called something like renumber-windows would in my opinion be more
intuitive than having it change an only marginally related command into
something completely different.

-Jan
Thomas Adam
2015-03-31 23:53:58 UTC
Permalink
Post by Jan Larres
Are you saying that "move-window -r" is essentially a completely different
command that doesn't actually involve moving windows? That is not made clear
in the man page, and is not exactly intuitive. I had interpreted the option to
mean that after moving a window it would automatically renumber the windows
independent of the renumber-windows option.
Renumbering of winlinks only happens when the winlink is
killed/destroyed (assuming renumber-windows session option). The point
of 'movew -r' is solely to renumber the winlinks. You can use it with
-t to specify the target, but NOT -s for the source.
Post by Jan Larres
This would be especially useful since
https://sourceforge.net/p/tmux/tickets/150/ isn't fixed yet. I am trying to
I suppose I could modify movew to support this, although there's likely
no point. Seems I looked at this.
Post by Jan Larres
So is there a way to move a window and renumber the windows in one operation,
either with a single command or a mapping?
Why do this? I mean, if you wanted to move the current window to
session 3, you can just do:

movew -t3:

And tmux can figure that out itself. What you can do is this:

movew -t 3:50 \; movew -r -t3

Which would move the current window to session 3, window index 50 and
then renumber the winlinks in session 3.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Jan Larres
2015-04-01 03:01:56 UTC
Permalink
Post by Thomas Adam
Renumbering of winlinks only happens when the winlink is
killed/destroyed (assuming renumber-windows session option). The point
of 'movew -r' is solely to renumber the winlinks. You can use it with
-t to specify the target, but NOT -s for the source.
Okay, after some experimenting I finally understood how the -r option works:
it renumbers the windows in the target session. I think that could use some
clarification in the man page.
Post by Thomas Adam
Post by Jan Larres
So is there a way to move a window and renumber the windows in one operation,
either with a single command or a mapping?
Why do this? I mean, if you wanted to move the current window to
movew -t 3:50 \; movew -r -t3
With a fixed session number this would work, yes. But the idea is that I want
to be able to press a key, enter the session number, press enter, and have the
current window move and the windows renumbered automatically in both the
source and the target session. The only way I can think of to make this work
is to write a shell script that executes the appropriate commands and pass the
session number to it with a command-prompt binding. This is certainly
possible, but it would be much simpler if moving windows respected the
renumber-windows option.

By the way, while I'm at it it would be nice if there was an option that
allows you to move a window inbetween two existing windows instead of just
saying that the index is in use, like moving tabs works in Vim.

Anyway, thanks for the help so far.

-Jan
Thomas Adam
2015-04-01 20:10:44 UTC
Permalink
Post by Jan Larres
Post by Thomas Adam
Renumbering of winlinks only happens when the winlink is
killed/destroyed (assuming renumber-windows session option). The point
of 'movew -r' is solely to renumber the winlinks. You can use it with
-t to specify the target, but NOT -s for the source.
it renumbers the windows in the target session. I think that could use some
clarification in the man page.
I'm not so sure: without -t for all commands which don't require it,
assumes so sort of "current" object to operate on, and movew is no
different to that, nor is the use of '-r' along with it.
Post by Jan Larres
Post by Thomas Adam
Post by Jan Larres
So is there a way to move a window and renumber the windows in one operation,
either with a single command or a mapping?
Why do this? I mean, if you wanted to move the current window to
movew -t 3:50 \; movew -r -t3
With a fixed session number this would work, yes. But the idea is that I want
to be able to press a key, enter the session number, press enter, and have the
current window move and the windows renumbered automatically in both the
source and the target session. The only way I can think of to make this work
is to write a shell script that executes the appropriate commands and pass the
session number to it with a command-prompt binding. This is certainly
possible, but it would be much simpler if moving windows respected the
renumber-windows option.
Hooks support will help with this when it gets finalised.
Post by Jan Larres
By the way, while I'm at it it would be nice if there was an option that
allows you to move a window inbetween two existing windows instead of just
saying that the index is in use, like moving tabs works in Vim.
Maybe.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Jan Larres
2015-04-02 03:34:26 UTC
Permalink
Post by Thomas Adam
Post by Jan Larres
it renumbers the windows in the target session. I think that could use some
clarification in the man page.
I'm not so sure: without -t for all commands which don't require it,
assumes so sort of "current" object to operate on, and movew is no
different to that, nor is the use of '-r' along with it.
I mostly meant that the -r option completely changes the way the command
operates and doesn't actually move a window any more, but that the -t argument
(but not the others) still applies. In my opinion that could be made a bit
clearer.

-Jan

Loading...