mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Use extensible-exceptions to allow base-3 or base-4
This commit is contained in:
parent
b435a6a519
commit
aa8290b60d
@ -89,7 +89,7 @@ import Data.Set (fromList, toList)
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
import Control.Exception hiding (handle)
|
import Control.Exception.Extensible hiding (handle)
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ getCompletions :: XP [String]
|
|||||||
getCompletions = do
|
getCompletions = do
|
||||||
s <- get
|
s <- get
|
||||||
io $ completionFunction s (commandToComplete (xptype s) (command s))
|
io $ completionFunction s (commandToComplete (xptype s) (command s))
|
||||||
`catch` \_ -> return []
|
`catch` \(SomeException _) -> return []
|
||||||
|
|
||||||
setComplWin :: Window -> ComplWindowDim -> XP ()
|
setComplWin :: Window -> ComplWindowDim -> XP ()
|
||||||
setComplWin w wi =
|
setComplWin w wi =
|
||||||
@ -758,7 +758,7 @@ getHistoryFile :: IO FilePath
|
|||||||
getHistoryFile = fmap (++ "/history") $ getAppUserDataDirectory "xmonad"
|
getHistoryFile = fmap (++ "/history") $ getAppUserDataDirectory "xmonad"
|
||||||
|
|
||||||
readHistory :: IO History
|
readHistory :: IO History
|
||||||
readHistory = catch readHist (const (return emptyHistory))
|
readHistory = readHist `catch` \(SomeException _) -> return emptyHistory
|
||||||
where
|
where
|
||||||
readHist = do
|
readHist = do
|
||||||
path <- getHistoryFile
|
path <- getHistoryFile
|
||||||
@ -768,7 +768,7 @@ readHistory = catch readHist (const (return emptyHistory))
|
|||||||
writeHistory :: History -> IO ()
|
writeHistory :: History -> IO ()
|
||||||
writeHistory hist = do
|
writeHistory hist = do
|
||||||
path <- getHistoryFile
|
path <- getHistoryFile
|
||||||
catch (writeFile path (show hist)) $ const $ hPutStrLn stderr "error in writing"
|
writeFile path (show hist) `catch` \(SomeException _) -> hPutStrLn stderr "error in writing"
|
||||||
setFileMode path mode
|
setFileMode path mode
|
||||||
where mode = ownerReadMode .|. ownerWriteMode
|
where mode = ownerReadMode .|. ownerWriteMode
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import XMonad.Core
|
|||||||
import XMonad.Prompt
|
import XMonad.Prompt
|
||||||
|
|
||||||
import System.IO
|
import System.IO
|
||||||
import Control.Exception
|
import Control.Exception.Extensible (bracket)
|
||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
--
|
--
|
||||||
|
@ -31,7 +31,7 @@ import System.Directory
|
|||||||
import System.Process
|
import System.Process
|
||||||
import System.IO
|
import System.IO
|
||||||
|
|
||||||
import qualified Control.Exception as E
|
import qualified Control.Exception.Extensible as E
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
@ -62,7 +62,8 @@ manPrompt c = do
|
|||||||
|
|
||||||
getMans :: IO [String]
|
getMans :: IO [String]
|
||||||
getMans = do
|
getMans = do
|
||||||
paths <- getCommandOutput "manpath -g 2>/dev/null" `E.catch` \_ -> return []
|
paths <- getCommandOutput "manpath -g 2>/dev/null" `E.catch`
|
||||||
|
\(E.SomeException _) -> return []
|
||||||
let sects = ["man" ++ show n | n <- [1..9 :: Int]]
|
let sects = ["man" ++ show n | n <- [1..9 :: Int]]
|
||||||
dirs = [d ++ "/" ++ s | d <- split ':' paths, s <- sects]
|
dirs = [d ++ "/" ++ s | d <- split ':' paths, s <- sects]
|
||||||
mans <- forM dirs $ \d -> do
|
mans <- forM dirs $ \d -> do
|
||||||
|
@ -24,7 +24,7 @@ module XMonad.Util.NamedWindows (
|
|||||||
|
|
||||||
import Prelude hiding ( catch )
|
import Prelude hiding ( catch )
|
||||||
import Control.Applicative ( (<$>) )
|
import Control.Applicative ( (<$>) )
|
||||||
import Control.Exception ( bracket, catch )
|
import Control.Exception.Extensible ( bracket, catch, SomeException(..) )
|
||||||
import Data.Maybe ( fromMaybe, listToMaybe )
|
import Data.Maybe ( fromMaybe, listToMaybe )
|
||||||
|
|
||||||
import qualified XMonad.StackSet as W ( peek )
|
import qualified XMonad.StackSet as W ( peek )
|
||||||
@ -50,11 +50,11 @@ getName w = withDisplay $ \d -> do
|
|||||||
let getIt = bracket getProp (xFree . tp_value) (fmap (`NW` w) . copy)
|
let getIt = bracket getProp (xFree . tp_value) (fmap (`NW` w) . copy)
|
||||||
|
|
||||||
getProp = (internAtom d "_NET_WM_NAME" False >>= getTextProperty d w)
|
getProp = (internAtom d "_NET_WM_NAME" False >>= getTextProperty d w)
|
||||||
`catch` \_ -> getTextProperty d w wM_NAME
|
`catch` \(SomeException _) -> getTextProperty d w wM_NAME
|
||||||
|
|
||||||
copy prop = fromMaybe "" . listToMaybe <$> wcTextPropertyToTextList d prop
|
copy prop = fromMaybe "" . listToMaybe <$> wcTextPropertyToTextList d prop
|
||||||
|
|
||||||
io $ getIt `catch` \_ -> ((`NW` w) . resName) `fmap` getClassHint d w
|
io $ getIt `catch` \(SomeException _) -> ((`NW` w) . resName) `fmap` getClassHint d w
|
||||||
|
|
||||||
unName :: NamedWindow -> Window
|
unName :: NamedWindow -> Window
|
||||||
unName (NW _ w) = w
|
unName (NW _ w) = w
|
||||||
|
@ -33,8 +33,9 @@ module XMonad.Util.Run (
|
|||||||
|
|
||||||
import System.Posix.IO
|
import System.Posix.IO
|
||||||
import System.Posix.Process (executeFile)
|
import System.Posix.Process (executeFile)
|
||||||
|
import System.Posix.Types (ProcessID)
|
||||||
import Control.Concurrent (threadDelay)
|
import Control.Concurrent (threadDelay)
|
||||||
import Control.Exception (try) -- use OldException with base 4
|
import Control.Exception.Extensible (try,SomeException)
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process (runInteractiveProcess)
|
import System.Process (runInteractiveProcess)
|
||||||
import XMonad
|
import XMonad
|
||||||
@ -107,7 +108,9 @@ it makes use of shell interpretation by relying on @$HOME@ and
|
|||||||
interpolation, whereas the safeSpawn example can be safe because
|
interpolation, whereas the safeSpawn example can be safe because
|
||||||
Firefox doesn't need any arguments if it is just being started. -}
|
Firefox doesn't need any arguments if it is just being started. -}
|
||||||
safeSpawn :: MonadIO m => FilePath -> [String] -> m ()
|
safeSpawn :: MonadIO m => FilePath -> [String] -> m ()
|
||||||
safeSpawn prog args = liftIO (try (xfork $ executeFile prog True args Nothing) >> return ())
|
safeSpawn prog args = liftIO $ do
|
||||||
|
try $ xfork $ executeFile prog True args Nothing :: IO (Either SomeException ProcessID)
|
||||||
|
return ()
|
||||||
|
|
||||||
-- | Like 'safeSpawn', but only takes a program (and no arguments for it). eg.
|
-- | Like 'safeSpawn', but only takes a program (and no arguments for it). eg.
|
||||||
--
|
--
|
||||||
|
@ -22,7 +22,7 @@ module XMonad.Util.XSelection ( -- * Usage
|
|||||||
transformPromptSelection,
|
transformPromptSelection,
|
||||||
transformSafePromptSelection) where
|
transformSafePromptSelection) where
|
||||||
|
|
||||||
import Control.Exception as E (catch)
|
import Control.Exception.Extensible as E (catch,SomeException(..))
|
||||||
import Control.Monad (liftM, join)
|
import Control.Monad (liftM, join)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import XMonad
|
import XMonad
|
||||||
@ -66,8 +66,8 @@ getSelection = io $ do
|
|||||||
ty <- E.catch
|
ty <- E.catch
|
||||||
(E.catch
|
(E.catch
|
||||||
(internAtom dpy "UTF8_STRING" False)
|
(internAtom dpy "UTF8_STRING" False)
|
||||||
(\_ -> internAtom dpy "COMPOUND_TEXT" False))
|
(\(E.SomeException _) -> internAtom dpy "COMPOUND_TEXT" False))
|
||||||
(\_ -> internAtom dpy "sTring" False)
|
(\(E.SomeException _) -> internAtom dpy "sTring" False)
|
||||||
clp <- internAtom dpy "BLITZ_SEL_STRING" False
|
clp <- internAtom dpy "BLITZ_SEL_STRING" False
|
||||||
xConvertSelection dpy p ty clp win currentTime
|
xConvertSelection dpy p ty clp win currentTime
|
||||||
allocaXEvent $ \e -> do
|
allocaXEvent $ \e -> do
|
||||||
|
@ -40,7 +40,14 @@ flag testing
|
|||||||
|
|
||||||
library
|
library
|
||||||
if flag(small_base)
|
if flag(small_base)
|
||||||
build-depends: base >= 3 && < 4, containers, directory, process, random, old-time, old-locale
|
build-depends: base >= 3 && < 5,
|
||||||
|
containers,
|
||||||
|
directory,
|
||||||
|
extensible-exceptions,
|
||||||
|
old-locale,
|
||||||
|
old-time,
|
||||||
|
process,
|
||||||
|
random
|
||||||
else
|
else
|
||||||
build-depends: base < 3
|
build-depends: base < 3
|
||||||
|
|
||||||
@ -60,7 +67,7 @@ library
|
|||||||
ghc-options: -fwarn-tabs -Werror
|
ghc-options: -fwarn-tabs -Werror
|
||||||
|
|
||||||
if impl(ghc >= 6.12.1)
|
if impl(ghc >= 6.12.1)
|
||||||
ghc-options: -fno-warn-warnings-deprecations -fno-warn-unused-do-bind
|
ghc-options: -fno-warn-unused-do-bind
|
||||||
|
|
||||||
if impl (ghc == 6.10.1) && arch (x86_64)
|
if impl (ghc == 6.10.1) && arch (x86_64)
|
||||||
ghc-options: -O0
|
ghc-options: -O0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user