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