codehenry / xmonad

Automatically exported from code.google.com/p/xmonad
0 stars 0 forks source link

EZConfig `exchangeKeys` function #608

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
There should be an exchangeKeys function to swap two keys without needing to 
copy their implementation.

Here is my try of an implementation, but I couldn’t get it working, it 
compiles but nothing happens. Probably a simple logical error.

exchangeKeys :: XConfig a -> ((KeyMask, KeySym), (KeyMask, KeySym)) -> XConfig a
exchangeKeys conf (map, map') =
  conf { keys = \cnf ->
            let
              -- fwd = M.findWithDefault $ pure ()
              fwd map keys = keys M.! map
              oldKeys = keys conf cnf
              (com, com') = (fwd map oldKeys, fwd map' oldKeys)
            in
             M.insert map com' $ M.insert map' com oldKeys
       }

There should be `exchangeKeysP`, too.

Original issue reported on code.google.com by Ephro...@gmail.com on 22 Jun 2015 at 10:59

GoogleCodeExporter commented 8 years ago
Hi, thanks!  I will take a look at this if no one else gets around to it in the 
meantime, but I may not get to it for a few weeks since I will be moving across 
the country and travelling.

Original comment by byor...@gmail.com on 23 Jun 2015 at 2:47

GoogleCodeExporter commented 8 years ago
Oh, and the commented-out fwd is the right one. I tried to make it crash with 
(!), but that didn’t work somehow.

Original comment by Ephro...@gmail.com on 23 Jun 2015 at 2:50