summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Core.hs10
-rw-r--r--State.hs1
2 files changed, 7 insertions, 4 deletions
diff --git a/Core.hs b/Core.hs
index 5073c59..d5fbc88 100644
--- a/Core.hs
+++ b/Core.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Core where
@@ -40,6 +41,7 @@ emptyState = State
, treeBuffer = []
, now = UTCTime (fromGregorian 1984 5 23) 49062
, signalHandlers = []
+ , query = "tag:inbox AND NOT tag:killed"
, keymap = displayKey
, mousemap = displayMouse
, colorConfig = ColorConfig
@@ -63,8 +65,8 @@ emptyState = State
, tagSymbols = []
}
-withQuery :: String -> State -> IO State
-withQuery query q = do
+notmuchSearch :: State -> IO State
+notmuchSearch q@State{query} = do
r_ <- either error id <$> Notmuch.search
[ "--offset=0"
, "--limit=100"
@@ -77,11 +79,11 @@ mainWithState :: State -> IO ()
mainWithState state = mainWithStateAndArgs state =<< getArgs
mainWithStateAndArgs :: State -> [String] -> IO ()
-mainWithStateAndArgs state args = do
+mainWithStateAndArgs state@State{query = defaultSearch} args = do
usage' <- parseUsageOrExit usage
args' <- parseArgsOrExit usage' args
let query = getArgWithDefault args' defaultSearch (shortOption 'q')
- withScreen s0 (\_-> withQuery query state >>= runState)
+ withScreen s0 (\_-> notmuchSearch state { query = query } >>= runState)
where
usage = unlines
[ "Command-line MUA using notmuch."
diff --git a/State.hs b/State.hs
index abd25b0..21c0122 100644
--- a/State.hs
+++ b/State.hs
@@ -20,6 +20,7 @@ data State = State
, treeBuffer :: [Blessings String]
, now :: UTCTime
, signalHandlers :: [(Signal, IO ())]
+ , query :: String
, keymap :: String -> State -> IO State
, mousemap :: Scan -> State -> IO State
, tagSymbols :: [(T.Text, T.Text)]