.vim/ftplugin/mail.vim

Mon, 10 Oct 2016 01:14:22 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 10 Oct 2016 01:14:22 -0400
changeset 414
9536ca40b624
parent 411
1bb7fe33cd74
child 434
be837354e11b
permissions
-rw-r--r--

add gpg edit helper

387
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
1 setl textwidth=72
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
2 setl formatoptions=jaw12tcql
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
3 setl spell
349
976c8bf0499b set reflow_wrap = wrap
Meredith Howard <mhoward@roomag.org>
parents: 348
diff changeset
4
411
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
5 " http://cedricduval.free.fr/download/mail.vim
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
6 function! Mail_Erase_Sig()
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
7 " search for the signature pattern (takes into account signature delimiters
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
8 " from broken mailers that forget the space after the two dashes)
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
9 let i = 0
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
10 while ((i <= line('$')) && (getline(i) !~ '^> *-- \=$'))
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
11 let i = i + 1
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
12 endwhile
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
13
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
14 " if found, then
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
15 if (i != line('$') + 1)
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
16 " first, look for our own signature, to avoid deleting it
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
17 let j = i
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
18 while (j < line('$') && (getline(j + 1) !~ '^-- $'))
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
19 let j = j + 1
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
20 endwhile
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
21
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
22 " second, search for the last non empty (non sig) line
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
23 while ((i > 0) && (getline(i - 1) =~ '^\(>\s*\)*$'))
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
24 let i = i - 1
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
25 endwhile
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
26
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
27 " third, delete those lines plus the signature
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
28 exe ':'.i.','.(j - 1).'d'
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
29 endif
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
30 endfunction
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
31
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
32 call Mail_Erase_Sig()
1bb7fe33cd74 Add previous sig removal
Meredith Howard <mhoward@roomag.org>
parents: 387
diff changeset
33
387
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
34 " Get right to composing the body:
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
35 if line('$') > 1
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
36 :0
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
37 :/^$/
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
38 :normal 2]
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
39 :+1
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
40 :exe 'startinsert'
d16b5c66461a fix formatoptions and autorun
Meredith Howard <mhoward@roomag.org>
parents: 368
diff changeset
41 endif

mercurial