]> git.notmuchmail.org Git - notmuch/commitdiff
vim: add option to save the patches of a patch series
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 14 Oct 2013 03:38:38 +0000 (22:38 -0500)
committerFelipe Contreras <felipe.contreras@gmail.com>
Wed, 20 Nov 2013 13:23:29 +0000 (07:23 -0600)
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
vim/notmuch.vim

index a1c5e286b612e14a54410746a60f56a18cce9603..9cfa795d3d36e2d1652709b057d4f6aa802f38ca 100644 (file)
@@ -34,6 +34,7 @@ let g:notmuch_rb_show_maps = {
        \ 'o':          'show_open_msg()',
        \ 'e':          'show_extract_msg()',
        \ 's':          'show_save_msg()',
        \ 'o':          'show_open_msg()',
        \ 'e':          'show_extract_msg()',
        \ 's':          'show_save_msg()',
+       \ 'p':          'show_save_patches()',
        \ 'r':          'show_reply()',
        \ '?':          'show_info()',
        \ '<Tab>':      'show_next_msg()',
        \ 'r':          'show_reply()',
        \ '?':          'show_info()',
        \ '<Tab>':      'show_next_msg()',
@@ -181,6 +182,20 @@ ruby << EOF
 EOF
 endfunction
 
 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: ')
 function! s:show_tag(intags)
        if empty(a:intags)
                let tags = input('tags: ')