From fc7a8483f4a66a3f47bbb335574a399df64d62e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Tue, 3 Sep 2013 12:29:47 -0300 Subject: Color in new emails --- Maildir.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Maildir.hs') diff --git a/Maildir.hs b/Maildir.hs index ede0f44..7e2941d 100644 --- a/Maildir.hs +++ b/Maildir.hs @@ -14,9 +14,8 @@ import Data.List(isPrefixOf) import System.Directory (doesDirectoryExist, getDirectoryContents) import System.FilePath (()) import System.IO(IOMode(..), hGetContents, openFile) -import Network.Email.Mailbox(Flag(..), Flags) -type Maildir = FilePath +import Types(Maildir, Flag(..), Flags) isMaildir :: FilePath -> IO Bool isMaildir fp = allM doesDirectoryExist [ fp @@ -96,12 +95,16 @@ listMessageFlags fp = do return (zip ids flags) getFlags :: FilePath -> Flags -getFlags fp = map toFlag $ strip fp +getFlags fp = addNew $ map toFlag $ strip fp where strip x | null x = [] | ":2," `isPrefixOf` x = drop 3 x | otherwise = let (discard, analyze) = span (/= ':') fp in strip analyze + addNew flags = if elem SEEN flags then flags else (NEW:flags) + +isNew :: FilePath -> Bool +isNew fp = elem NEW $ getFlags fp toFlag :: Char -> Flag toFlag c | c == 'S' = SEEN -- cgit v1.2.3