From 7d0ac5c6129d3ec0765597bd9494347dda377888 Mon Sep 17 00:00:00 2001 From: Daniel Schoepe Date: Thu, 2 Jul 2009 12:49:33 +0200 Subject: Remove code duplication in X.A.CopyWindow Ignore-this: cbbbe68690dbb4b814cd48fa32d4720 darcs-hash:20090702104933-7f603-8f51c30a91e31fa6b7b6cd7ef7197abb1999e487.gz --- XMonad/Actions/CopyWindow.hs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'XMonad/Actions/CopyWindow.hs') diff --git a/XMonad/Actions/CopyWindow.hs b/XMonad/Actions/CopyWindow.hs index d49b5dc..1f425bf 100644 --- a/XMonad/Actions/CopyWindow.hs +++ b/XMonad/Actions/CopyWindow.hs @@ -22,9 +22,10 @@ module XMonad.Actions.CopyWindow ( ) where import Prelude hiding (filter) -import Control.Monad (filterM) +import Control.Monad import qualified Data.List as L import XMonad hiding (modify, workspaces) +import XMonad.Actions.WindowGo import qualified XMonad.StackSet as W -- $usage @@ -98,15 +99,10 @@ copyWindow w n = copy' runOrCopy :: String -> Query Bool -> X () runOrCopy = copyMaybe . spawn --- | copyMaybe. Copies "XMonad.Actions.WindowGo" ('raiseMaybe') --- TODO: Factor out and improve with regard to WindowGo. +-- | Copy a window if it exists, run the first argument otherwise copyMaybe :: X () -> Query Bool -> X () -copyMaybe f thatUserQuery = withWindowSet $ \s -> do - maybeResult <- filterM (runQuery thatUserQuery) (W.allWindows s) - case maybeResult of - [] -> f - (x:_) -> windows $ copyWindow x (W.currentTag s) - +copyMaybe f qry = ifWindow qry copyWin f + where copyWin = ask >>= \w -> doF (\ws -> copyWindow w (W.currentTag ws) ws) -- | Remove the focused window from this workspace. If it's present in no -- other workspace, then kill it instead. If we do kill it, we'll get a -- cgit v1.2.3