From 5273db3d5c21cd4ef331df57e09c58c93bcc3f46 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 11 Jan 2015 21:53:13 +0100 Subject: notmuch insert reply drafts --- test5.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test5.hs') diff --git a/test5.hs b/test5.hs index b72850a..9a64db0 100644 --- a/test5.hs +++ b/test5.hs @@ -4,6 +4,7 @@ module Main (main) where +import qualified Data.ByteString.Lazy as LBS import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Tree as Tree @@ -449,7 +450,30 @@ replyToAll q@State{..} = case getMessage (Z.label cursor) of Plain $ "notmuch exit code = " ++ show code } ExitSuccess -> - runEditor path q + runEditor' path q >>= \case + ExitFailure code -> + return q { flashMessage = Plain $ "editor exit code = " ++ show code } + ExitSuccess -> do + x <- LBS.readFile path + -- TODO use TagOps + Notmuch.notmuchWithInput + [ "insert" + , "--no-hooks" + , "+draft" + -- TODO dont hardcode which tags to delete + , "-inbox" + , "-unread" + ] + -- TODO rename to draftPath + x >>= \case + (ExitFailure code, _, _) -> + return q { flashMessage = + Plain $ "notmuch insert exit code = " ++ show code + } + _ -> + toggleFold q { + flashMessage = "draft created" + } viewSource :: State -> IO State -- cgit v1.2.3