diff options
author | Raúl Benencia <rul@kalgan.cc> | 2013-09-03 12:29:47 -0300 |
---|---|---|
committer | Raúl Benencia <rul@kalgan.cc> | 2013-09-03 12:29:47 -0300 |
commit | fc7a8483f4a66a3f47bbb335574a399df64d62e0 (patch) | |
tree | ee91c99a23b8999503d47635b1b404d54770e586 /Maildir.hs | |
parent | ac5a65d8adc1d9a683327165057493d9cba6fdb8 (diff) |
Color in new emails
Diffstat (limited to 'Maildir.hs')
-rw-r--r-- | Maildir.hs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 |