aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
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/autoload
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/autoload')
-rw-r--r--vim/autoload/mail.vim58
1 files changed, 58 insertions, 0 deletions
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim
new file mode 100644
index 00000000..4e8232c8
--- /dev/null
+++ b/vim/autoload/mail.vim
@@ -0,0 +1,58 @@
+" Flag a message as unimportant
+function! mail#FlagUnimportant()
+ call cursor(1, 1)
+ call search('^$')
+ -
+ call append(line('.'), 'X-Priority: 5')
+ call append(line('.'), 'Importance: Low')
+endfunction
+
+" Move through quoted paragraphs like normal-mode `{` and `}`
+function! mail#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