summaryrefslogtreecommitdiffstats
path: root/test5.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-01-11 21:53:13 +0100
committertv <tv@shackspace.de>2015-01-11 21:53:13 +0100
commit5273db3d5c21cd4ef331df57e09c58c93bcc3f46 (patch)
treedd62e266744497088f2749568b797793e5daf208 /test5.hs
parentdf057aa8493de81770576c596fe6a497605481ea (diff)
notmuch insert reply drafts
Diffstat (limited to 'test5.hs')
-rw-r--r--test5.hs26
1 files changed, 25 insertions, 1 deletions
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