From 900cadc72f03c2db4822498d1540d29f72b03fa6 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 7 Jan 2015 01:00:55 +0100 Subject: purge getThread --- Notmuch.hs | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/Notmuch.hs b/Notmuch.hs index 6439d97..59067cf 100644 --- a/Notmuch.hs +++ b/Notmuch.hs @@ -2,36 +2,17 @@ {-# LANGUAGE OverloadedStrings #-} module Notmuch where ---import Language.Haskell.TH.Ppr (bytesToString) +import qualified Data.ByteString.Lazy as LBS +import Control.Concurrent +import Control.DeepSeq (rnf) +import Control.Exception import Data.Aeson ---import Data.List.Split ---import Data.Attoparsec.ByteString hiding (try) -import Data.Maybe import Data.Monoid -import Data.String ---import Data.Traversable import Data.Tree ---import qualified Data.ByteString as BS -import qualified Data.ByteString.Lazy as LBS ---import qualified Data.ByteString.Char8 as BS8 ---import qualified Data.Text.Lazy as TL -import qualified Data.Text as T ---import qualified Data.Text.Encoding as T -import qualified Data.Text.IO as T ---import Data.Version (Version(..), parseVersion) -import System.Process ---import System.IO -import qualified Data.Map as M - -import Notmuch.SearchResult import Notmuch.Message - - -import Control.Concurrent ---import Control.Concurrent.MVar -import Control.Exception +import Notmuch.SearchResult import System.IO -import Control.DeepSeq (rnf) +import System.Process -- | Fork a thread while doing something else, but kill it if there's an @@ -111,18 +92,13 @@ notmuchReply replyTo term = -- >>= return . eitherDecode' -getThread :: String -> IO (Forest Message) -getThread tid = do +notmuchShow :: String -> IO (Forest Message) +notmuchShow term = do c' <- notmuch [ "show", "--format=json", "--format-version=2" - , "thread:" <> tid ] - - let threads = case eitherDecode' c' :: Either String [Thread] of - Left err -> error err - Right x -> x - --threadsF = map threadForest threads - ttt = threadForest $ head $ threads - return ttt - + , term ] + -- TODO why head? + return $ threadForest $ head $ + either error id (eitherDecode' c') setTag :: String -> String -> IO LBS.ByteString -- cgit v1.2.3