Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1B115431FB6 for ; Sun, 19 Oct 2014 02:40:06 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9Lb0Ki-x1v6x for ; Sun, 19 Oct 2014 02:39:58 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id C5AC6431FAF for ; Sun, 19 Oct 2014 02:39:57 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 722FE10008C; Sun, 19 Oct 2014 12:39:33 +0300 (EEST) From: Tomi Ollila To: Ian Main , notmuch@notmuchmail.org Subject: Re: [PATCH] Make patch saving in vim a little better. In-Reply-To: <1412111331-18823-1-git-send-email-imain@stemwinder.org> References: <1412111331-18823-1-git-send-email-imain@stemwinder.org> User-Agent: Notmuch/0.18.1+130~ga61922f (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Oct 2014 09:40:06 -0000 On Wed, Oct 01 2014, Ian Main wrote: > It seems like there was some bitrot on the previous version of this > which made it not work correctly. This fixes the bitrot and also > updates how it works. > > - Sometimes [PATCH.*] isn't at the beginning of the message (often on > lists I'm on). > - It now goes through all the messages in the thread. for some reason > the toplevel messages didn't usually contain all the patches in my > testing. > - Check for 'Re:' at the beginning and skip if it's there. > - Save patches to filesystem-safe filename containing the subject > (unfortunately we use system()...) > > Ian > --- > vim/notmuch.vim | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/vim/notmuch.vim b/vim/notmuch.vim > index b33c6c6..d80f22f 100644 > --- a/vim/notmuch.vim > +++ b/vim/notmuch.vim > @@ -182,12 +182,18 @@ 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] > + t.messages.each do |m| > + next if not m['subject'] =~ /\[PATCH.*\]/ > + next if m['subject'] =~ /^Re:/ > + file = "#{m['subject']}-%04d.patch" % [n += 1] Is the subject here taken from first message in the thread or is the subject changing in every message ? If the name is changing (which I presume, cannot test), the list of files will look a bit confusing. This could follow the git patch naming where the number is at the beginning of filename. > + # Sanitize for the filesystem > + file.gsub!(/[^0-9A-Za-z.\-]/, '_') > + # Remove leading underscores. > + file.gsub!(/^_+/, '') The naming could also follow git way, dashes (-) between words and replacing multiple --:s with just one - (like gsub(/--+/, '-')) -- but in this case there could something in the filename to distinguish from git patches as these patches may be `git am` -incompatible. > + vim_puts "Saving patch to #{file}" > system "notmuch show --format=mbox id:#{m.message_id} > #{file}" > end > - vim_puts "Saved #{n} patches" > + vim_puts "Saved #{n} patch(es)" > EOF > endfunction > > -- > 1.9.3 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch