]> git.notmuchmail.org Git - notmuch/commitdiff
make control-p go to previous message
authorBart Trojanowski <bart@jukie.net>
Fri, 20 Nov 2009 20:23:02 +0000 (15:23 -0500)
committerBart Trojanowski <bart@jukie.net>
Wed, 25 Nov 2009 05:48:52 +0000 (00:48 -0500)
vim/README
vim/plugin/notmuch.vim

index 31f1e20b1eb9a066db5e700dfa8926938768cfb0..207799942a2a4e5349a58bf0925dc6579b94f10b 100644 (file)
@@ -33,6 +33,7 @@ Buffer types:
 
         Keybindings:
             ^n      - next message
 
         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
             b       - toggle folding of message bodies
             c       - toggle folding of citations
             h       - toggle folding of extra header lines
index 9e5ee39a9fa1daaa817b52bcfd71ad04bcca32f4..2ddc8160417b5552e77274c057d8819474e658e6 100644 (file)
@@ -90,8 +90,8 @@ let g:notmuch_search_maps = {
 
 " --- --- bindings for show screen {{{2
 let g:notmuch_show_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>',
         \ '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
 
 
 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
 
 endfunction
 
-function! s:NM_show_next()
+function! s:NM_show_next(can_change_thread)
         let info = b:nm_raw_info
         let lnum = line('.')
         let info = b:nm_raw_info
         let lnum = line('.')
-        let cnt = 0
         for msg in info['msgs']
         for msg in info['msgs']
-                let cnt = cnt + 1
                 if lnum >= msg['start']
                         continue
                 endif
 
                 exec printf('norm %dG', msg['start'])
                 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 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()
 endfunction
 
 function! s:NM_show_archive_thread()