Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Mail |
| 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | 113cb51 | 2021-11-07 20:27:04 +0000 | [diff] [blame] | 4 | " Last Change: 2021 Oct 23 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | |
| 6 | " Only do this when not done yet for this buffer |
| 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
| 10 | let b:did_ftplugin = 1 |
| 11 | |
Bram Moolenaar | 2df58b4 | 2012-11-28 18:21:11 +0100 | [diff] [blame] | 12 | let b:undo_ftplugin = "setl modeline< tw< fo< comments<" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 13 | |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 14 | " Don't use modelines in e-mail messages, avoid trojan horses and nasty |
| 15 | " "jokes" (e.g., setting 'textwidth' to 5). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 16 | setlocal nomodeline |
| 17 | |
| 18 | " many people recommend keeping e-mail messages 72 chars wide |
| 19 | if &tw == 0 |
| 20 | setlocal tw=72 |
| 21 | endif |
| 22 | |
| 23 | " Set 'formatoptions' to break text lines and keep the comment leader ">". |
| 24 | setlocal fo+=tcql |
| 25 | |
Bram Moolenaar | 2df58b4 | 2012-11-28 18:21:11 +0100 | [diff] [blame] | 26 | " Add n:> to 'comments, in case it was removed elsewhere |
| 27 | setlocal comments+=n:> |
| 28 | |
Bram Moolenaar | 113cb51 | 2021-11-07 20:27:04 +0000 | [diff] [blame] | 29 | " .eml files are universally formatted with DOS line-endings, per RFC5322. |
| 30 | " If the file was not DOS the it will be marked as changed, which is probably |
| 31 | " a good thing. |
| 32 | if expand('%:e') ==? 'eml' |
| 33 | let b:undo_ftplugin ..= " fileformat=" .. &fileformat |
| 34 | setlocal fileformat=dos |
| 35 | endif |
| 36 | |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 37 | " Add mappings, unless the user doesn't want this. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 38 | if !exists("no_plugin_maps") && !exists("no_mail_maps") |
| 39 | " Quote text by inserting "> " |
| 40 | if !hasmapto('<Plug>MailQuote') |
| 41 | vmap <buffer> <LocalLeader>q <Plug>MailQuote |
| 42 | nmap <buffer> <LocalLeader>q <Plug>MailQuote |
| 43 | endif |
| 44 | vnoremap <buffer> <Plug>MailQuote :s/^/> /<CR>:noh<CR>`` |
| 45 | nnoremap <buffer> <Plug>MailQuote :.,$s/^/> /<CR>:noh<CR>`` |
| 46 | endif |