All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 setlocal formatoptions-=o
3 setlocal formatoptions-=r
4 setlocal formatoptions-=l
5 setlocal formatoptions+=a
6 setlocal formatoptions+=w
7 setlocal formatoptions+=n
13 augroup tsperrorinsert
22 " Dynamically set format options, depending on where you are in a
23 " mail, idea from Teemu Likonen:
24 " http://groups.google.com/group/vim_use/msg/f59e5c1adc6be2b3
26 let s:defaults = "setlocal fo=".&fo
27 " tw=".&tw." ts=".&ts." sts=".&sts." sw=".&sw." fo=".&fo
29 let b:MailAreaDetect=1
31 nnoremap <buffer><silent> <F9> :call <SID>MailAreaDetect_Switch(0)<CR>
32 inoremap <buffer><silent> <F9> <C-\><C-O>:call <SID>MailAreaDetect_Switch(1)<CR>
34 function! s:MailAreaDetect_Switch(vmode)
36 silent call <SID>MailAreaDetect_Off()
37 let b:MailAreaDetect=0
38 echo 'MailAreaDetect Off'
43 silent call <SID>MailAreaDetect_On()
44 let b:MailAreaDetect=1
45 echo 'MailAreaDetect On'
52 function! s:MailAreaDetect_On()
53 silent autocmd! MailAreaDetect CursorMoved,CursorMoved
54 \ <buffer> call <SID>AreaOptions()
55 let b:MailAreaDetect=1
58 function! s:MailAreaDetect_Off()
59 silent autocmd! MailAreaDetect
61 let b:MailAreaDetect=0
64 augroup MailAreaDetect
66 call <SID>MailAreaDetect_On()
69 function! s:AreaOptions()
72 let s:synCur = synIDattr(synID(line("."),1,0),"name")
73 let s:synNext = synIDattr(synID(line(".")+1,1,0),"name")
75 if s:synNext =~ '^mailQuote' && s:synCur == '' && getline('.') =~ '^.'
76 " elseif getline('.') =~ '^\s*[^>]' && getline(line('.')+1) =~ '\m^\s*>'
78 "echo 'Quotation leader (fo='.&fo.')'
79 elseif s:synCur =~ '^mailQuote'
80 " elseif getline('.') =~ '\m^\s*>'
82 "echo 'Quotation (fo='.&fo.')'
83 elseif <SID>CheckArea('\m^--- .*\n^+++ ','\v(^$|\n^-- $)')
84 setlocal fo-=a fo-=w fo-=t noet
85 "echo 'Patch (fo='.&fo.')'
86 elseif s:synCur == '' && s:synNext =~ '^mailSignature'
87 " elseif getline(line('.')+1) =~ '\m^-- $'
88 setlocal fo-=a fo-=w fo-=t
89 "echo 'Last line before signature (fo='.&fo.')'
90 elseif s:synCur =~ '^mailSignature'
91 " elseif <SID>CheckArea('^-- $','^$')
92 setlocal fo-=a fo-=w fo-=t
93 "echo 'Signature (fo='.&fo.')'
94 elseif s:synCur =~ '^mail'
95 " if <SID>CheckArea('\v^From( |: ).*\n','\v^$')
96 setlocal fo-=a fo-=w fo-=t
97 "echo 'Header (fo='.&fo.')'
99 "echo 'My text (fo='.&fo.')'
103 function! s:CheckArea(start, end)
104 return (search(a:start,'bcnW')-line('.')) >
105 \ (search(a:end,'bnW')-line('.'))
108 function! FixQuotes()
110 let l:lineNxt = getline(l:i)
111 let l:synNxt = synIDattr(synID(l:i,1,0),"name")
112 while l:i < line('$')-1
113 let l:lineCur = l:lineNxt
114 let l:synCur = l:synNxt
115 let l:lineNxt = getline(l:i+1)
116 let l:synNxt = synIDattr(synID(l:i+1,1,0),"name")
117 if l:synCur =~ '^mailQuote' && l:lineCur =~ '\w.*\S$' &&
118 \ l:synNxt =~ '^mailQuote' && l:lineNxt =~ '\w'
119 call setline(l:i, l:lineCur . ' ')
127 autocmd BufWinEnter $TMPDIR/mutt-* call FixQuotes()
130 nmap <buffer> <C-P><F1> :w<CR>:%!mailplate --keep-unknown official<CR>
131 nmap <buffer> <C-P><F2> :w<CR>:%!mailplate --keep-unknown tahi<CR>
132 nmap <buffer> <C-P><F3> :w<CR>:%!mailplate --keep-unknown kiwi<CR>
133 nmap <buffer> <C-P><F4> :w<CR>:%!mailplate --keep-unknown pobox<CR>
134 nmap <buffer> <C-P><F5> :w<CR>:%!mailplate --keep-unknown kbkg<CR>
135 nmap <buffer> <C-P><F6> :w<CR>:%!mailplate --keep-unknown debian<CR>
136 nmap <buffer> <C-P><F7> :w<CR>:%!mailplate --keep-unknown uniwh<CR>
137 nmap <buffer> <C-P><F8> :w<CR>:%!mailplate --keep-unknown mtfk<CR>
138 nmap <buffer> <C-P><F9> :w<CR>:%!mailplate --keep-unknown sudetia<CR>
139 nmap <buffer> <C-P><F11> :w<CR>:%!mailplate --keep-unknown thorndonsquashtc<CR>
140 nmap <buffer> <C-P><F12> :w<CR>:%!mailplate --keep-unknown default<CR>
141 nmap <buffer> <F1> :w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>
143 " change subject line
144 " Before: Subject: old
145 " After : Subject: New (was: old)
146 " http://strcat.de/wiki/dotfiles#vim
147 " map ,sw 1G/^Subject: <CR>:s/Re:/was:/<CR>Wi (<C-O>$)<ESC>0Whi
148 map <Leader>ns 1G/^Subject: /<CR>:s,\(Subject: \)\(Re: \)*\(.*\)$,\1 (was: \3),<CR>:set nohls<CR>f li
150 " Delete 'was' in the Subject.
151 " Before: Subject: New (was: old)
152 " After : Subject: New
153 " http://strcat.de/wiki/dotfiles#vim
154 map <Leader>dw 1G/^Subject: /<CR>:s, *(was: .*)$<CR>:set nohls<CR>f l
156 " http://dollyfish.net.nz/blog/2008-04-01/mutt-and-vim-custom-autocompletion
157 fun! LBDBCompleteFn(findstart, base)
158 let line = getline('.')
160 " locate the start of the word
161 let start = col('.') - 1
162 while start > 0 && line[start - 1] =~ '[^:,]'
165 while start < col('.') && line[start] =~ '[:, ]'
171 let query = substitute(a:base, '"', '', 'g')
172 let query = substitute(query, '\s*<.*>\s*', '', 'g')
173 for m in LbdbQuery(query)
174 call complete_add(printf('"%s" <%s>', escape(m[0], '"'), m[1]))
182 set completefunc=LBDBCompleteFn
184 " And this magic by James Vega, which ensures that we only complete with lbdb
185 " on the recipient lines of the mail header.
186 inoremap <expr> <C-n> DelegateCompletion(1)
187 inoremap <expr> <C-p> DelegateCompletion(0)
189 fun! DelegateCompletion(next)
190 if getline('.') =~? '^\%(To\|B\=Cc\):'
199 autocmd BufWritePost <buffer> exe 'write ' . fnameescape((exists('$TMPDIR') ? expand('$TMPDIR') : '/tmp') . '/mail.backup.' . strftime('%Y-%m-%d-%H%M%S'))
201 let g:markdown_in_mail = 1
202 runtime! ftplugin/markdown.vim