diff options
Diffstat (limited to 'vim/after/ftplugin/mail.vim')
-rw-r--r-- | vim/after/ftplugin/mail.vim | 88 |
1 files changed, 35 insertions, 53 deletions
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 9f8fc608..4c07bac3 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -1,61 +1,32 @@ +" Restore global value for no_mail_maps that we set in +" ~/.vim/ftplugin/mail.vim to work around the bad maps set in +" $VIMRUNTIME/ftplugin/mail.vim +" +if exists('b:no_mail_maps') + let no_mail_maps = b:no_mail_maps +elseif exists('no_mail_maps') + unlet no_mail_maps +endif + " Don't append spaces after quote chars, for strict compliance with " format=flowed let b:quote_space = 0 let b:undo_ftplugin .= '|unlet b:quote_space' -" Attempt to move to a good spot to start writing -function! s:SuggestStart() abort - - " Move to top of buffer - call setpos('.', [0, 1, 1, 0]) - - " Move to body text - call search('\m^$', 'c') | + - - " Start by trying to move to the first quoted line; this may fail if there's - " no quote, which is fine - call search('\m^>', 'c') - - " Delete quoted blank lines or quoted greetings until we get to something - " with substance. Yes, I like Perl, how could you tell? - while getline('.') =~? '^> *' - \ . '\%(' - \ . '\%(' - \ . 'g[''\u2019]\=day' - \ . '\|\%(good \)\=\%(morning\|afternoon\|evening\)' - \ . '\|h[eu]\%(ll\|rr\)o\+' - \ . '\|hey\+' - \ . '\|hi\+' - \ . '\|sup' - \ . '\|what[''\u2019]\=s up' - \ . '\|yo' - \ . '\)' - \ . '[[:punct:] ]*' - \ . '\%(' - \ . '\a\+' - \ . '[[:punct:] ]*' - \ . '\)\=' - \ . '\)\=$' - delete - endwhile - - " Now move to the first quoted or unquoted blank line - call search('\m^>\= *$', 'c') -endfunction -command! -bar -buffer SuggestStart - \ call s:SuggestStart() +command -bar -buffer SuggestStart + \ call mail#SuggestStart() let b:undo_ftplugin .= '|delcommand SuggestStart' SuggestStart -" Normalise quoting -command -buffer -bar -range=% StrictQuote +" Normalize quoting +command -bar -buffer -range=% StrictQuote \ call mail#StrictQuote(<q-line1>, <q-line2>) -nnoremap <LocalLeader>s - \ :StrictQuote<CR> -xnoremap <LocalLeader>s - \ :StrictQuote<CR> let b:undo_ftplugin .= '|delcommand StrictQuote' +command -bar -buffer -nargs=1 SetImportance + \ call mail#importance#Set(<f-args>) +let b:undo_ftplugin .= '|delcommand SetImportance' + " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w let b:undo_ftplugin .= '|setlocal formatoptions<' @@ -78,12 +49,15 @@ if exists('no_plugin_maps') || exists('no_mail_maps') endif " Flag messages as important/unimportant -nnoremap <buffer> <LocalLeader>h - \ :<C-U>call mail#FlagImportant()<CR> -let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>h' -nnoremap <buffer> <LocalLeader>l - \ :<C-U>call mail#FlagUnimportant()<CR> -let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>l' +nnoremap <buffer> <LocalLeader>ih + \ :<C-U>SetImportance high<CR> +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>ih' +nnoremap <buffer> <LocalLeader>il + \ :<C-U>SetImportance low<CR> +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>il' +nnoremap <buffer> <LocalLeader>in + \ :<C-U>SetImportance normal<CR> +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>in' " Quote operator nnoremap <buffer> <expr> <LocalLeader>q @@ -101,6 +75,14 @@ xnoremap <buffer> <expr> <LocalLeader>Q let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>Q' \ . '|xunmap <buffer> <LocalLeader>Q' +" Mappings for enforcing strict quoting +nnoremap <buffer> <LocalLeader>s + \ :StrictQuote<CR> +xnoremap <buffer> <LocalLeader>s + \ :StrictQuote<CR> +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>s' + \ . '|xunmap <buffer> <LocalLeader>s' + " Maps using autoloaded function for quoted paragraph movement nnoremap <buffer> <silent> <LocalLeader>[ \ :<C-U>call mail#NewBlank(v:count1, 1, 0)<CR> |