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
18 " Dynamically set format options, depending on where you are in a
19 " mail, idea from Teemu Likonen:
20 " http://groups.google.com/group/vim_use/msg/f59e5c1adc6be2b3
22 let s:defaults = "setlocal fo=".&fo
23 " tw=".&tw." ts=".&ts." sts=".&sts." sw=".&sw." fo=".&fo
25 let b:MailAreaDetect=1
27 nnoremap <buffer><silent> <F9> :call <SID>MailAreaDetect_Switch(0)<CR>
28 inoremap <buffer><silent> <F9> <C-\><C-O>:call <SID>MailAreaDetect_Switch(1)<CR>
30 function! s:MailAreaDetect_Switch(vmode)
32 silent call <SID>MailAreaDetect_Off()
33 let b:MailAreaDetect=0
34 echo 'MailAreaDetect Off'
39 silent call <SID>MailAreaDetect_On()
40 let b:MailAreaDetect=1
41 echo 'MailAreaDetect On'
48 function! s:MailAreaDetect_On()
49 silent autocmd! MailAreaDetect CursorMoved,CursorMoved
50 \ <buffer> call <SID>AreaOptions()
51 let b:MailAreaDetect=1
54 function! s:MailAreaDetect_Off()
55 silent autocmd! MailAreaDetect
57 let b:MailAreaDetect=0
60 augroup MailAreaDetect
62 call <SID>MailAreaDetect_On()
65 function! s:AreaOptions()
68 let s:synCur = synIDattr(synID(line("."),1,0),"name")
69 let s:synNext = synIDattr(synID(line(".")+1,1,0),"name")
71 if s:synNext =~ '^mailQuote' && s:synCur == '' && getline('.') =~ '^.'
72 " elseif getline('.') =~ '^\s*[^>]' && getline(line('.')+1) =~ '\m^\s*>'
74 "echo 'Quotation leader (fo='.&fo.')'
75 elseif s:synCur =~ '^mailQuote'
76 " elseif getline('.') =~ '\m^\s*>'
78 "echo 'Quotation (fo='.&fo.')'
79 elseif <SID>CheckArea('\m^--- .*\n^+++ ','\v(^$|\n^-- $)')
80 setlocal fo-=a fo-=w fo-=t noet
81 "echo 'Patch (fo='.&fo.')'
82 elseif s:synCur == '' && s:synNext =~ '^mailSignature'
83 " elseif getline(line('.')+1) =~ '\m^-- $'
84 setlocal fo-=a fo-=w fo-=t
85 "echo 'Last line before signature (fo='.&fo.')'
86 elseif s:synCur =~ '^mailSignature'
87 " elseif <SID>CheckArea('^-- $','^$')
88 setlocal fo-=a fo-=w fo-=t
89 "echo 'Signature (fo='.&fo.')'
90 elseif s:synCur =~ '^mail'
91 " if <SID>CheckArea('\v^From( |: ).*\n','\v^$')
92 setlocal fo-=a fo-=w fo-=t
93 "echo 'Header (fo='.&fo.')'
95 "echo 'My text (fo='.&fo.')'
99 function! s:CheckArea(start, end)
100 return (search(a:start,'bcnW')-line('.')) >
101 \ (search(a:end,'bnW')-line('.'))
104 function! FixQuotes()
106 let l:lineNxt = getline(l:i)
107 let l:synNxt = synIDattr(synID(l:i,1,0),"name")
108 while l:i < line('$')-1
109 let l:lineCur = l:lineNxt
110 let l:synCur = l:synNxt
111 let l:lineNxt = getline(l:i+1)
112 let l:synNxt = synIDattr(synID(l:i+1,1,0),"name")
113 if l:synCur =~ '^mailQuote' && l:lineCur =~ '\w.*\S$' &&
114 \ l:synNxt =~ '^mailQuote' && l:lineNxt =~ '\w'
115 call setline(l:i, l:lineCur . ' ')
123 autocmd BufWinEnter $TMPDIR/mutt-* call FixQuotes()
126 nmap <buffer> <C-P><F1> :w<CR>:%!mailplate --keep-unknown official<CR>
127 nmap <buffer> <C-P><F2> :w<CR>:%!mailplate --keep-unknown tahi<CR>
128 nmap <buffer> <C-P><F3> :w<CR>:%!mailplate --keep-unknown pmvm<CR>
129 nmap <buffer> <C-P><F4> :w<CR>:%!mailplate --keep-unknown pobox<CR>
130 nmap <buffer> <C-P><F5> :w<CR>:%!mailplate --keep-unknown debian<CR>
131 nmap <buffer> <C-P><F6> :w<CR>:%!mailplate --keep-unknown debconf<CR>
132 nmap <buffer> <C-P><F7> :w<CR>:%!mailplate --keep-unknown uniwh<CR>
133 nmap <buffer> <C-P><F8> :w<CR>:%!mailplate --keep-unknown mtfk<CR>
134 nmap <buffer> <C-P><F9> :w<CR>:%!mailplate --keep-unknown sudetia<CR>
135 nmap <buffer> <C-P><F12> :w<CR>:%!mailplate --keep-unknown private<CR>
136 nmap <buffer> <F1> :w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>
138 " change subject line
139 " Before: Subject: old
140 " After : Subject: New (was: old)
141 " http://strcat.de/wiki/dotfiles#vim
142 " map ,sw 1G/^Subject: <CR>:s/Re:/was:/<CR>Wi (<C-O>$)<ESC>0Whi
143 map <Leader>ns 1G/^Subject: /<CR>:s,\(Subject: \)\(Re: \)*\(.*\)$,\1 (was: \3),<CR>:set nohls<CR>f li
145 " Delete 'was' in the Subject.
146 " Before: Subject: New (was: old)
147 " After : Subject: New
148 " http://strcat.de/wiki/dotfiles#vim
149 map <Leader>dw 1G/^Subject: /<CR>:s, *(was: .*)$<CR>:set nohls<CR>f l
151 " http://dollyfish.net.nz/blog/2008-04-01/mutt-and-vim-custom-autocompletion
152 fun! LBDBCompleteFn(findstart, base)
153 let line = getline('.')
155 " locate the start of the word
156 let start = col('.') - 1
157 while start > 0 && line[start - 1] =~ '[^:,]'
160 while start < col('.') && line[start] =~ '[:, ]'
166 let query = substitute(a:base, '"', '', 'g')
167 let query = substitute(query, '\s*<.*>\s*', '', 'g')
168 for m in LbdbQuery(query)
169 call complete_add(printf('"%s" <%s>', escape(m[0], '"'), m[1]))
177 set completefunc=LBDBCompleteFn
179 " And this magic by James Vega, which ensures that we only complete with lbdb
180 " on the recipient lines of the mail header.
181 inoremap <expr> <C-n> DelegateCompletion(1)
182 inoremap <expr> <C-p> DelegateCompletion(0)
184 fun! DelegateCompletion(next)
185 if getline('.') =~? '^\%(To\|B\=Cc\):'