diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-23 11:24:51 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-23 11:24:51 +1200 |
commit | 764bbeef64cc575a55ab0a22e22c095ac7d564ad (patch) | |
tree | 2ca8e9a84c4bfb71f12a3959e2fb4a4dc1dd8aaa /vim/after/ftplugin/mail.vim | |
parent | Merge branch 'release/v4.38.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-764bbeef64cc575a55ab0a22e22c095ac7d564ad.tar.gz dotfiles-764bbeef64cc575a55ab0a22e22c095ac7d564ad.zip |
Merge branch 'release/v4.39.0'v4.39.0
* release/v4.39.0: (33 commits)
Bump VERSION
Use case-sensitive operators to appease vim-vint
Correct :return to :break
Run repeat blank squeeze on mail reply
Normalise quoting in mail
Strip trailing blanks after greeting
Improve opening-greeting strip from mail ftplugin
Add foldexpr function deletion to undo
Give credit to Tim Pope
Adopt heading-based Markdown folding
Remove redundancies from 'formatoptions' setting
Break apart 'comments' definitions
Use variable assignment for complex pattern
Correct definition for b:undo_ftplugin
Refactor undo_ftplugin lines for Markdown ftplugin
Break up Markdown ftplugin option settings
Adjust header/footer for Markdown ftplugin
Remove HTML ftplugin import from Markdown ftplugin
Move my after ftplugin for Markdown into main
Add Tim Pope's Markdown ftplugin
...
Diffstat (limited to 'vim/after/ftplugin/mail.vim')
-rw-r--r-- | vim/after/ftplugin/mail.vim | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 457135ef..15277f7b 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -6,11 +6,11 @@ if line('.') == 1 && col('.') == 1 " no quote, which is fine call search('\m^>', 'c') - " Check this line to see if it's a generic hello-name greeting that we can - " just strip out; delete any following lines too, if they're blank - if getline('.') =~? '^>\s*\%(<hello\|hey\+\|hi\)\s\+\S\+\s*$' + " Check this line to see if it's a generic hello or hello-name greeting that + " we can just strip out; delete any following lines too, if they're blank + if getline('.') =~? '^>\s*\%(<hello\|hey\+\|hi\)\(\s\+\S\+\)\=[,;]*\s*$' delete - while getline('.') =~# '^>$' + while getline('.') =~# '^>\s*$' delete endwhile endif @@ -20,15 +20,37 @@ if line('.') == 1 && col('.') == 1 endif +" Normalise quoting +for lnum in range(1, line('$')) + + " Get current line + let line = getline(lnum) + + " Get the leading quote string, if any; stop if there isn't one + let quote = matchstr(line, '^[> \t]\+') + if strlen(quote) == 0 + break + endif + + " Normalise the quote with no intermediate and one trailing space + let quote = substitute(quote, '[^>]', '', 'g').' ' + + " Re-set the line + let line = substitute(line, '^[> \t]\+', quote, '') + call setline(lnum, line) + +endfor + " Add a space to the end of wrapped lines for format-flowed mail setlocal formatoptions+=w let b:undo_ftplugin .= '|setlocal formatoptions<' " Define what constitutes a 'blank line' for the squeeze_repeat_blanks.vim -" plugin, if loaded, to include leading quotes and spaces +" plugin, if loaded, to include leading quotes and spaces, and then do it if exists('loaded_squeeze_repeat_blanks') let b:squeeze_repeat_blanks_blank = '^[ >]*$' let b:undo_ftplugin .= '|unlet b:squeeze_repeat_blanks_blank' + silent SqueezeRepeatBlanks endif " Stop here if the user doesn't want ftplugin mappings |