From 32dc8cc98ef0e49e042d7d8cf000dc6360b106d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Tue, 27 Aug 2013 20:41:57 -0300 Subject: Unify selection list code --- Handlers.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Handlers.hs') 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 -- cgit v1.2.3