after/ftplugin/mail.vim

Don’t limit ourselves to plain ASCII encoding:

scriptencoding utf-8

Enforce vim script implementation to reduce ambiguities and improve robustness:

scriptversion 4

Add maps to insert X-Advice headers. Obviously we’re not going to convince every one to take part, but they have become popular in work mail.

call keymaps#mnemonic_map('Advice',
\                         #{buffer: v:true, key: 'A', local: v:true})
for s:prio in ['perhaps', 'should', 'must']
    for s:due in ['now', 'soon', 'whenever']
        execute printf('nnoremap <buffer> [Advice]%.1s%.1s ' ..
        \              ':call filetypes#add_advice_header("%s", "%s")<CR>',
        \              s:prio, s:due, s:prio, s:due)
    endfor
endfor

Enable thesaurus support; annoying in code, but great in prose.

call filetypes#apply_ftplugin('complete+=s')

Set useful defaults for formatting prose:

call filetypes#apply_ftplugin('formatoptions+=2')

Add dictionary from miscfiles if available:

if filereadable('/usr/share/dict/words')
    call filetypes#apply_ftplugin('complete+=k/usr/share/dict/words')
endif

Tip

On Debian systems this file tends to be provided by packages from the wordlist project(see aptitude search '~Pwordlist' for options). On other systems, and possibly on Debian too, it may be provided by GNU’s miscfiles package.

Break undo sequence on sentence level punctuation. This kind of feels better when editing prose and also when making liberal use of undo-tree. Not yet sure if it is too granular.

for s:key in split(',.!?:;', '\zs')
    execute 'inoremap <buffer> ' .. s:key .. ' ' .. s:key .. '<C-g>u'
endfor

Support increment and decrement on single characters for easy list prefix manipulation:

call filetypes#apply_ftplugin('nrformats+=alpha')

Kill from current line to signature, as a quick way to scrub large chunks of quoted text:

inoremap <buffer> <C-k>
\   <Cmd>call filetypes#kill_to_signature()<CR>
nnoremap <buffer> <C-k> <Cmd>call filetypes#kill_to_signature()<CR>