From fc083db2efae845a4f6eff2eac977f164debcb9e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 14 Aug 2018 19:40:11 +1200 Subject: Move Vim mail functions to autoload --- vim/after/ftplugin/mail.vim | 71 +++++---------------------------------------- 1 file changed, 7 insertions(+), 64 deletions(-) (limited to 'vim/after/ftplugin') diff --git a/vim/after/ftplugin/mail.vim b/vim/after/ftplugin/mail.vim index 612dc523..0b762e61 100644 --- a/vim/after/ftplugin/mail.vim +++ b/vim/after/ftplugin/mail.vim @@ -50,81 +50,24 @@ let b:undo_ftplugin .= '|nunmap q' \ . '|xunmap Q' " Flag a message as unimportant -function! s:FlagUnimportant() - call cursor(1, 1) - call search('^$') - - - call append(line('.'), 'X-Priority: 5') - call append(line('.'), 'Importance: Low') -endfunction nnoremap \ l - \ :call FlagUnimportant() + \ :call mail#FlagUnimportant() let b:undo_ftplugin .= '|nunmap l' -" Move through quoted paragraphs like normal-mode `{` and `}` -function! s:NewBlank(count, up, visual) abort - - " Reselect visual selection - if a:visual - normal! gv - endif - - " Flag for whether we've started a block - let l:block = 0 - - " Flag for the number of blocks passed - let l:blocks = 0 - - " Iterate through buffer lines - let l:num = line('.') - while a:up ? l:num > 1 : l:num < line('$') - - " If the line is blank - if getline(l:num) =~# '^[ >]*$' - - " If we'd moved through a non-blank block already, reset that flag and - " bump up the block count - if l:block - let l:block = 0 - let l:blocks += 1 - endif - - " If we've hit the number of blocks, end the loop - if l:blocks == a:count - break - endif - - " If the line is not blank, flag that we're going through a block - else - let l:block = 1 - endif - - " Move the line number or up or down depending on direction - let l:num += a:up ? -1 : 1 - - endwhile - - " Move to line if nonzero and not equal to the current line - if l:num != line('.') - execute 'normal '.l:num.'G' - endif - -endfunction - " Maps using NewBlank() function above for quoted paragraph movement nnoremap [ - \ :call NewBlank(v:count1, 1, 0) + \ :call mail#NewBlank(v:count1, 1, 0) nnoremap ] - \ :call NewBlank(v:count1, 0, 0) + \ :call mail#NewBlank(v:count1, 0, 0) onoremap [ - \ :call NewBlank(v:count1, 1, 0) + \ :call mail#NewBlank(v:count1, 1, 0) onoremap ] - \ :call NewBlank(v:count1, 0, 0) + \ :call mail#NewBlank(v:count1, 0, 0) xnoremap [ - \ :call NewBlank(v:count1, 1, 1) + \ :call mail#NewBlank(v:count1, 1, 1) xnoremap ] - \ :call NewBlank(v:count1, 0, 1) + \ :call mail#NewBlank(v:count1, 0, 1) let b:undo_ftplugin .= '|nunmap [' \ . '|nunmap ]' \ . '|ounmap [' -- cgit v1.2.3