X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=vim%2Fnotmuch.vim;h=9cfa795d3d36e2d1652709b057d4f6aa802f38ca;hb=77c2c3143be1f69f10f04f9e5e885a30248c2fd0;hp=11ea4fd363467865e973a0571b18c9c7bfcc39c6;hpb=01859bd7ce98cd1a2938a628e1a21714016e0421;p=notmuch diff --git a/vim/notmuch.vim b/vim/notmuch.vim index 11ea4fd3..9cfa795d 100644 --- a/vim/notmuch.vim +++ b/vim/notmuch.vim @@ -34,6 +34,7 @@ let g:notmuch_rb_show_maps = { \ 'o': 'show_open_msg()', \ 'e': 'show_extract_msg()', \ 's': 'show_save_msg()', + \ 'p': 'show_save_patches()', \ 'r': 'show_reply()', \ '?': 'show_info()', \ '': 'show_next_msg()', @@ -181,6 +182,20 @@ ruby << EOF EOF endfunction +function! s:show_save_patches() +ruby << EOF + q = $curbuf.query($cur_thread) + t = q.search_threads.first + n = 0 + t.toplevel_messages.first.replies.each do |m| + next if not m['subject'] =~ /^\[PATCH.*\]/ + file = "%04d.patch" % [n += 1] + system "notmuch show --format=mbox id:#{m.message_id} > #{file}" + end + vim_puts "Saved #{n} patches" +EOF +endfunction + function! s:show_tag(intags) if empty(a:intags) let tags = input('tags: ') @@ -302,7 +317,7 @@ ruby << EOF $messages.clear $curbuf.render do |b| q = $curbuf.query(get_cur_view) - q.sort = 0 + q.sort = Notmuch::SORT_OLDEST_FIRST msgs = q.search_messages msgs.each do |msg| m = Mail.read(msg.filename)