X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=2ddc8160417b5552e77274c057d8819474e658e6;hp=9e5ee39a9fa1daaa817b52bcfd71ad04bcca32f4;hb=71c9dbb71db5de37d647ca9899e4749be305b622;hpb=75ae11ebd222cbbc19817be0cc6998cb6b1456d4 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index 9e5ee39a..2ddc8160 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -90,8 +90,8 @@ let g:notmuch_search_maps = { " --- --- bindings for show screen {{{2 let g:notmuch_show_maps = { - \ '': ':call NM_show_prev()', - \ '': ':call NM_show_next()', + \ '': ':call NM_show_prev(1)', + \ '': ':call NM_show_next(1)', \ 'q': ':call NM_kill_this_buffer()', \ \ 'b': ':call NM_show_fold_toggle(''b'', ''bdy'', !g:notmuch_show_fold_bodies)', @@ -313,26 +313,56 @@ function! s:NM_cmd_show(words) endfunction -function! s:NM_show_prev() - echoe "not implemented" +function! s:NM_show_prev(can_change_thread) + let info = b:nm_raw_info + let lnum = line('.') + for msg in reverse(copy(info['msgs'])) + if lnum <= msg['start'] + continue + endif + + exec printf('norm %dG', msg['start']) + " TODO: try to fit the message on screen + norm zz + return + endfor + if !a:can_change_thread + return + endif + call NM_kill_this_buffer() + if line('.') != line('0') + norm k + call NM_search_show_thread() + norm G + call NM_show_prev(0) + else + echo 'No more messages.' + endif endfunction -function! s:NM_show_next() +function! s:NM_show_next(can_change_thread) let info = b:nm_raw_info let lnum = line('.') - let cnt = 0 for msg in info['msgs'] - let cnt = cnt + 1 if lnum >= msg['start'] continue endif exec printf('norm %dG', msg['start']) + " TODO: try to fit the message on screen norm zz return endfor - norm qj - call NM_search_show_thread() + if !a:can_change_thread + return + endif + call NM_kill_this_buffer() + if line('.') != line('$') + norm j + call NM_search_show_thread() + else + echo 'No more messages.' + endif endfunction function! s:NM_show_archive_thread()