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
11 augroup tsperrorinsert
20 " Dynamically set format options, depending on where you are in a
21 " mail, idea from Teemu Likonen:
22 " http://groups.google.com/group/vim_use/msg/f59e5c1adc6be2b3
24 let s:defaults = "setlocal fo=".&fo
25 " tw=".&tw." ts=".&ts." sts=".&sts." sw=".&sw." fo=".&fo
27 let b:MailAreaDetect=1
29 nnoremap <buffer><silent> <F9> :call <SID>MailAreaDetect_Switch(0)<CR>
30 inoremap <buffer><silent> <F9> <C-\><C-O>:call <SID>MailAreaDetect_Switch(1)<CR>
32 function! s:MailAreaDetect_Switch(vmode)
34 silent call <SID>MailAreaDetect_Off()
35 let b:MailAreaDetect=0
36 echo 'MailAreaDetect Off'
41 silent call <SID>MailAreaDetect_On()
42 let b:MailAreaDetect=1
43 echo 'MailAreaDetect On'
50 function! s:MailAreaDetect_On()
51 silent autocmd! MailAreaDetect CursorMoved,CursorMoved
52 \ <buffer> call <SID>AreaOptions()
53 let b:MailAreaDetect=1
56 function! s:MailAreaDetect_Off()
57 silent autocmd! MailAreaDetect
59 let b:MailAreaDetect=0
62 augroup MailAreaDetect
64 call <SID>MailAreaDetect_On()
67 function! s:AreaOptions()
70 let s:synCur = synIDattr(synID(line("."),1,0),"name")
71 let s:synNext = synIDattr(synID(line(".")+1,1,0),"name")
73 if s:synNext =~ '^mailQuote' && s:synCur == '' && getline('.') =~ '^.'
74 " elseif getline('.') =~ '^\s*[^>]' && getline(line('.')+1) =~ '\m^\s*>'
76 "echo 'Quotation leader (fo='.&fo.')'
77 elseif s:synCur =~ '^mailQuote'
78 " elseif getline('.') =~ '\m^\s*>'
80 "echo 'Quotation (fo='.&fo.')'
81 elseif <SID>CheckArea('\m^--- .*\n^+++ ','\v(^$|\n^-- $)')
82 setlocal fo-=a fo-=w fo-=t noet
83 "echo 'Patch (fo='.&fo.')'
84 elseif s:synCur == '' && s:synNext =~ '^mailSignature'
85 " elseif getline(line('.')+1) =~ '\m^-- $'
86 setlocal fo-=a fo-=w fo-=t
87 "echo 'Last line before signature (fo='.&fo.')'
88 elseif s:synCur =~ '^mailSignature'
89 " elseif <SID>CheckArea('^-- $','^$')
90 setlocal fo-=a fo-=w fo-=t
91 "echo 'Signature (fo='.&fo.')'
92 elseif s:synCur =~ '^mail'
93 " if <SID>CheckArea('\v^From( |: ).*\n','\v^$')
94 setlocal fo-=a fo-=w fo-=t
95 "echo 'Header (fo='.&fo.')'
97 "echo 'My text (fo='.&fo.')'
101 function! s:CheckArea(start, end)
102 return (search(a:start,'bcnW')-line('.')) >
103 \ (search(a:end,'bnW')-line('.'))
106 function! FixQuotes()
108 let l:lineNxt = getline(l:i)
109 let l:synNxt = synIDattr(synID(l:i,1,0),"name")
110 while l:i < line('$')-1
111 let l:lineCur = l:lineNxt
112 let l:synCur = l:synNxt
113 let l:lineNxt = getline(l:i+1)
114 let l:synNxt = synIDattr(synID(l:i+1,1,0),"name")
115 if l:synCur =~ '^mailQuote' && l:lineCur =~ '\w.*\S$' &&
116 \ l:synNxt =~ '^mailQuote' && l:lineNxt =~ '\w'
117 call setline(l:i, l:lineCur . ' ')
125 autocmd BufWinEnter $TMPDIR/mutt-* call FixQuotes()
128 nmap <buffer> <C-P><F1> :w<CR>:%!mailplate --keep-unknown official<CR>
129 nmap <buffer> <C-P><F2> :w<CR>:%!mailplate --keep-unknown tahi<CR>
130 nmap <buffer> <C-P><F3> :w<CR>:%!mailplate --keep-unknown pmvm<CR>
131 nmap <buffer> <C-P><F4> :w<CR>:%!mailplate --keep-unknown pobox<CR>
132 nmap <buffer> <C-P><F5> :w<CR>:%!mailplate --keep-unknown debian<CR>
133 nmap <buffer> <C-P><F6> :w<CR>:%!mailplate --keep-unknown debconf<CR>
134 nmap <buffer> <C-P><F7> :w<CR>:%!mailplate --keep-unknown uniwh<CR>
135 nmap <buffer> <C-P><F8> :w<CR>:%!mailplate --keep-unknown mtfk<CR>
136 nmap <buffer> <C-P><F9> :w<CR>:%!mailplate --keep-unknown sudetia<CR>
137 nmap <buffer> <C-P><F12> :w<CR>:%!mailplate --keep-unknown private<CR>
138 nmap <buffer> <F1> :w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>
140 " change subject line
141 " Before: Subject: old
142 " After : Subject: New (was: old)
143 " http://strcat.de/wiki/dotfiles#vim
144 " map ,sw 1G/^Subject: <CR>:s/Re:/was:/<CR>Wi (<C-O>$)<ESC>0Whi
145 map <Leader>ns 1G/^Subject: /<CR>:s,\(Subject: \)\(Re: \)*\(.*\)$,\1 (was: \3),<CR>:set nohls<CR>f li
147 " Delete 'was' in the Subject.
148 " Before: Subject: New (was: old)
149 " After : Subject: New
150 " http://strcat.de/wiki/dotfiles#vim
151 map <Leader>dw 1G/^Subject: /<CR>:s, *(was: .*)$<CR>:set nohls<CR>f l
153 " http://dollyfish.net.nz/blog/2008-04-01/mutt-and-vim-custom-autocompletion
154 fun! LBDBCompleteFn(findstart, base)
155 let line = getline('.')
157 " locate the start of the word
158 let start = col('.') - 1
159 while start > 0 && line[start - 1] =~ '[^:,]'
162 while start < col('.') && line[start] =~ '[:, ]'
168 let query = substitute(a:base, '"', '', 'g')
169 let query = substitute(query, '\s*<.*>\s*', '', 'g')
170 for m in LbdbQuery(query)
171 call complete_add(printf('"%s" <%s>', escape(m[0], '"'), m[1]))
179 set completefunc=LBDBCompleteFn
181 " And this magic by James Vega, which ensures that we only complete with lbdb
182 " on the recipient lines of the mail header.
183 inoremap <expr> <C-n> DelegateCompletion(1)
184 inoremap <expr> <C-p> DelegateCompletion(0)
186 fun! DelegateCompletion(next)
187 if getline('.') =~? '^\%(To\|B\=Cc\):'
196 autocmd BufWritePost <buffer> exe 'write ' . fnameescape((exists('$TMPDIR') ? expand('$TMPDIR') : '/tmp') . '/mail.backup.' . strftime('%Y-%m-%d-%H%M%S'))