X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=b4eeb416ce608ad58b31883639d1f8a03bd76141;hp=c95e6b0e2c71abb2d2b964106770116d53a79d1d;hb=4c9ddb9ac152df442c6971e4448b0839179a5c66;hpb=0f39d2c4deef6f774e63d78a226857039d0cd978 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index c95e6b0e..b4eeb416 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -410,20 +410,19 @@ function! s:NM_show_previous(can_change_thread, find_matching) continue endif - exec printf('norm %dG', msg['start']) + exec printf('norm %dGzt', 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') + if line('.') > 1 norm k call NM_search_show_thread() norm G - call NM_show_previous(0) + call NM_show_previous(0, a:find_matching) else echo 'No more messages.' endif @@ -440,14 +439,16 @@ function! s:NM_show_next(can_change_thread, find_matching) continue endif - exec printf('norm %dG', msg['start']) + exec printf('norm %dGzt', msg['start']) " TODO: try to fit the message on screen - norm zz return endfor - if !a:can_change_thread - return + if a:can_change_thread + call NM_show_next_thread() endif +endfunction + +function! s:NM_show_next_thread() call NM_kill_this_buffer() if line('.') != line('$') norm j @@ -465,10 +466,6 @@ function! s:NM_show_mark_read_then_archive_thread() echo 'not implemented' endfunction -function! s:NM_show_next_message() - echo 'not implemented' -endfunction - function! s:NM_show_mark_read_then_next_open_message() echo 'not implemented' endfunction @@ -520,22 +517,25 @@ endfunction " --- --- show screen helper functions {{{2 +function! s:NM_show_get_message_for_line(line) + for msg in b:nm_raw_info['msgs'] + if a:line > msg['end'] + continue + endif + return msg + endfor + return {} +endfunction + function! s:NM_show_message_id() if !exists('b:nm_raw_info') echoe 'no b:nm_raw_info' return '' endif - let info = b:nm_raw_info - let lnum = line('.') - for msg in info['msgs'] - if lnum > msg['end'] - continue - endif - if has_key(msg,'id') - return msg['id'] - endif - return '' - endfor + let msg = NM_show_get_message_for_line(line('.')) + if has_key(msg,'id') + return msg['id'] + endif return '' endfunction @@ -791,6 +791,8 @@ function! s:NM_newBuffer(type, content) silent put=a:content keepjumps 0d setlocal nomodifiable + set scrolloff=0 + set sidescrolloff=0 execute printf('set filetype=notmuch-%s', a:type) execute printf('set syntax=notmuch-%s', a:type) let b:nm_type = a:type