aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim
diff options
context:
space:
mode:
authorGravatar Bart Trojanowski <bart@jukie.net>2009-11-20 15:23:02 -0500
committerGravatar Bart Trojanowski <bart@jukie.net>2009-11-25 00:48:52 -0500
commit71c9dbb71db5de37d647ca9899e4749be305b622 (patch)
treeecc1f6bfdaab4d8be3064a6af55151a6fda44402 /vim
parent75ae11ebd222cbbc19817be0cc6998cb6b1456d4 (diff)
make control-p go to previous message
Diffstat (limited to 'vim')
-rw-r--r--vim/README1
-rw-r--r--vim/plugin/notmuch.vim48
2 files changed, 40 insertions, 9 deletions
diff --git a/vim/README b/vim/README
index 31f1e20b..20779994 100644
--- a/vim/README
+++ b/vim/README
@@ -33,6 +33,7 @@ Buffer types:
Keybindings:
^n - next message
+ ^p - previous message
b - toggle folding of message bodies
c - toggle folding of citations
h - toggle folding of extra header lines
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 = {
- \ '<C-P>': ':call <SID>NM_show_prev()<CR>',
- \ '<C-N>': ':call <SID>NM_show_next()<CR>',
+ \ '<C-P>': ':call <SID>NM_show_prev(1)<CR>',
+ \ '<C-N>': ':call <SID>NM_show_next(1)<CR>',
\ 'q': ':call <SID>NM_kill_this_buffer()<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
-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 <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()
+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 <SID>NM_search_show_thread()
+ if !a:can_change_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
function! s:NM_show_archive_thread()