aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-22 19:00:32 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-22 19:00:32 +1200
commit009bd6626ea6e33b59a31a219df628ed0cc5a46c (patch)
tree5d5537256f4ba067475f92eb983ff0dd9bc14ad2 /vim
parent2a7e2b14d3046ab05f222a4e0d7173d9e7f97f53 (diff)
downloaddotfiles-009bd6626ea6e33b59a31a219df628ed0cc5a46c.tar.gz
dotfiles-009bd6626ea6e33b59a31a219df628ed0cc5a46c.zip
Move mail ftplugin function out into autoload
Now that it isn't called on every load.
Diffstat (limited to 'vim')
-rw-r--r--vim/after/ftplugin/mail.vim24
-rw-r--r--vim/autoload/mail.vim23
2 files changed, 24 insertions, 23 deletions
diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim
index 2083aaaf..90278bbe 100644
--- a/vim/after/ftplugin/mail.vim
+++ b/vim/after/ftplugin/mail.vim
@@ -49,30 +49,8 @@ let b:undo_ftplugin .= '|delcommand SuggestStart'
SuggestStart
" Normalise quoting
-function! s:StrictQuote(start, end) abort
- let body = 0
- for lnum in range(a:start, a:end)
-
- " Get current line
- let line = getline(lnum)
-
- " 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 -buffer -bar -range=% StrictQuote
- \ call s:StrictQuote(<q-line1>, <q-line2>)
+ \ call mail#StrictQuote(<q-line1>, <q-line2>)
nnoremap <LocalLeader>s
\ :StrictQuote<CR>
xnoremap <LocalLeader>s
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim
index 40b7fb7f..3fbba860 100644
--- a/vim/autoload/mail.vim
+++ b/vim/autoload/mail.vim
@@ -79,3 +79,26 @@ function! mail#NewBlank(count, up, visual) abort
endif
endfunction
+
+function! mail#StrictQuote(start, end) abort
+ let body = 0
+ for lnum in range(a:start, a:end)
+
+ " Get current line
+ let line = getline(lnum)
+
+ " 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