]> git.madduck.net Git - etc/vim.git/blob - .vim/ftplugin/mail.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

mailplate shortcuts updated
[etc/vim.git] / .vim / ftplugin / mail.vim
1 nmap <buffer> <C-P><F1> :w<CR>:%!mailplate --keep-unknown official<CR>
2 nmap <buffer> <C-P><F2> :w<CR>:%!mailplate --keep-unknown tahi<CR>
3 nmap <buffer> <C-P><F3> :w<CR>:%!mailplate --keep-unknown pmvm<CR>
4 nmap <buffer> <C-P><F4> :w<CR>:%!mailplate --keep-unknown pobox<CR>
5 nmap <buffer> <C-P><F5> :w<CR>:%!mailplate --keep-unknown debian<CR>
6 nmap <buffer> <C-P><F6> :w<CR>:%!mailplate --keep-unknown debconf<CR>
7 nmap <buffer> <C-P><F7> :w<CR>:%!mailplate --keep-unknown uniwh<CR>
8 nmap <buffer> <C-P><F8> :w<CR>:%!mailplate --keep-unknown mtfk<CR>
9 nmap <buffer> <C-P><F9> :w<CR>:%!mailplate --keep-unknown sudetia<CR>
10 nmap <buffer> <C-P><F12> :w<CR>:%!mailplate --keep-unknown private<CR>
11 nmap <buffer> <F1> :w<CR>:%!mailplate --auto --keep-unknown 2>/dev/null<CR>
12
13 " change subject line
14 " Before: Subject: old
15 " After : Subject: New (was: old)
16 " http://strcat.de/wiki/dotfiles#vim
17 " map ,sw 1G/^Subject: <CR>:s/Re:/was:/<CR>Wi (<C-O>$)<ESC>0Whi
18 map <Leader>ns 1G/^Subject: /<CR>:s,\(Subject: \)\(Re: \)*\(.*\)$,\1 (was: \3),<CR>:set nohls<CR>f li
19
20 " Delete 'was' in the Subject.
21 " Before: Subject: New (was: old)
22 " After : Subject: New
23 " http://strcat.de/wiki/dotfiles#vim
24 map <Leader>dw 1G/^Subject: /<CR>:s, *(was: .*)$<CR>:set nohls<CR>f l
25
26 " http://dollyfish.net.nz/blog/2008-04-01/mutt-and-vim-custom-autocompletion
27 fun! LBDBCompleteFn(findstart, base)
28   let line = getline('.')
29   if a:findstart
30     " locate the start of the word
31     let start = col('.') - 1
32     while start > 0 && line[start - 1] =~ '[^:,]'
33       let start -= 1
34     endwhile
35     while start < col('.') && line[start] =~ '[:, ]'
36       let start += 1
37     endwhile
38     return start
39   else
40     let res = []
41     let query = substitute(a:base, '"', '', 'g')
42     let query = substitute(query, '\s*<.*>\s*', '', 'g')
43     for m in LbdbQuery(query)
44       call complete_add(printf('"%s" <%s>', escape(m[0], '"'), m[1]))
45       if complete_check()
46         break
47       endif
48     endfor
49     return res
50   endif
51 endfun
52 set completefunc=LBDBCompleteFn
53
54 " And this magic by James Vega, which ensures that we only complete with lbdb
55 " on the recipient lines of the mail header.
56 inoremap <expr> <C-n> DelegateCompletion(1)
57 inoremap <expr> <C-p> DelegateCompletion(0)
58
59 fun! DelegateCompletion(next)
60   if getline('.') =~? '^\%(To\|B\=Cc\):'
61     return "\x18\x15"
62   elseif a:next
63     return "\x0e"
64   else
65     return "\x10"
66   endif
67 endfun