X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=vim%2Fplugin%2Fnotmuch.vim;h=f33d0582c9153018e084f0625d8eca062a159493;hp=ef3260ed085473a0943f9820f86f0994d993a45c;hb=8a3352e619de6d347e1eb42011e65a85f0f4c7ca;hpb=b76852dcc517dc3fc754c26b438f0875e4cfbb3f diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim index ef3260ed..f33d0582 100644 --- a/vim/plugin/notmuch.vim +++ b/vim/plugin/notmuch.vim @@ -105,6 +105,7 @@ let s:notmuch_compose_headers_defaults = [ " --- --- bindings for folders mode {{{2 let g:notmuch_folders_maps = { + \ 'm': ':call NM_new_mail()', \ 's': ':call NM_search_prompt()', \ 'q': ':call NM_kill_this_buffer()', \ '=': ':call NM_folders_refresh_view()', @@ -113,7 +114,8 @@ let g:notmuch_folders_maps = { " --- --- bindings for search screen {{{2 let g:notmuch_search_maps = { - \ '': ':call NM_search_show_thread()', + \ '': ':call NM_search_show_thread(0)', + \ '': ':call NM_search_show_thread(1)', \ '': ':call NM_search_expand('''')', \ 'a': ':call NM_search_archive_thread()', \ 'f': ':call NM_search_filter()', @@ -136,11 +138,12 @@ let g:notmuch_show_maps = { \ '': ':call NM_show_next(1, 0)', \ '': ':call NM_search_expand('''')', \ 'q': ':call NM_kill_this_buffer()', + \ 's': ':call NM_search_prompt()', \ \ 'b': ':call NM_show_fold_toggle(''b'', ''bdy'', !g:notmuch_show_fold_bodies)', \ 'c': ':call NM_show_fold_toggle(''c'', ''cit'', !g:notmuch_show_fold_citations)', \ 'h': ':call NM_show_fold_toggle(''h'', ''hdr'', !g:notmuch_show_fold_headers)', - \ 's': ':call NM_show_fold_toggle(''s'', ''sig'', !g:notmuch_show_fold_signatures)', + \ 'i': ':call NM_show_fold_toggle(''s'', ''sig'', !g:notmuch_show_fold_signatures)', \ \ 'a': ':call NM_show_archive_thread()', \ 'A': ':call NM_show_mark_read_then_archive_thread()', @@ -264,17 +267,14 @@ endfunction " --- --- search screen action functions {{{2 -function! s:NM_search_show_thread() - let id = NM_search_thread_id() - if id != '' - let words = [id] - if exists('b:nm_search_words') - let words = ['('] + b:nm_search_words + [')', 'AND', id] - endif - if len(words) - call NM_cmd_show(words) - endif +function! s:NM_search_show_thread(everything) + let words = [ NM_search_thread_id() ] + if !a:everything && exists('b:nm_search_words') + call extend(words, ['AND', '(']) + call extend(words, b:nm_search_words) + call add(words, ')') endif + call NM_cmd_show(words) endfunction function! s:NM_search_prompt() @@ -346,7 +346,14 @@ function! s:NM_search_toggle_order() endfunction function! s:NM_search_reply_to_thread() - echo 'not implemented' + let cmd = ['reply'] + call add(cmd, NM_search_thread_id()) + call add(cmd, 'AND') + call extend(cmd, NM_get_search_words()) + + let data = NM_run(cmd) + let lines = split(data, "\n") + call NM_newComposeBuffer(lines, 0) endfunction function! s:NM_search_add_tags(tags) @@ -401,7 +408,7 @@ endfunction function! s:NM_cmd_show(words) let prev_bufnr = bufnr('%') - let data = s:NM_run(['show'] + a:words) + let data = s:NM_run(['show', '--entire-thread'] + a:words) let lines = split(data, "\n") let info = s:NM_cmd_show_parse(lines) @@ -498,7 +505,14 @@ function! s:NM_show_previous_message() endfunction function! s:NM_show_reply() - echo 'not implemented' + let cmd = ['reply'] + call add(cmd, NM_show_message_id()) + call add(cmd, 'AND') + call extend(cmd, NM_get_search_words()) + + let data = NM_run(cmd) + let lines = split(data, "\n") + call NM_newComposeBuffer(lines, 0) endfunction function! s:NM_show_view_all_mime_parts() @@ -624,9 +638,19 @@ function! s:NM_show_fold_toggle(key, type, fold) let act = 'close' endif for fld in info['folds'] - if fld[0] == a:type - exec printf('%dfold%s', fld[1], act) + if fld[0] != a:type + continue + endif + "let idx = fld[3] + "let msg = info['msgs'][idx] + "if has_key(msg,'match') && msg['match'] == '0' + " continue + "endif + let cls = foldclosed(fld[1]) + if cls != -1 && cls != fld[1] + continue endif + exec printf('%dfold%s', fld[1], act) endfor exec printf('nnoremap %s :call NM_show_fold_toggle(''%s'', ''%s'', %d)', a:key, a:key, a:type, !a:fold) endfunction @@ -938,9 +962,7 @@ function! s:NM_compose_send() let lnum = lnum + 1 let line = getline(lnum) endwhile - let body_starts = lnum + 1 - exec printf('0,%dd', body_starts) - write + let body_starts = lnum "[-a header] [-b bcc-addr] [-c cc-addr] [-s subject] to-addr let cmd = ['mail'] @@ -972,6 +994,12 @@ function! s:NM_compose_send() endfor call extend(cmd, tos) + " TODO: make sure we have at least one target + " TODO: ask about empty jubject, etc + + exec printf('0,%dd', body_starts) + write + call map(cmd, 's:NM_shell_escape(v:val)') let cmdtxt = join(cmd) . '< ' . fname let out = system(cmdtxt) @@ -1130,7 +1158,7 @@ function! s:NM_newComposeBuffer(lines, start_on_line) if start_on_line > 0 && start_on_line <= len(lines) call cursor(start_on_line, strlen(getline(start_on_line)) + 1) else - call cursor(real_hdr_start, strlen(getline(real_hdr_start) + 1) + call cursor(real_hdr_start, strlen(getline(real_hdr_start)) + 1) call NM_compose_next_entry_area() endif @@ -1227,7 +1255,7 @@ endfunction " --- external mail handling helpers {{{1 function! s:NM_new_mail() - echo 'not implemented' + call NM_cmd_compose([], []) endfunction " --- tag manipulation helpers {{{1