X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=e5787f07acc39aaeffbb9efc329debccdb771a98;hb=8bb6f7869c4c98190f010d60409938b1c50c5968;hp=8d5d1c34e377aca92680483ac55f091eb63a93b0;hpb=44ea57a0d10ddab514abea319c4d25ec4e36b51e;p=notmuch
diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index 8d5d1c34..e5787f07 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -18,11 +18,14 @@
" along with Notmuch. If not, see .
"
" Authors: Bart Trojanowski
-
+" Contributors: Felipe Contreras ,
+" Peter Hartman
+"
" --- configuration defaults {{{1
let s:notmuch_defaults = {
\ 'g:notmuch_cmd': 'notmuch' ,
+ \ 'g:notmuch_sendmail': 'sendmail' ,
\ 'g:notmuch_debug': 0 ,
\
\ 'g:notmuch_search_newest_first': 1 ,
@@ -117,8 +120,10 @@ let g:notmuch_search_maps = {
\ '': ':call NM_search_show_thread(0)',
\ '': ':call NM_search_show_thread(1)',
\ '': ':call NM_search_expand('''')',
+ \ 'I': ':call NM_search_mark_read_thread()',
\ 'a': ':call NM_search_archive_thread()',
\ 'A': ':call NM_search_mark_read_then_archive_thread()',
+ \ 'D': ':call NM_search_delete_thread()',
\ 'f': ':call NM_search_filter()',
\ 'm': ':call NM_new_mail()',
\ 'o': ':call NM_search_toggle_order()',
@@ -146,8 +151,11 @@ let g:notmuch_show_maps = {
\ 'h': ':call NM_show_fold_toggle(''h'', ''hdr'', !g:notmuch_show_fold_headers)',
\ 'i': ':call NM_show_fold_toggle(''s'', ''sig'', !g:notmuch_show_fold_signatures)',
\
+ \ 'I': ':call NM_show_mark_read_thread()',
\ 'a': ':call NM_show_archive_thread()',
\ 'A': ':call NM_show_mark_read_then_archive_thread()',
+ \ 'D': ':call NM_show_delete_thread()',
+ \ 'd': ':call NM_show_delete_message()',
\ 'N': ':call NM_show_mark_read_then_next_open_message()',
\ 'v': ':call NM_show_view_all_mime_parts()',
\ '+': ':call NM_show_add_tag()',
@@ -306,13 +314,23 @@ function! s:NM_search_edit()
endif
endfunction
+function! s:NM_search_mark_read_thread()
+ call NM_tag([], ['-unread'])
+ norm j
+endfunction
+
function! s:NM_search_archive_thread()
- call NM_add_remove_tags([], '-', ['inbox'])
+ call NM_tag([], ['-inbox'])
norm j
endfunction
function! s:NM_search_mark_read_then_archive_thread()
- call NM_add_remove_tags([], '-', ['unread', 'inbox'])
+ call NM_tag([], ['-unread', '-inbox'])
+ norm j
+endfunction
+
+function! s:NM_search_delete_thread()
+ call NM_tag([], ['+delete','-inbox','-unread'])
norm j
endfunction
@@ -403,7 +421,8 @@ function! s:NM_search_add_remove_tags(prompt, prefix, intags)
else
let tags = a:intags
endif
- call NM_add_remove_tags([], a:prefix, tags)
+ call map(tags, 'a:prefix . v:val')
+ call NM_tag([], tags)
endfunction
" --- implement show screen {{{1
@@ -492,15 +511,31 @@ function! s:NM_show_next_thread()
endif
endfunction
+function! s:NM_show_mark_read_thread()
+ call NM_tag(b:nm_search_words, ['-unread'])
+ call NM_show_next_thread()
+endfunction
+
function! s:NM_show_archive_thread()
- echo 'not implemented'
+ call NM_tag(b:nm_search_words, ['-inbox'])
+ call NM_show_next_thread()
endfunction
function! s:NM_show_mark_read_then_archive_thread()
- call NM_add_remove_tags(b:nm_search_words, '-', ['unread', 'inbox'])
+ call NM_tag(b:nm_search_words, ['-unread', '-inbox'])
+ call NM_show_next_thread()
+endfunction
+
+function! s:NM_show_delete_thread()
+ call NM_tag(b:nm_search_words, ['+delete', '-inbox', '-unread'])
call NM_show_next_thread()
endfunction
+function! s:NM_show_delete_message()
+ let msg = NM_show_get_message_for_line(line('.'))
+ call NM_tag([msg['id']], ['+delete', '-inbox', '-unread'])
+endfunction
+
function! s:NM_show_mark_read_then_next_open_message()
echo 'not implemented'
endfunction
@@ -561,7 +596,8 @@ function! s:NM_show_advance_marking_read_and_archiving()
let filter = NM_combine_tags('tag:', advance_tags, 'OR', '()')
\ + ['AND']
\ + NM_combine_tags('', ids, 'OR', '()')
- call NM_add_remove_tags(filter, '-', advance_tags)
+ call map(advance_tags, '"+" . v:val')
+ call NM_tag(filter, advance_tags)
call NM_show_next(1, 1)
return
endif
@@ -580,7 +616,8 @@ function! s:NM_show_advance_marking_read_and_archiving()
" do this last to hide the latency
let filter = NM_combine_tags('tag:', advance_tags, 'OR', '()')
\ + ['AND', msg_top['id']]
- call NM_add_remove_tags(filter, '-', advance_tags)
+ call map(advance_tags, '"-" . v:val')
+ call NM_tag(filter, advance_tags)
endif
return
endif
@@ -728,7 +765,7 @@ function! s:NM_cmd_show_parse(inlines)
if part_end
" FIXME: this is a hack for handling two folds being added for one line
- " we should handle addinga fold in a function
+ " we should handle adding a fold in a function
if len(foldinfo) && foldinfo[1] < foldinfo[2]
call add(info['folds'], foldinfo[0:3])
let info['foldtext'][foldinfo[1]] = foldinfo[4]
@@ -943,18 +980,28 @@ function! s:NM_compose_send()
let line = getline(lnum)
let lst_hdr = ''
while match(line, '^$') == -1
- if match(line, '^Notmuch-Help:') == -1
+ if !exists("hdr_starts") && match(line, '^Notmuch-Help:') == -1
let hdr_starts = lnum - 1
- break
endif
let lnum = lnum + 1
let line = getline(lnum)
endwhile
+ let body_starts = lnum - 1
+ call append(body_starts, 'Date: ' . strftime('%a, %d %b %Y %H:%M:%S %z'))
exec printf(':0,%dd', hdr_starts)
write
- let cmdtxt = 'mailx -t < ' . fname
+ let line = getline(1)
+ let m = matchlist(line, '^From:\s*\(.*\)\s*<\(.*\)>$')
+ if (len(m) >= 2)
+ let from = m[2]
+ else
+ let m = matchlist(line, '^From:\s*\(.*\)$')
+ let from = m[1]
+ endif
+
+ let cmdtxt = g:notmuch_sendmail . ' -t -f ' . from . ' < ' . fname
let out = system(cmdtxt)
let err = v:shell_error
if err
@@ -1024,11 +1071,9 @@ endfunction
" --- --- compose screen helper functions {{{2
function! s:NM_compose_get_user_email()
- let name = substitute(system('id -u -n'), '\v(^\s*|\s*$|\n)', '', 'g')
- let fqdn = substitute(system('hostname -f'), '\v(^\s*|\s*$|\n)', '', 'g')
-
- " TODO: do this properly
- return name . '@' . fqdn
+ " TODO: do this properly (still), i.e., allow for multiple email accounts
+ let email = substitute(system('notmuch config get user.primary_email'), '\v(^\s*|\s*$|\n)', '', 'g')
+ return email
endfunction
function! s:NM_compose_find_line_match(start, pattern, failure)
@@ -1266,12 +1311,11 @@ function! s:NM_search_expand(arg)
let b:nm_prev_bufnr = prev_bufnr
endfunction
-function! s:NM_add_remove_tags(filter, prefix, tags)
+function! s:NM_tag(filter, tags)
let filter = len(a:filter) ? a:filter : [NM_search_thread_id()]
if !len(filter)
throw 'Eeek! I couldn''t find the thead id!'
endif
- call map(a:tags, 'a:prefix . v:val')
let args = ['tag']
call extend(args, a:tags)
call add(args, '--')