aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin/mail.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-14 19:40:29 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-14 19:40:41 +1200
commitf833e6c33a97df108d378a4a682c7d3825c6a63a (patch)
tree36519491c9e4df030f97a9cb969c55e2036249f7 /vim/after/ftplugin/mail.vim
parentMove to body text correctly for start guesser (diff)
downloaddotfiles-f833e6c33a97df108d378a4a682c7d3825c6a63a.tar.gz
dotfiles-f833e6c33a97df108d378a4a682c7d3825c6a63a.zip
Wrap mail quote cleanup in command-func
Diffstat (limited to 'vim/after/ftplugin/mail.vim')
-rw-r--r--vim/after/ftplugin/mail.vim45
1 files changed, 25 insertions, 20 deletions
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 43586731..85db8c9e 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -47,32 +47,37 @@ command! -bar -buffer SuggestStart
SuggestStart
" Normalise quoting
-let body = 0
-for lnum in range(1, line('$'))
+function! s:StrictQuote() abort
+ let body = 0
+ for lnum in range(1, line('$'))
- " Get current line
- let line = getline(lnum)
+ " 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
+ " 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
+ " 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')
+ " Normalise the quote with no spaces
+ let quote = substitute(quote, '[^>]', '', 'g')
- " Re-set the line
- let line = substitute(line, '^[> ]\+', quote, '')
- call setline(lnum, line)
+ " Re-set the line
+ let line = substitute(line, '^[> ]\+', quote, '')
+ call setline(lnum, line)
-endfor
+ endfor
+endfunction
+command -bar -buffer StrictQuote
+ \ call s:StrictQuote()
+StrictQuote
" Add a space to the end of wrapped lines for format-flowed mail
setlocal formatoptions+=w