.config/nvim/after/ftplugin/mail.vim

Sun, 05 Mar 2023 23:19:03 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 05 Mar 2023 23:19:03 -0500
changeset 1066
c826661721a8
parent 1029
9265f8508e4c
child 1125
58490a30d6fb
permissions
-rw-r--r--

detect presence of nvim

1029
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 setl textwidth=72
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 setl formatoptions=jaw12tcql
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 setl spell
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 setl noundofile noswapfile nobackup
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 setl equalprg=pandoc\ -f\ markdown\ -t\ markdown
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 " http://cedricduval.free.fr/download/mail.vim
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 function! Mail_Erase_Sig()
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 " search for the signature pattern (takes into account signature delimiters
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 " from broken mailers that forget the space after the two dashes)
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 let i = 0
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 while ((i <= line('$')) && (getline(i) !~ '^> *-- \=$'))
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14 let i = i + 1
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 endwhile
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 " if found, then
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 if (i != line('$') + 1)
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 " first, look for our own signature, to avoid deleting it
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 let j = i
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 while (j < line('$') && (getline(j + 1) !~ '^-- $'))
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 let j = j + 1
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 endwhile
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25 " second, search for the last non empty (non sig) line
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26 while ((i > 0) && (getline(i - 1) =~ '^\(>\s*\)*$'))
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27 let i = i - 1
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28 endwhile
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30 " third, delete those lines plus the signature
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31 exe ':'.i.','.(j - 1).'d'
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32 endif
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33 endfunction
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
34
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35 call Mail_Erase_Sig()
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37 " Get right to composing the body:
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38 if line('$') > 1 && line("'\"") < 1
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39 :normal gg}
9265f8508e4c Copy other ft and plugin settings
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
40 endif

mercurial