RE: [PATCH] Make patch saving in vim a little better.
authorFranz Fellner <alpine.art.de@gmail.com>
Sat, 18 Oct 2014 20:48:08 +0000 (22:48 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:05:21 +0000 (10:05 -0800)
39/02e63572c868eaac75272d98cd780e6bf01f61 [new file with mode: 0644]

diff --git a/39/02e63572c868eaac75272d98cd780e6bf01f61 b/39/02e63572c868eaac75272d98cd780e6bf01f61
new file mode 100644 (file)
index 0000000..b18e83a
--- /dev/null
@@ -0,0 +1,129 @@
+Return-Path: <alpine.art.de@gmail.com>\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 A4BCD431FBC\r
+       for <notmuch@notmuchmail.org>; Sat, 18 Oct 2014 13:48:05 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 8bVr2pUO+1Yg for <notmuch@notmuchmail.org>;\r
+       Sat, 18 Oct 2014 13:47:59 -0700 (PDT)\r
+Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com\r
+       [209.85.212.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id D1E58431FB6\r
+       for <notmuch@notmuchmail.org>; Sat, 18 Oct 2014 13:47:58 -0700 (PDT)\r
+Received: by mail-wi0-f170.google.com with SMTP id hi2so5887619wib.5\r
+       for <notmuch@notmuchmail.org>; Sat, 18 Oct 2014 13:47:57 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=date:from:to:message-id:in-reply-to:references:subject:mime-version\r
+       :content-type:content-transfer-encoding;\r
+       bh=+uS9EHZlOe3gaJ9jDLmERtTNyxRse+CpQH+nvVsWJN4=;\r
+       b=nwcnE46rSmieJmWKmMCWdmtJMKWxJFHxl4vp7hBXwac0vIdCHq+NMGUDbEa1kf4G4U\r
+       f7ggBZ8p1w02FqrzkVEdN5Aq/1nwcupPGlFKVta3vjrZLvL3fDHhVcCh3Qb2+W6+SnCY\r
+       cLDNuL53e6pnq0eQv81bKoTKiaEi4QTHBKFfQ6cQwhK6bChivKBa86K6IFqtKN9pbxQI\r
+       2rb0BRtnUsAdJA4FZY047NFupizs1NNHyzG2oWrhcbKvmCmxVa0zmJGeCyiNO8PTEogU\r
+       qxTCVPK5weA5AcQF0THcITbudPKRCzD3JWSiQM8wBDBvcfCcR7zh0JPi/4xEOpwDvwbq\r
+       rC5g==\r
+X-Received: by 10.194.3.101 with SMTP id b5mr20250888wjb.24.1413665277770;\r
+       Sat, 18 Oct 2014 13:47:57 -0700 (PDT)\r
+Received: from localhost (p5B00C687.dip0.t-ipconnect.de. [91.0.198.135])\r
+       by mx.google.com with ESMTPSA id ma8sm6174014wjb.46.2014.10.18.13.47.56\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sat, 18 Oct 2014 13:47:57 -0700 (PDT)\r
+Date: Sat, 18 Oct 2014 22:48:08 +0200\r
+From: Franz Fellner <alpine.art.de@gmail.com>\r
+To: Ian Main <imain@stemwinder.org>, Ian Main <imain@stemwinder.org>, \r
+       notmuch@notmuchmail.org\r
+Message-ID: <5442d2086ff85_255f136de94b2@TP_L520.notmuch>\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
+Subject: RE: [PATCH] Make patch saving in vim a little better.\r
+Mime-Version: 1.0\r
+Content-Type: text/plain;\r
+ charset=utf-8\r
+Content-Transfer-Encoding: 7bit\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: Sat, 18 Oct 2014 20:48:05 -0000\r
+\r
+PATCH LGTM. Did not find any patch that couldn't be saved.\r
+One issue: It saves the patches into $WORKDIR. It would be great if the target path could\r
+be prompted (default again to ~/.notmuch/tmp?) so no random dirs get polluted.\r
+But that isn't a regression to the previous behaviour -> no showstopper.\r
+\r
+Franz\r
+\r
+Ian Main wrote:\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
+> +            # Sanitize for the filesystem\r
+> +            file.gsub!(/[^0-9A-Za-z.\-]/, '_')\r
+> +            # Remove leading underscores.\r
+> +            file.gsub!(/^_+/, '')\r
+> +            vim_puts "Saving patch to #{file}"\r
+>              system "notmuch show --format=mbox id:#{m.message_id} > #{file}"\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
+\r
+\r