Re: [PATCH v2 1/2] emacs: create patch filename from subject for inline patch fake...
authorJani Nikula <jani@nikula.org>
Mon, 26 Dec 2011 21:52:23 +0000 (23:52 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:19 +0000 (09:41 -0800)
b9/3c2b160e5de15cc642f5f351ad5335b33a30c2 [new file with mode: 0644]

diff --git a/b9/3c2b160e5de15cc642f5f351ad5335b33a30c2 b/b9/3c2b160e5de15cc642f5f351ad5335b33a30c2
new file mode 100644 (file)
index 0000000..fed0a03
--- /dev/null
@@ -0,0 +1,153 @@
+Return-Path: <jani@nikula.org>\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 BB1BC431FD0\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Dec 2011 13:52:29 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 v9GPeJLABIIf for <notmuch@notmuchmail.org>;\r
+       Mon, 26 Dec 2011 13:52:29 -0800 (PST)\r
+Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com\r
+ [74.125.83.53])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ C273D431FB6   for <notmuch@notmuchmail.org>; Mon, 26 Dec 2011 13:52:28 -0800\r
+ (PST)\r
+Received: by eekd41 with SMTP id d41so13637008eek.26\r
+       for <notmuch@notmuchmail.org>; Mon, 26 Dec 2011 13:52:27 -0800 (PST)\r
+Received: by 10.14.51.136 with SMTP id b8mr10278450eec.65.1324936347187;\r
+       Mon, 26 Dec 2011 13:52:27 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
+       [80.220.92.23])\r
+       by mx.google.com with ESMTPS id t1sm97489975eeb.3.2011.12.26.13.52.24\r
+       (version=SSLv3 cipher=OTHER); Mon, 26 Dec 2011 13:52:25 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>,\r
+       David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 1/2] emacs: create patch filename from subject for\r
+       inline patch fake parts\r
+In-Reply-To: <8739c7jcfo.fsf@servo.finestructure.net>\r
+References: <1321657368-13872-1-git-send-email-jani@nikula.org>\r
+       <cover.1324849534.git.jani@nikula.org>\r
+       <aa55383e8609a2e0d376744ff3e982fd072c58d6.1324849534.git.jani@nikula.org>\r
+       <cun62h3tu51.fsf@hotblack-desiato.hh.sledj.net>\r
+       <87wr9ja5bp.fsf@nikula.org>\r
+       <8739c7jcfo.fsf@servo.finestructure.net>\r
+User-Agent: Notmuch/0.10.2+131~gb184771 (http://notmuchmail.org) Emacs/23.3.1\r
+       (i686-pc-linux-gnu)\r
+Date: Mon, 26 Dec 2011 23:52:23 +0200\r
+Message-ID: <87mxafq9uw.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Mon, 26 Dec 2011 21:52:29 -0000\r
+\r
+On Mon, 26 Dec 2011 12:38:35 -0800, Jameson Graef Rollins <jrollins@finestructure.net> wrote:\r
+> On Mon, 26 Dec 2011 14:24:42 +0200, Jani Nikula <jani@nikula.org> wrote:\r
+> > > Clicking on the button for the part saves the wrong thing, though,\r
+> > > because it's not a real MIME part. That looks a bit awkward to fix, so\r
+> > > perhaps you could still prefix the name with "inline: " to indicate that\r
+> > > it's odd?\r
+> > \r
+> > I'm not sure I follow you here. Could you elaborate what you mean by\r
+> > "the wrong thing", please?\r
+> \r
+> Yes, this is a problem/bug with the current behavior of these fake\r
+> inline parts, actually.  The button should behave as those it is\r
+> representing an actual MIME part of the message.  However, clicking the\r
+> button saves the entire part that the fake part is derived from, rather\r
+> than just the data in the fake part.  This is countereintuitive and\r
+> confusing.\r
+\r
+Okay, thanks for the explanation. This might be beyond my elisp\r
+skills. And IMHO out of the scope of the patch anyway.\r
+\r
+> > I don't think the user would want to have an "inline: " prefix in the\r
+> > filename that would have to be removed every time. I think that kind of\r
+> > defeats the purpose here. Or where exactly are you proposing to have the\r
+> > prefix?\r
+> \r
+> It's confusing to have this fake part button look just like a real part\r
+> button, without any indication that it's really a fake part, and then to\r
+> behave differently as well.  The button needs some indication that it\r
+> does not represent a real mime part of the message.  Giving the fake\r
+> part a proper filename is fine, but it needs some other indicator that\r
+> the part is fake and that the button is not going to behave as expected.\r
+\r
+Below is an idea I came up with, utilizing the content-type\r
+vs. declared-type distinction. I think it's really simple and neat, but\r
+I hope not too magical.\r
+\r
+Picking up an example mail from the list, inline patches would show up\r
+like this:\r
+\r
+[ 0001-emacs-unify-search-mechanisms.patch: inline patch (as text/x-diff) ]\r
+\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+>From b1847714f7368247fbc5c93767f59d8269eadc1c Mon Sep 17 00:00:00 2001\r
+From: Jani Nikula <jani@nikula.org>\r
+Date: Mon, 26 Dec 2011 23:31:41 +0200\r
+Subject: [PATCH] emacs: add inline patch fake parts through a special handler\r
+\r
+Add wash generated inline patch fake parts through a special\r
+"inline-patch-fake-part" handler to distinguish them from real MIME\r
+parts. The fake parts are described as "inline patch (as text/x-diff)".\r
+\r
+Signed-off-by: Jani Nikula <jani@nikula.org>\r
+---\r
+ emacs/notmuch-show.el |    4 ++++\r
+ emacs/notmuch-wash.el |    2 +-\r
+ 2 files changed, 5 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index eee4da9..6ef3f90 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -585,6 +585,10 @@ current buffer, if possible."\r
+               nil))\r
+         nil))))\r
\r
++;; Handler for wash generated inline patch fake parts.\r
++(defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type nth depth declared-type)\r
++  (notmuch-show-insert-part-*/* msg part "text/x-diff" nth depth "inline patch"))\r
++\r
+ (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)\r
+   ;; This handler _must_ succeed - it is the handler of last resort.\r
+   (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))\r
+diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+index 7d037f5..de51c88 100644\r
+--- a/emacs/notmuch-wash.el\r
++++ b/emacs/notmuch-wash.el\r
+@@ -351,7 +351,7 @@ for error."\r
+             (setq patch-end (match-beginning 0)))\r
+         (save-restriction\r
+           (narrow-to-region patch-start patch-end)\r
+-          (setq part (plist-put part :content-type "text/x-diff"))\r
++          (setq part (plist-put part :content-type "inline-patch-fake-part"))\r
+           (setq part (plist-put part :content (buffer-string)))\r
+           (setq part (plist-put part :id -1))\r
+           (setq part (plist-put part :filename\r
+-- \r
+1.7.5.4\r
+\r