diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-30 20:23:43 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-30 20:23:43 +1300 |
commit | 78b3b3e49b8dc8286a3059e4b3a5bc11214c9a5d (patch) | |
tree | 32ff337ee16af906b36b4c4a1928bad4a809839e /vim/autoload | |
parent | Specify encoding of file with ZALGO comment (diff) | |
download | dotfiles-78b3b3e49b8dc8286a3059e4b3a5bc11214c9a5d.tar.gz dotfiles-78b3b3e49b8dc8286a3059e4b3a5bc11214c9a5d.zip |
Move ft=mail start suggestion to autoload
Diffstat (limited to 'vim/autoload')
-rw-r--r-- | vim/autoload/mail.vim | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim index 3fbba860..bc9bac4a 100644 --- a/vim/autoload/mail.vim +++ b/vim/autoload/mail.vim @@ -102,3 +102,43 @@ function! mail#StrictQuote(start, end) abort endfor endfunction + +" Attempt to move to a good spot to start writing +function! mail#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 |