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