diff options
author | tv <tv@shackspace.de> | 2014-12-31 13:25:59 +0100 |
---|---|---|
committer | tv <tv@shackspace.de> | 2014-12-31 13:25:59 +0100 |
commit | 3b7e06df9ac0856ddeb52434867a3fdb44d86b3a (patch) | |
tree | 836bd72e577a5adfedce8f94a0b711aa03dec1c2 | |
parent | 3c70b1c4a5dd2e66280bc234d5d4e626ded4cc33 (diff) |
{S-,}-\t moves to {prev,next} unread {M,SR}
M = message
SR = search result
-rw-r--r-- | test5.hs | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -232,8 +232,8 @@ keymap "\ESC[d" = moveTreeRight 1 -- S-Left keymap "\ESC[5~" = \q -> moveTreeDown (screenHeight q `div` 2) q -- PgUp keymap "\ESC[6~" = \q -> moveTreeUp (screenHeight q `div` 2) q -- PgDn keymap "\n" = toggleFold -keymap "\ESC[Z" = moveCursorUpToPrevUnreadMessage -- S-Tab -keymap "\t" = moveCursorDownToNextUnreadMessage +keymap "\ESC[Z" = moveCursorUpToPrevUnread -- S-Tab +keymap "\t" = moveCursorDownToNextUnread keymap "\DEL" = moveToParent -- backspace -- TODO Stuff Vim sends after exit (also there is more...) @@ -338,13 +338,13 @@ moveToParent q@State{..} = i -> moveTreeDown i q' -moveCursorToUnreadMessage +moveCursorToUnread :: (Num a, Monad m, Eq a) => (Z.TreePos Z.Full TreeView -> Maybe (Z.TreePos Z.Full TreeView)) -> (State -> a) -> (a -> State -> m State) -> State -> m State -moveCursorToUnreadMessage cursorMove getTreeMoveCount treeMove q@State{..} = +moveCursorToUnread cursorMove getTreeMoveCount treeMove q@State{..} = case cursorMove cursor >>= rec of Just cursor' -> let q' = q { cursor = cursor' } @@ -355,23 +355,25 @@ moveCursorToUnreadMessage cursorMove getTreeMoveCount treeMove q@State{..} = return q { flashMessage = "no unread message in sight" } where rec loc = - if isUnreadMessage loc + if isUnread loc then Just loc else cursorMove loc >>= rec - isUnreadMessage loc = + isUnread loc = case Z.label loc of + TVSearchResult sr -> + "unread" `elem` Notmuch.searchTags sr TVMessage m -> "unread" `elem` Notmuch.messageTags m _ -> False -moveCursorUpToPrevUnreadMessage :: Monad m => State -> m State -moveCursorUpToPrevUnreadMessage = - moveCursorToUnreadMessage findPrev topOverrun moveTreeDown +moveCursorUpToPrevUnread :: Monad m => State -> m State +moveCursorUpToPrevUnread = + moveCursorToUnread findPrev topOverrun moveTreeDown -moveCursorDownToNextUnreadMessage :: Monad m => State -> m State -moveCursorDownToNextUnreadMessage = - moveCursorToUnreadMessage findNext botOverrun moveTreeUp +moveCursorDownToNextUnread :: Monad m => State -> m State +moveCursorDownToNextUnread = + moveCursorToUnread findNext botOverrun moveTreeUp toggleFold :: State -> IO State |