aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-01-06 13:16:13 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-01-06 13:16:13 +1300
commit3bd3adfff29d5f7996cc9667a639126a5797b33f (patch)
treea8b20f86310ebb16095cd42d69ccd42f62d6c2b5 /vim
parentExplain .bashrc $- 'r' flag problem fully (diff)
downloaddotfiles-3bd3adfff29d5f7996cc9667a639126a5797b33f.tar.gz
dotfiles-3bd3adfff29d5f7996cc9667a639126a5797b33f.zip
Refactor Vim mail header field shortcuts
Diffstat (limited to 'vim')
-rw-r--r--vim/autoload/mail.vim34
1 files changed, 24 insertions, 10 deletions
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim
index baff4bbf..f37a7865 100644
--- a/vim/autoload/mail.vim
+++ b/vim/autoload/mail.vim
@@ -1,19 +1,33 @@
+" Add a header to a mail message
+function! mail#AddHeaderField(name, body) abort
+ let l:num = 0
+ while l:num < line('$') && getline(l:num + 1) !=# ''
+ let l:num += 1
+ endwhile
+ call append(l:num, a:name.': '.a:body)
+endfunction
+
+" Add a set of headers to a mail message
+function! mail#AddHeaderFields(fields) abort
+ for l:name in sort(keys(a:fields))
+ call mail#AddHeaderField(l:name, a:fields[l:name])
+ endfor
+endfunction
+
" Flag a message as important
function! mail#FlagImportant() abort
- call cursor(1, 1)
- call search('^$')
- -
- call append(line('.'), 'X-Priority: 1')
- call append(line('.'), 'Importance: High')
+ call mail#AddHeaderFields({
+ \ 'Importance': 'High',
+ \ 'X-Priority': 1
+ \ })
endfunction
" 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')
+ call mail#AddHeaderFields({
+ \ 'Importance': 'Low',
+ \ 'X-Priority': 5
+ \ })
endfunction
" Move through quoted paragraphs like normal-mode `{` and `}`