]> git.notmuchmail.org Git - notmuch/blobdiff - vim/plugin/notmuch.vim
correct fold line counts
[notmuch] / vim / plugin / notmuch.vim
index c45b8e15a782b9fa1d4f3829bd5b572ad216dcac..43f6f542c266261dfe95345b53af2e6eaa7448a0 100644 (file)
@@ -468,8 +468,10 @@ function! s:NM_cmd_show_parse(inlines)
                                 elseif mode_type == 'cit'
                                         if part_end || match(line, g:notmuch_show_citation_regexp) == -1
                                                 let outlnum = len(info['disp'])
-                                                let foldinfo = [ mode_type, mode_start, outlnum-1,
-                                                               \ printf('[ %d-line citation.  Press "c" to show. ]', outlnum - mode_start) ]
+                                                if mode_start != outlnum
+                                                        let foldinfo = [ mode_type, mode_start, outlnum-1,
+                                                                       \ printf('[ %d-line citation.  Press "c" to show. ]', outlnum - mode_start) ]
+                                                endif
                                                 let mode_type = ''
                                         endif
                                 elseif mode_type == 'sig'
@@ -477,8 +479,10 @@ function! s:NM_cmd_show_parse(inlines)
                                         if (outlnum - mode_start) > g:notmuch_show_signature_lines_max
                                                 let mode_type = ''
                                         elseif part_end
-                                                let foldinfo = [ mode_type, mode_start, outlnum,
-                                                               \ printf('[ %d-line signature.  Press "s" to show. ]', outlnum - mode_start) ]
+                                                if mode_start != outlnum
+                                                        let foldinfo = [ mode_type, mode_start, outlnum-1,
+                                                                       \ printf('[ %d-line signature.  Press "s" to show. ]', outlnum - mode_start) ]
+                                                endif
                                                 let mode_type = ''
                                         endif
                                 endif
@@ -532,7 +536,7 @@ function! s:NM_cmd_show_parse(inlines)
                                         let hdr_start = msg['hdr_start']+1
                                         let hdr_end = len(info['disp'])
                                         let foldinfo = [ 'hdr', hdr_start, hdr_end,
-                                               \ printf('[ %d-line headers.  Press "h" to show. ]', hdr_end - hdr_start) ]
+                                               \ printf('[ %d-line headers.  Press "h" to show. ]', hdr_end + 1 - hdr_start) ]
                                         let msg['header'] = hdr
                                         let in_header = 0
                                         let hdr = {}
@@ -741,9 +745,12 @@ endif
 " --- assign keymaps {{{1
 
 function! s:NM_set_map(maps)
+        nmapclear
         for [key, code] in items(a:maps)
                 exec printf('nnoremap <buffer> %s %s', key, code)
         endfor
+        " --- this is a hack for development :)
+        nnoremap ,nmr :source ~/.vim/plugin/notmuch.vim<CR>:call NotMuch('')<CR>
 endfunction
 
 " --- command handler {{{1
@@ -774,8 +781,4 @@ endfunction
 command! -nargs=* -complete=customlist,CompleteNotMuch NotMuch call NotMuch(<q-args>)
 cabbrev  notmuch <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'NotMuch' : 'notmuch')<CR>
 
-" --- hacks, only for development :) {{{1
-
-nnoremap ,nmr :source ~/.vim/plugin/notmuch.vim<CR>:call NotMuch('')<CR>
-
 " vim: set ft=vim ts=8 sw=8 et foldmethod=marker :