aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-14 19:40:11 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-14 19:40:11 +1200
commitfc083db2efae845a4f6eff2eac977f164debcb9e (patch)
tree84d99c057c59d5074088d57004e8a9dc90d9f65e /vim/after/ftplugin
parentDelete multiple blank lines after skipped greeting (diff)
downloaddotfiles-fc083db2efae845a4f6eff2eac977f164debcb9e.tar.gz
dotfiles-fc083db2efae845a4f6eff2eac977f164debcb9e.zip
Move Vim mail functions to autoload
Diffstat (limited to 'vim/after/ftplugin')
-rw-r--r--vim/after/ftplugin/mail.vim71
1 files changed, 7 insertions, 64 deletions
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 <buffer> <LocalLeader>q'
\ . '|xunmap <buffer> <LocalLeader>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 <buffer>
\ <LocalLeader>l
- \ <C-U>:call <SID>FlagUnimportant()<CR>
+ \ <C-U>:call mail#FlagUnimportant()<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>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 <buffer> <silent> <LocalLeader>[
- \ :<C-U>call <SID>NewBlank(v:count1, 1, 0)<CR>
+ \ :<C-U>call mail#NewBlank(v:count1, 1, 0)<CR>
nnoremap <buffer> <silent> <LocalLeader>]
- \ :<C-U>call <SID>NewBlank(v:count1, 0, 0)<CR>
+ \ :<C-U>call mail#NewBlank(v:count1, 0, 0)<CR>
onoremap <buffer> <silent> <LocalLeader>[
- \ :<C-U>call <SID>NewBlank(v:count1, 1, 0)<CR>
+ \ :<C-U>call mail#NewBlank(v:count1, 1, 0)<CR>
onoremap <buffer> <silent> <LocalLeader>]
- \ :<C-U>call <SID>NewBlank(v:count1, 0, 0)<CR>
+ \ :<C-U>call mail#NewBlank(v:count1, 0, 0)<CR>
xnoremap <buffer> <silent> <LocalLeader>[
- \ :<C-U>call <SID>NewBlank(v:count1, 1, 1)<CR>
+ \ :<C-U>call mail#NewBlank(v:count1, 1, 1)<CR>
xnoremap <buffer> <silent> <LocalLeader>]
- \ :<C-U>call <SID>NewBlank(v:count1, 0, 1)<CR>
+ \ :<C-U>call mail#NewBlank(v:count1, 0, 1)<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>['
\ . '|nunmap <buffer> <LocalLeader>]'
\ . '|ounmap <buffer> <LocalLeader>['