" Some mail & news stuff
" Made by Ray Dassen <jdassen@wi.leidenuniv.nl>

" Mail (mutt) & News
"
" ,kqs = kill quoted signature 
"map ,kqs G?^> *-- $<CR>d/^-- $<CR>
"          goto end-of-buffer, search-backwards for a quoted sigdashes
"          line, ie "^> -- $", and delete unto end-of-paragraph:
map ,kqs G?^> *-- $<CR>d}

"    ,kpq kill SuperCite (aka PowerQuote) quote (replacing it by `>')
map ,kpq :%s/^> *[a-zA-Z]*>/> >/<C-M>

" reformat body text to current textwidth
" map ,ref 1G/^$<CR>V/^-- $<CR><Up>Q1G
map ,ref G?^-- $<CR><Up>V1G/^[ \t]*$<CR>Q1G

" Standard spam complaint
map ,spam :r/home/jdassen/junk/complain-message2<CR>

" Spellcheck.
map ,i :w<CR>:!ispell %<CR>:e %<CR>

"   ,rot    = rot13 encode or decode visualised text
vmap ,rot :!tr A-Za-z N-ZA-Mn-za-m<CR>

" PGP sign (human readable)
vmap ,sign :!pgp -fast<CR>


"""""""""""""""""""""""""""""""" Autocommands """"""""""""""""""""""""""""""""

augroup Messages " Mail & news
  autocmd!
  autocmd BufRead mutt*[0-9],snd.*,.letter,.followup,.article,.article[0-9] set textwidth=76 formatoptions=2tcq comments=n:>,n::,n:#,n:%,n:\| digraph
  autocmd BufRead mutt*[0-9],snd.*,.letter,.followup,.article,.article[0-9] :normal ,kqs
   " - Assume 80-column screen width (which is very common), and allow
   "   for our text to be quoted a couple of times without requiring
   "   reformatting to fit in 80-columns.
   " - Attempt to reformat quoted text in messages properly. Recognise
   "   the most common single character quote indicators `>', `:', `#', `%',
   "   `|'. The only other reasonably common quote indicator that this 
   "   doesn't deal with is the stupid ?Supercite? convention `JDOE>',
   "   which ought to be banned for waste of bandwith. 
   " - Enable backspace for digraphs
   " - Kill quoted signature
augroup END
