
Hello List, I just recently found out about xmonad and I am addicted already :) Thanks for this great window manager. I have written a function that will rotate all windows in the stack except the master, while leaving the focus where it is. I use it with the TwoPane layout: In this layout, the first window after the master window will be raised whenever the master gets the focus, which I found annoying. If that window has the focus, and you use my rotateSlaves function to change to another window, this window will still be visible when you change the focus to the master window. It is also nice to be able to change the window visible in the second pane without loosing focus in the master window. I was not sure whether I should put this in XMonadContrib, since I think it's a candidate for Operations.hs. Anyway, here is the function: rotSlaves :: SS.StackSet i a s sd -> SS.StackSet i a s sd rotSlaves = SS.modify' rotSlaves' rotSlaves' :: SS.Stack a -> SS.Stack a rotSlaves' (SS.Stack t ls rs) | (null ls) = SS.Stack t [] ((rearRs)++(frontRs)) --Master has focus | otherwise = SS.Stack t' (reverse ((master)++revls')) rs' --otherwise where (frontRs, rearRs) = splitAt (max 0 ((length rs) - 1) rs (ils, master) = splitAt (max 0 ((length ls) - 1) ls toBeRotated = (reverse ils)++(t:rs) (revls',t':rs') = splitAt (length ils) ((last toBeRotated):(init toBeRotated)) a keybinding looks like: , ((modMask .|. shiftMask, xK_Tab ), windows rotSlaves) I hope someone else will find that usefull... Hans Philipp Annen

On Thu, Aug 02, 2007 at 12:55:13AM +0200, Hans Philipp Annen wrote:
I was not sure whether I should put this in XMonadContrib, since I think it's a candidate for Operations.hs.
I think that having this implemented in a contrib module would be nice. You should send a patch with darcs. You can also send a patch for Operations.hs but I believe thet this kind of contribution is exactly the reason why the XMonadContrib repository was created. Thanks, Andrea

hpa:
Hello List,
I just recently found out about xmonad and I am addicted already :) Thanks for this great window manager.
I have written a function that will rotate all windows in the stack except the master, while leaving the focus where it is. I use it with the TwoPane layout: In this layout, the first window after the master window will be raised whenever the master gets the focus, which I found annoying. If that window has the focus, and you use my rotateSlaves function to change to another window, this window will still be visible when you change the focus to the master window. It is also nice to be able to change the window visible in the second pane without loosing focus in the master window.
Ii think this is a nice idea, and should definitely go in the contrib module. We want to keep the core api very small, and just let people pick and choose their extensions.
I was not sure whether I should put this in XMonadContrib, since I think it's a candidate for Operations.hs.
Anyway, here is the function:
rotSlaves :: SS.StackSet i a s sd -> SS.StackSet i a s sd rotSlaves = SS.modify' rotSlaves'
rotSlaves' :: SS.Stack a -> SS.Stack a rotSlaves' (SS.Stack t ls rs) | (null ls) = SS.Stack t [] ((rearRs)++(frontRs)) --Master has focus | otherwise = SS.Stack t' (reverse ((master)++revls')) rs' --otherwise where (frontRs, rearRs) = splitAt (max 0 ((length rs) - 1) rs (ils, master) = splitAt (max 0 ((length ls) - 1) ls toBeRotated = (reverse ils)++(t:rs) (revls',t':rs') = splitAt (length ils) ((last toBeRotated):(init toBeRotated))
a keybinding looks like:
, ((modMask .|. shiftMask, xK_Tab ), windows rotSlaves)
I hope someone else will find that usefull...
Nice, feel free to submit it as a contrib module (and perhaps with some internal quickcheck properties to ensure the invariant that the master doesn't move, and that focus is kept where it starts. (have a look in tests/Properties.hs for example QC tests for this kind of thing). -- Don

I have sent a darcs patch. The code I posted did not work due to a copy-paste error, sorry about that. The contributed code does. Have Fun Hans Philipp

On Thu, Aug 02, 2007 at 12:55:13AM +0200, Hans Philipp Annen wrote:
Hello List, ... Hi,
I was not sure whether I should put this in XMonadContrib, since I think it's a candidate for Operations.hs.
Anyway, here is the function:
rotSlaves :: SS.StackSet i a s sd -> SS.StackSet i a s sd rotSlaves = SS.modify' rotSlaves'
rotSlaves' :: SS.Stack a -> SS.Stack a rotSlaves' (SS.Stack t ls rs) | (null ls) = SS.Stack t [] ((rearRs)++(frontRs)) --Master has focus | otherwise = SS.Stack t' (reverse ((master)++revls')) rs' --otherwise where (frontRs, rearRs) = splitAt (max 0 ((length rs) - 1) rs (ils, master) = splitAt (max 0 ((length ls) - 1) ls toBeRotated = (reverse ils)++(t:rs) (revls',t':rs') = splitAt (length ils) ((last toBeRotated):(init toBeRotated))
I think I have a version which is easier to understand (at least for me): rotSlaves' s@(SS.Stack _ [] []) = s rotSlaves' (SS.Stack t [] (r:rs)) = SS.Stack t [] (rs ++ [r]) --Master has focus rotSlaves' (SS.Stack t ls rs) = SS.Stack t' (reverse (master:revls')) rs' --otherwise where (master:q:revls') = reverse (t:ls) (t':rs') = (rs ++ [q]) Actually it rotates the slaves into the other direction (which made it simpler), but that shouldn't matter much when using the TwoPane layout.
I hope someone else will find that usefull...
Hans Philipp Annen
Karsten Schölzel -- Karsten Schölzel | Email: kuser@gmx.de Friedrichstraße 7 | Jabber: topox@jabber.ccc.de 18057 Rostock | VoIP: sip:5857712@sipgate.de Germany | sip:708529@fwd.pulver.com | Tel: +4918015855857712 | Mobile: +491627144185

Hi Karsten, this solution is much more elegant, nice :) If you agree, I will add both functions to RotSlaves.hs, rename them to rotSlavesUp and rotSlavesDown respectively and add you to the list of authors (and maintainers?). Greetings Hans Philipp
I think I have a version which is easier to understand (at least for me):
rotSlaves' s@(SS.Stack _ [] []) = s rotSlaves' (SS.Stack t [] (r:rs)) = SS.Stack t [] (rs ++ [r]) --Master has focus rotSlaves' (SS.Stack t ls rs) = SS.Stack t' (reverse (master:revls')) rs' --otherwise where (master:q:revls') = reverse (t:ls) (t':rs') = (rs ++ [q])
Actually it rotates the slaves into the other direction (which made it simpler), but that shouldn't matter much when using the TwoPane layout.
I hope someone else will find that usefull...
Hans Philipp Annen
Karsten Schölzel -- Karsten Schölzel | Email: kuser@gmx.de Friedrichstraße 7 | Jabber: topox@jabber.ccc.de 18057 Rostock | VoIP: sip:5857712@sipgate.de Germany | sip:708529@fwd.pulver.com | Tel: +4918015855857712 | Mobile: +491627144185

On Thu, Aug 02, 2007 at 09:19:38PM +0200, Hans Philipp Annen wrote:
Hi Karsten,
this solution is much more elegant, nice :) If you agree, I will add both functions to RotSlaves.hs, rename them to rotSlavesUp and rotSlavesDown respectively and add you to the list of authors (and maintainers?).
Greetings
Hans Philipp
I think I have a version which is easier to understand (at least for me):
rotSlaves' s@(SS.Stack _ [] []) = s rotSlaves' (SS.Stack t [] (r:rs)) = SS.Stack t [] (rs ++ [r]) --Master has focus rotSlaves' (SS.Stack t ls rs) = SS.Stack t' (reverse (master:revls')) rs' --otherwise where (master:q:revls') = reverse (t:ls) (t':rs') = (rs ++ [q])
Actually it rotates the slaves into the other direction (which made it simpler), but that shouldn't matter much when using the TwoPane layout.
Hi Hans Philipp, I just thought again about the direction your version rotated, and i came up with this rotSlavesDown s@(SS.Stack _ [] []) = s rotSlavesDown (SS.Stack t [] rs) = SS.Stack t [] ((last rs):(init rs)) --Master has focus rotSlavesDown (SS.Stack t ls rs) = SS.Stack t' ls' rs' --otherwise where (t':ls') = (init ls) ++ [last (t:rs)] ++ [last ls] rs' = init (t:rs) Feel free to add these functions to RotSlaves.hs and me as an author. Greetings Karsten

doh!, and why did me and my friend spend an hour trying to reduce the length and ugliness of my first implementation?? ;) Again, your function is more beautiful and I think I have to remove us from the authors list, since nothing of our code is left... Hans Philipp On Thu, Aug 02, 2007 at 10:00:29PM +0200, Karsten Schoelzel wrote:
Hi Hans Philipp,
I just thought again about the direction your version rotated, and i came up with this
rotSlavesDown s@(SS.Stack _ [] []) = s rotSlavesDown (SS.Stack t [] rs) = SS.Stack t [] ((last rs):(init rs)) --Master has focus rotSlavesDown (SS.Stack t ls rs) = SS.Stack t' ls' rs' --otherwise where (t':ls') = (init ls) ++ [last (t:rs)] ++ [last ls] rs' = init (t:rs)
Feel free to add these functions to RotSlaves.hs and me as an author.
Greetings
Karsten _______________________________________________ Xmonad mailing list Xmonad@haskell.org http://www.haskell.org/mailman/listinfo/xmonad

On Thu, Aug 02, 2007 at 10:26:46PM +0200, Hans Philipp Annen wrote:
doh!, and why did me and my friend spend an hour trying to reduce the length and ugliness of my first implementation?? ;)
I can't answer you that question ;-)
Again, your function is more beautiful and I think I have to remove us from the authors list, since nothing of our code is left...
But the idea is yours, so you should take some credit for it :-)
Hans Philipp
Greetings Karsten
participants (4)
-
Andrea Rossato
-
dons@cse.unsw.edu.au
-
Hans Philipp Annen
-
Karsten Schoelzel