X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=b4eeb416ce608ad58b31883639d1f8a03bd76141;hp=f0106604f081a5a296c126a5157f59feb36c8f36;hb=4c9ddb9ac152df442c6971e4448b0839179a5c66;hpb=b440aeb23e8ddc3c88c697718aedab0ab9ca3245 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index f0106604..b4eeb416 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -110,8 +110,8 @@ let g:notmuch_search_maps = { " --- --- bindings for show screen {{{2 let g:notmuch_show_maps = { - \ '': ':call NM_show_previous(1)', - \ '': ':call NM_show_next(1)', + \ '': ':call NM_show_previous(1, 0)', + \ '': ':call NM_show_next(1, 0)', \ '': ':call NM_search_expand('''')', \ 'q': ':call NM_kill_this_buffer()', \ @@ -399,49 +399,56 @@ function! s:NM_cmd_show(words) endfunction -function! s:NM_show_previous(can_change_thread) +function! s:NM_show_previous(can_change_thread, find_matching) let info = b:nm_raw_info let lnum = line('.') for msg in reverse(copy(info['msgs'])) + if a:find_matching && msg['match'] == '0' + continue + endif if lnum <= msg['start'] 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 endfunction -function! s:NM_show_next(can_change_thread) +function! s:NM_show_next(can_change_thread, find_matching) let info = b:nm_raw_info let lnum = line('.') for msg in info['msgs'] + if a:find_matching && msg['match'] == '0' + continue + endif if lnum >= msg['start'] 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 @@ -459,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 @@ -514,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 @@ -785,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