From 1c05da6f3230be66bc62184a72526338c1757877 Mon Sep 17 00:00:00 2001 From: Adam Vogt Date: Sun, 20 Dec 2009 20:07:39 +0100 Subject: In D.Extending note how <+> can be used with keybindings. Ignore-this: ebea8ef8a835ed368fa06621add6519f darcs-hash:20091220190739-1499c-bb3eb7e6a4caec3ffebb240d500d464b7107b027.gz --- XMonad/Doc/Extending.hs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'XMonad/Doc') diff --git a/XMonad/Doc/Extending.hs b/XMonad/Doc/Extending.hs index b57bc2e..749b72e 100644 --- a/XMonad/Doc/Extending.hs +++ b/XMonad/Doc/Extending.hs @@ -977,7 +977,7 @@ module, before starting we must first import this modules: For instance, if you have defined some additional key bindings like these: -> myKeys conf@(XConfig {XMonad.modMask = modm}) = +> myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList > [ ((modm, xK_F12), xmonadPrompt defaultXPConfig) > , ((modm, xK_F3 ), shellPrompt defaultXPConfig) > ] @@ -985,13 +985,19 @@ these: then you can create a new key bindings map by joining the default one with yours: -> newKeys x = M.union (keys defaultConfig x) (M.fromList (myKeys x)) +> newKeys x = myKeys x `M.union` keys defaultConfig x Finally, you can use @newKeys@ in the 'XMonad.Core.XConfig.keys' field of the configuration: > main = xmonad $ defaultConfig { keys = newKeys } +Alternatively, the '<+>' operator can be used which in this usage does exactly +the same as the explicit usage of 'M.union' and propagation of the config +argument, thanks to appropriate instances in "Data.Monoid". + +> main = xmonad $ defaultConfig { keys = myKeys <+> keys defaultConfig } + All together, your @~\/.xmonad\/xmonad.hs@ would now look like this: @@ -1006,11 +1012,9 @@ All together, your @~\/.xmonad\/xmonad.hs@ would now look like this: > import XMonad.Prompt.XMonad > > main :: IO () -> main = xmonad $ defaultConfig { keys = newKeys } +> main = xmonad $ defaultConfig { keys = myKeys <+> keys defaultConfig } > -> newKeys x = M.union (keys defaultConfig x) (M.fromList (myKeys x)) -> -> myKeys conf@(XConfig {XMonad.modMask = modm}) = +> myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList > [ ((modm, xK_F12), xmonadPrompt defaultXPConfig) > , ((modm, xK_F3 ), shellPrompt defaultXPConfig) > ] @@ -1034,10 +1038,10 @@ For example, suppose you want to get rid of @mod-q@ and @mod-shift-q@ to define @newKeys@ as a 'Data.Map.difference' between the default map and the map of the key bindings you want to remove. Like so: -> newKeys x = M.difference (keys defaultConfig x) (M.fromList $ keysToRemove x) +> newKeys x = keys defaultConfig x `M.difference` keysToRemove x > -> keysToRemove :: XConfig Layout -> [((KeyMask, KeySym),X ())] -> keysToRemove x = +> keysToRemove :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) +> keysToRemove x = M.fromList > [ ((modm , xK_q ), return ()) > , ((modm .|. shiftMask, xK_q ), return ()) > ] -- cgit v1.2.3