make control-p go to previous message

This commit is contained in:
Bart Trojanowski 2009-11-20 15:23:02 -05:00
parent 75ae11ebd2
commit 71c9dbb71d
2 changed files with 42 additions and 11 deletions

View file

@ -33,6 +33,7 @@ Buffer types:
Keybindings: Keybindings:
^n - next message ^n - next message
^p - previous message
b - toggle folding of message bodies b - toggle folding of message bodies
c - toggle folding of citations c - toggle folding of citations
h - toggle folding of extra header lines h - toggle folding of extra header lines

View file

@ -90,8 +90,8 @@ let g:notmuch_search_maps = {
" --- --- bindings for show screen {{{2 " --- --- bindings for show screen {{{2
let g:notmuch_show_maps = { let g:notmuch_show_maps = {
\ '<C-P>': ':call <SID>NM_show_prev()<CR>', \ '<C-P>': ':call <SID>NM_show_prev(1)<CR>',
\ '<C-N>': ':call <SID>NM_show_next()<CR>', \ '<C-N>': ':call <SID>NM_show_next(1)<CR>',
\ 'q': ':call <SID>NM_kill_this_buffer()<CR>', \ 'q': ':call <SID>NM_kill_this_buffer()<CR>',
\ \
\ 'b': ':call <SID>NM_show_fold_toggle(''b'', ''bdy'', !g:notmuch_show_fold_bodies)<CR>', \ 'b': ':call <SID>NM_show_fold_toggle(''b'', ''bdy'', !g:notmuch_show_fold_bodies)<CR>',
@ -313,26 +313,56 @@ function! s:NM_cmd_show(words)
endfunction endfunction
function! s:NM_show_prev() function! s:NM_show_prev(can_change_thread)
echoe "not implemented" let info = b:nm_raw_info
endfunction let lnum = line('.')
for msg in reverse(copy(info['msgs']))
function! s:NM_show_next() 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 <SID>NM_kill_this_buffer()
if line('.') != line('0')
norm k
call <SID>NM_search_show_thread()
norm G
call <SID>NM_show_prev(0)
else
echo 'No more messages.'
endif
endfunction
function! s:NM_show_next(can_change_thread)
let info = b:nm_raw_info let info = b:nm_raw_info
let lnum = line('.') let lnum = line('.')
let cnt = 0
for msg in info['msgs'] for msg in info['msgs']
let cnt = cnt + 1
if lnum >= msg['start'] if lnum >= msg['start']
continue continue
endif endif
exec printf('norm %dG', msg['start']) exec printf('norm %dG', msg['start'])
" TODO: try to fit the message on screen
norm zz norm zz
return return
endfor endfor
norm qj if !a:can_change_thread
call <SID>NM_search_show_thread() return
endif
call <SID>NM_kill_this_buffer()
if line('.') != line('$')
norm j
call <SID>NM_search_show_thread()
else
echo 'No more messages.'
endif
endfunction endfunction
function! s:NM_show_archive_thread() function! s:NM_show_archive_thread()