aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload/mail.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-01-07 09:48:46 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-01-07 09:48:46 +1300
commit5d56356e22b6ac6888051ac000f4542a41bc4ae2 (patch)
tree0bcec57a939388b27acaf1ee42033d6ad6cfecde /vim/autoload/mail.vim
parentMerge branch 'release/v4.8.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-5d56356e22b6ac6888051ac000f4542a41bc4ae2.tar.gz
dotfiles-5d56356e22b6ac6888051ac000f4542a41bc4ae2.zip
Merge branch 'release/v4.9.0'v4.9.0
* release/v4.9.0: Bump VERSION Return to vi as default visual editor Remove superfluous unmappings for mail filetype Clarify a comment for HTML indentation Add test to 'keywordprg' setting for Vim help Make name of autocmd group more specific Clarify a comment Refactor Vim mail header field shortcuts Explain .bashrc $- 'r' flag problem fully
Diffstat (limited to 'vim/autoload/mail.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 `}`