diff options
author | Kierán Meinhardt <kieran.meinhardt@gmail.com> | 2020-09-23 17:15:39 +0200 |
---|---|---|
committer | Kierán Meinhardt <kieran.meinhardt@gmail.com> | 2020-09-23 17:15:39 +0200 |
commit | 171fb04841a657c8721bd370b2acf177ea57ef9d (patch) | |
tree | 09d9f361010ea4d64edddcf0203324fd5ed7d3e7 | |
parent | 984ad66260097f22164d7a174d1292dc2022fc4c (diff) |
State: integrate default query
-rw-r--r-- | Core.hs | 10 | ||||
-rw-r--r-- | State.hs | 1 |
2 files changed, 7 insertions, 4 deletions
@@ -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." @@ -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)] |