aboutsummaryrefslogtreecommitdiff
path: root/Maildir.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-09-03 12:29:47 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-09-03 12:29:47 -0300
commitfc7a8483f4a66a3f47bbb335574a399df64d62e0 (patch)
treeee91c99a23b8999503d47635b1b404d54770e586 /Maildir.hs
parentac5a65d8adc1d9a683327165057493d9cba6fdb8 (diff)
Color in new emails
Diffstat (limited to 'Maildir.hs')
-rw-r--r--Maildir.hs9
1 files changed, 6 insertions, 3 deletions
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
nihil fit ex nihilo