aboutsummaryrefslogtreecommitdiff
path: root/Handlers.hs
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-27 20:41:57 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-27 20:41:57 -0300
commit32dc8cc98ef0e49e042d7d8cf000dc6360b106d6 (patch)
treeb55a3fa479756847a3db35d5eb4ae0b032592a1d /Handlers.hs
parentfab15274bae93611f85dd4cc221ce07b1661a081 (diff)
Unify selection list code
Diffstat (limited to 'Handlers.hs')
-rw-r--r--Handlers.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Handlers.hs b/Handlers.hs
index 9777b3c..007933d 100644
--- a/Handlers.hs
+++ b/Handlers.hs
@@ -8,6 +8,8 @@
module Handlers where
import Control.Monad.State
+import Data.List(stripPrefix)
+import System.FilePath(FilePath, takeFileName, dropTrailingPathSeparator)
import Email(parseEmail, getFields, getSubject, getFrom)
import Maildir
@@ -93,3 +95,15 @@ formatIndexModeRows st = mapM formatRow where
, (ppSep ++) $ ppIndexSubject . getSubject $ fs
]
return (fp, str)
+
+formatMaildirModeRows st = mapM formatRow where
+ formatRow fp = return $ (fp, (concat $ replicate (numPads - 1) pad) ++ name) where
+ bp = basePath st
+ str = case (stripPrefix bp fp) of
+ Nothing -> fp
+ Just s -> s
+ name' = takeFileName . dropTrailingPathSeparator $ str
+ name = takeFileName $ map (\x -> if x `elem` imapSep then '/' else x) name'
+ pad = " "
+ numPads = (length $ filter (== '/') str) + (length $ filter (`elem` imapSep) str)
+ imapSep = ['.'] -- IMAP usually separates its directories with dots
nihil fit ex nihilo