X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=05c21d3cead8af05305b4e01aed52f25ba13fcfe;hp=bdf03ba6c8edf14a99f9a5081b99ce9e654c87ce;hb=e236142f039c1a77ec2a40853cec102681b33adb;hpb=4aeb291c783c18d0c63277275f67798f227e3017 diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index bdf03ba6..05c21d3c 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -18,12 +18,14 @@ " along with Notmuch. If not, see . " " Authors: Bart Trojanowski -" Contributors: Peter Hartman +" 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 , @@ -147,6 +149,7 @@ 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()', \ 'N': ':call NM_show_mark_read_then_next_open_message()', @@ -308,12 +311,12 @@ function! s:NM_search_edit() 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 @@ -404,7 +407,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 @@ -493,12 +497,18 @@ 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 @@ -562,7 +572,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 @@ -581,7 +592,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 @@ -944,18 +956,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 @@ -1265,12 +1287,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, '--')