aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin/mail.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/after/ftplugin/mail.vim')
-rw-r--r--vim/after/ftplugin/mail.vim125
1 files changed, 36 insertions, 89 deletions
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index f4a4c91d..4c07bac3 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -1,86 +1,31 @@
+" 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'
-" If something hasn't already moved the cursor, we'll move to an optimal point
-" 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
-function! s:StrictQuote() abort
- let body = 0
- for lnum in range(1, line('$'))
-
- " Get current line
- let line = getline(lnum)
-
- " Skip lines until we hit a blank line, meaning body text
- let body = body || !strlen(line)
- if !body
- continue
- endif
-
- " Get the leading quote string, if any; skip if there isn't one
- let quote = matchstr(line, '^>[> ]*')
- if !strlen(quote)
- continue
- endif
-
- " Normalise the quote with no spaces
- let quote = substitute(quote, '[^>]', '', 'g')
-
- " Re-set the line
- let line = substitute(line, '^[> ]\+', quote, '')
- call setline(lnum, line)
-
- endfor
-endfunction
-command -bar -buffer StrictQuote
- \ call s:StrictQuote()
+" Normalize quoting
+command -bar -buffer -range=% StrictQuote
+ \ call mail#StrictQuote(<q-line1>, <q-line2>)
let b:undo_ftplugin .= '|delcommand StrictQuote'
-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
@@ -88,17 +33,8 @@ let b:undo_ftplugin .= '|setlocal formatoptions<'
" Mail-specific handling for custom vim-squeeze-repeat-blanks plugin
if exists('loaded_squeeze_repeat_blanks')
-
- " Set the blank line pattern
let b:squeeze_repeat_blanks_blank = '^[ >]*$'
let b:undo_ftplugin .= '|unlet b:squeeze_repeat_blanks_blank'
-
- " If there is anything quoted in this message (i.e. it looks like a reply),
- " squeeze blanks, but don't report lines deleted
- if search('\m^>', 'cnw')
- silent SqueezeRepeatBlanks
- endif
-
endif
" Spellcheck documents we're actually editing (not just viewing)
@@ -113,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
@@ -136,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>