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+=a
5 setlocal formatoptions+=w
9 " Dynamically set format options, depending on where you are in a
10 " mail, idea from Teemu Likonen:
11 " http://groups.google.com/group/vim_use/msg/f59e5c1adc6be2b3
13 let s:defaults = "setlocal fo=".&fo
14 " tw=".&tw." ts=".&ts." sts=".&sts." sw=".&sw." fo=".&fo
16 let b:MailAreaDetect=1
18 nnoremap <buffer><silent> <F9> :call <SID>MailAreaDetect_Switch(0)<CR>
19 inoremap <buffer><silent> <F9> <C-\><C-O>:call <SID>MailAreaDetect_Switch(1)<CR>
21 function! s:MailAreaDetect_Switch(vmode)
23 silent call <SID>MailAreaDetect_Off()
24 let b:MailAreaDetect=0
25 echo 'MailAreaDetect Off'
30 silent call <SID>MailAreaDetect_On()
31 let b:MailAreaDetect=1
32 echo 'MailAreaDetect On'
39 function! s:MailAreaDetect_On()
40 silent autocmd! MailAreaDetect CursorMoved,CursorMoved
41 \ <buffer> call <SID>AreaOptions()
42 let b:MailAreaDetect=1
45 function! s:MailAreaDetect_Off()
46 silent autocmd! MailAreaDetect
48 let b:MailAreaDetect=0
51 augroup MailAreaDetect
53 call <SID>MailAreaDetect_On()
56 function! s:AreaOptions()
59 let s:synCur = synIDattr(synID(line("."),1,0),"name")
60 let s:synNext = synIDattr(synID(line(".")+1,1,0),"name")
62 if s:synNext =~ '^mailQuote' && s:synCur == '' && getline('.') =~ '^.'
63 " elseif getline('.') =~ '^\s*[^>]' && getline(line('.')+1) =~ '\m^\s*>'
65 "echo 'Quotation leader (fo='.&fo.')'
66 elseif s:synCur =~ '^mailQuote'
67 " elseif getline('.') =~ '\m^\s*>'
69 "echo 'Quotation (fo='.&fo.')'
70 elseif <SID>CheckArea('\m^--- .*\n^+++ ','\v(^$|\n^-- $)')
71 setlocal fo-=a fo-=w fo-=t noet
72 "echo 'Patch (fo='.&fo.')'
73 elseif s:synCur == '' && s:synNext =~ '^mailSignature'
74 " elseif getline(line('.')+1) =~ '\m^-- $'
75 setlocal fo-=a fo-=w fo-=t
76 "echo 'Last line before signature (fo='.&fo.')'
77 elseif s:synCur =~ '^mailSignature'
78 " elseif <SID>CheckArea('^-- $','^$')
79 setlocal fo-=a fo-=w fo-=t
80 "echo 'Signature (fo='.&fo.')'
81 elseif s:synCur =~ '^mail'
82 " if <SID>CheckArea('\v^From( |: ).*\n','\v^$')
83 setlocal fo-=a fo-=w fo-=t
84 "echo 'Header (fo='.&fo.')'
86 "echo 'My text (fo='.&fo.')'
90 function! s:CheckArea(start, end)
91 return (search(a:start,'bcnW')-line('.')) >
92 \ (search(a:end,'bnW')-line('.'))
97 let l:lineNxt = getline(l:i)
98 let l:synNxt = synIDattr(synID(l:i,1,0),"name")
99 while l:i < line('$')-1
100 let l:lineCur = l:lineNxt
101 let l:synCur = l:synNxt
102 let l:lineNxt = getline(l:i+1)
103 let l:synNxt = synIDattr(synID(l:i+1,1,0),"name")
104 if l:synCur =~ '^mailQuote' && l:lineCur =~ '\w.*\S$' &&
105 \ l:synNxt =~ '^mailQuote' && l:lineNxt =~ '\w'
106 call setline(l:i, l:lineCur . ' ')
114 autocmd BufWinEnter $TMPDIR/mutt-* call FixQuotes()
117 nmap <buffer> <C-P><F1> :w<CR>:%!mailplate --keep-unknown official<CR>
118 nmap <buffer> <C-P><F2> :w<CR>:%!mailplate --keep-unknown tahi<CR>
119 nmap <buffer> <C-P><F3> :w<CR>:%!mailplate --keep-unknown pmvm<CR>
120 nmap <buffer> <C-P><F4> :w<CR>:%!mailplate --keep-unknown pobox<CR>
121 nmap <buffer> <C-P><F5> :w<CR>:%!mailplate --keep-unknown debian<CR>
122 nmap <buffer> <C-P><F6> :w<CR>:%!mailplate --keep-unknown debconf<CR>
123 nmap <buffer> <C-P><F7> :w<CR>:%!mailplate --keep-unknown uniwh<CR>
124 nmap <buffer> <C-P><F8> :w<CR>:%!mailplate --keep-unknown mtfk<CR>
125 nmap <buffer> <C-P><F9> :w<CR>:%!mailplate --keep-unknown sudetia<CR>
126 nmap <buffer> <C-P><F12> :w<CR>:%!mailplate --keep-unknown private<CR>
127 nmap <buffer> <F1> :w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>
129 " change subject line
130 " Before: Subject: old
131 " After : Subject: New (was: old)
132 " http://strcat.de/wiki/dotfiles#vim
133 " map ,sw 1G/^Subject: <CR>:s/Re:/was:/<CR>Wi (<C-O>$)<ESC>0Whi
134 map <Leader>ns 1G/^Subject: /<CR>:s,\(Subject: \)\(Re: \)*\(.*\)$,\1 (was: \3),<CR>:set nohls<CR>f li
136 " Delete 'was' in the Subject.
137 " Before: Subject: New (was: old)
138 " After : Subject: New
139 " http://strcat.de/wiki/dotfiles#vim
140 map <Leader>dw 1G/^Subject: /<CR>:s, *(was: .*)$<CR>:set nohls<CR>f l
142 " http://dollyfish.net.nz/blog/2008-04-01/mutt-and-vim-custom-autocompletion
143 fun! LBDBCompleteFn(findstart, base)
144 let line = getline('.')
146 " locate the start of the word
147 let start = col('.') - 1
148 while start > 0 && line[start - 1] =~ '[^:,]'
151 while start < col('.') && line[start] =~ '[:, ]'
157 let query = substitute(a:base, '"', '', 'g')
158 let query = substitute(query, '\s*<.*>\s*', '', 'g')
159 for m in LbdbQuery(query)
160 call complete_add(printf('"%s" <%s>', escape(m[0], '"'), m[1]))
168 set completefunc=LBDBCompleteFn
170 " And this magic by James Vega, which ensures that we only complete with lbdb
171 " on the recipient lines of the mail header.
172 inoremap <expr> <C-n> DelegateCompletion(1)
173 inoremap <expr> <C-p> DelegateCompletion(0)
175 fun! DelegateCompletion(next)
176 if getline('.') =~? '^\%(To\|B\=Cc\):'