aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/mail.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-15 10:12:38 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-15 10:12:38 +1200
commit4dd8d125cd401137d18d196e4125aa8fe789d2a0 (patch)
tree273810b45b6cd15d57402340da7978834cd27b55 /vim/autoload/mail.vim
parentMerge branch 'release/v1.52.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-02868fb4a993fa99ead5d49c12381882a2cde176.tar.gz (sig)
dotfiles-02868fb4a993fa99ead5d49c12381882a2cde176.zip
Merge branch 'release/v1.53.0'v1.53.0
* release/v1.53.0: Bump VERSION Unset g:is_posix when no longer needed Move Perl boilerplate generation to autoload Use consistent format for local leader mappings Rearrange local mappings for mail Add `abort` attribute to autoloaded mail function Move Vim mail functions to autoload Delete multiple blank lines after skipped greeting Add "hey" to generic mail quote greetings
Diffstat (limited to 'vim/autoload/mail.vim')
-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..6bec6e55
--- /dev/null
+++ b/vim/autoload/mail.vim
@@ -0,0 +1,58 @@
+" Flag a message as unimportant
+function! mail#FlagUnimportant() abort
+ 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