3 if exists("b:did_indent")
9 if !exists("g:mail_itemize_chars")
10 let g:mail_itemize_chars='o*+-'
13 let s:item_cap_re='^ *\(['.g:mail_itemize_chars.']\) .*$'
14 let s:item_re='^ *['.g:mail_itemize_chars.'] '
15 let s:void_re='^\([>}].*\| *\)$'
18 setlocal comments=n:},n:>
20 setlocal nosmartindent
22 setlocal indentexpr=GetMailIndent()
23 setlocal indentkeys=!^F,*<return>,o,O,<space>
25 " Only define the function once.
26 if exists("*GetMailIndent")
30 function! s:GetItemIndent(lnum)
32 let char = substitute(getline(lnum), s:item_cap_re, '\1', '')
38 let line = getline(lnum)
39 let ind = indent(lnum)
42 return lastind < 0 ? 2 : lastind
53 if char == substitute(line, s:item_cap_re, '\1', '')
62 function GetMailIndent()
67 let ind2 = indent(v:lnum - 2)
68 let ind1 = indent(v:lnum - 1)
69 let pre2 = getline(v:lnum - 2)
70 let pre1 = getline(v:lnum - 1)
71 let cur = getline(v:lnum)
73 if cur =~ s:void_re || pre1 == '-- ' || cur =~ '-- '
81 elseif pre2 =~ s:void_re || (ind2 <= 2 && pre2 =~ '[^a-zA-Z0-9]$')
85 let len = strlen(pre1) + strlen( substitute(cur, '^ *\([^ ]*\).*$', '\1', '') )
86 if pre1 =~ '[^a-zA-Z0-9]$' && len + 1 < &tw
87 if ind1 <= 2 && pre1 !~ s:item_re
95 let ind = s:GetItemIndent(v:lnum)
101 " vim: set sts=2 sw=2: