+
+ if in_part == 'text/plain'
+ if !part_end && mode_type == ''
+ if match(line, g:notmuch_show_signature_regexp) != -1
+ let mode_type = 'sig'
+ let mode_start = len(info['disp'])
+ elseif match(line, g:notmuch_show_citation_regexp) != -1
+ let mode_type = 'cit'
+ let mode_start = len(info['disp'])
+ endif
+ 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, len(info['msgs']),
+ \ printf('[ %d-line citation. Press "c" to show. ]', outlnum - mode_start) ]
+ let mode_type = ''
+ endif
+ elseif mode_type == 'sig'
+ let outlnum = len(info['disp'])
+ if (outlnum - mode_start) > g:notmuch_show_signature_lines_max
+ let mode_type = ''
+ elseif part_end
+ let foldinfo = [ mode_type, mode_start, outlnum-1, len(info['msgs']),
+ \ printf('[ %d-line signature. Press "s" to show. ]', outlnum - mode_start) ]
+ let mode_type = ''
+ endif
+ endif
+ endif
+
+ if part_end
+ " FIXME: this is a hack for handling two folds being added for one line
+ " we should handle adding a fold in a function
+ if len(foldinfo) && foldinfo[1] < foldinfo[2]
+ call add(info['folds'], foldinfo[0:3])
+ let info['foldtext'][foldinfo[1]] = foldinfo[4]
+ endif
+
+ let foldinfo = [ 'text', part_start, part_end, len(info['msgs']),
+ \ printf('[ %d-line %s. Press "p" to show. ]', part_end - part_start, in_part) ]
+ let in_part = ''
+ call add(info['disp'], '')
+ endif
+
+ elseif in_body
+ if !has_key(msg,'body_start')
+ let msg['body_start'] = len(info['disp']) + 1
+ endif
+ if match(line, g:notmuch_show_body_end_regexp) != -1
+ let body_end = len(info['disp'])
+ let foldinfo = [ 'bdy', body_start, body_end, len(info['msgs']),
+ \ printf('[ BODY %d - %d lines ]', len(info['msgs']), body_end - body_start) ]
+
+ let in_body = 0
+
+ elseif match(line, g:notmuch_show_part_begin_regexp) != -1
+ let m = matchlist(line, 'ID: \(\d\+\), Content-type: \(\S\+\)')
+ let in_part = 'unknown'
+ if len(m)
+ let in_part = m[2]
+ endif
+ call add(info['disp'],
+ \ printf('--- %s ---', in_part))
+ let part_start = len(info['disp']) + 1
+ endif
+
+ elseif in_header
+ if in_header == 1
+ let msg['descr'] = line
+ call add(info['disp'], line)
+ let in_header = 2
+ let msg['hdr_start'] = len(info['disp']) + 1
+
+ else
+ if match(line, g:notmuch_show_header_end_regexp) != -1
+ let hdr_start = msg['hdr_start']+1
+ let hdr_end = len(info['disp'])
+ let foldinfo = [ 'hdr', hdr_start, hdr_end, len(info['msgs']),
+ \ printf('[ %d-line headers. Press "h" to show. ]', hdr_end + 1 - hdr_start) ]
+ let msg['header'] = hdr
+ let in_header = 0
+ let hdr = {}
+ else
+ let m = matchlist(line, '^\(\w\+\):\s*\(.*\)$')
+ if len(m)
+ let hdr[m[1]] = m[2]
+ if match(g:notmuch_show_headers, m[1]) != -1
+ call add(info['disp'], line)
+ endif
+ endif
+ endif
+ endif
+
+ elseif in_message
+ if match(line, g:notmuch_show_message_end_regexp) != -1
+ let msg['end'] = len(info['disp'])
+ call add(info['disp'], '')
+
+ let foldinfo = [ 'msg', msg['start'], msg['end'], len(info['msgs']),
+ \ printf('[ MSG %d - %s ]', len(info['msgs']), msg['descr']) ]
+
+ call add(info['msgs'], msg)
+ let msg = {}
+ let in_message = 0
+ let in_header = 0
+ let in_body = 0
+ let in_part = ''
+
+ elseif match(line, g:notmuch_show_header_begin_regexp) != -1
+ let in_header = 1
+ continue
+
+ elseif match(line, g:notmuch_show_body_begin_regexp) != -1
+ let body_start = len(info['disp']) + 1
+ let in_body = 1
+ continue
+ endif
+
+ else
+ if match(line, g:notmuch_show_message_begin_regexp) != -1
+ let msg['start'] = len(info['disp']) + 1
+
+ let m = matchlist(line, g:notmuch_show_message_parse_regexp)
+ if len(m)
+ let msg['id'] = m[1]
+ let msg['depth'] = m[2]
+ let msg['match'] = m[3]
+ let msg['filename'] = m[4]
+ endif
+
+ let in_message = 1