From 4b26940ed310b9d7119eaf83c18526eb5ec38cd5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 11 Dec 2010 21:41:08 +0100 Subject: MBox: support for ~ paths and skipping non-existing mboxes --- Plugins/Mail.hs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'Plugins/Mail.hs') diff --git a/Plugins/Mail.hs b/Plugins/Mail.hs index 89cac30..38cdaae 100644 --- a/Plugins/Mail.hs +++ b/Plugins/Mail.hs @@ -16,12 +16,12 @@ module Plugins.Mail where import Prelude hiding (catch) import Plugins +import Plugins.Utils (expandHome, changeLoop) import Control.Monad import Control.Concurrent.STM import System.Directory -import System.Environment import System.FilePath import System.INotify @@ -58,10 +58,6 @@ instance Exec Mail where modifyTVar :: TVar a -> (a -> a) -> STM () modifyTVar v f = readTVar v >>= writeTVar v . f -expandHome :: FilePath -> IO FilePath -expandHome ('~':'/':path) = fmap ( path) (getEnv "HOME") -expandHome p = return p - handle :: TVar (Set String) -> Event -> IO () handle v e = atomically $ modifyTVar v $ case e of Created {} -> create @@ -72,13 +68,3 @@ handle v e = atomically $ modifyTVar v $ case e of where delete = S.delete (filePath e) create = S.insert (filePath e) - -changeLoop :: Eq a => STM a -> (a -> IO ()) -> IO () -changeLoop s f = atomically s >>= go - where - go old = do - f old - go =<< atomically (do - new <- s - guard (new /= old) - return new) -- cgit v1.2.3