[RFC] Content-Description when naming MIME parts in Emacs mode
authorW. Trevor King <wking@tremily.us>
Sun, 2 Feb 2014 20:46:17 +0000 (12:46 +1600)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:59:33 +0000 (09:59 -0800)
9c/b07d4bb295350003f2d01529fecbd6ab8f8046 [new file with mode: 0644]

diff --git a/9c/b07d4bb295350003f2d01529fecbd6ab8f8046 b/9c/b07d4bb295350003f2d01529fecbd6ab8f8046
new file mode 100644 (file)
index 0000000..3204862
--- /dev/null
@@ -0,0 +1,174 @@
+Return-Path: <wking@tremily.us>\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 A6276431FBD\r
+       for <notmuch@notmuchmail.org>; Sun,  2 Feb 2014 12:54:39 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       RCVD_IN_DNSWL_NONE=-0.0001] 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 Qnf8rC7eOq0n for <notmuch@notmuchmail.org>;\r
+       Sun,  2 Feb 2014 12:54:31 -0800 (PST)\r
+X-Greylist: delayed 489 seconds by postgrey-1.32 at olra;\r
+       Sun, 02 Feb 2014 12:54:31 PST\r
+Received: from qmta02.westchester.pa.mail.comcast.net\r
+       (qmta02.westchester.pa.mail.comcast.net [76.96.62.24])\r
+       by olra.theworths.org (Postfix) with ESMTP id 54819431FBC\r
+       for <notmuch@notmuchmail.org>; Sun,  2 Feb 2014 12:54:31 -0800 (PST)\r
+Received: from omta06.westchester.pa.mail.comcast.net ([76.96.62.51])\r
+       by qmta02.westchester.pa.mail.comcast.net with comcast\r
+       id MXyj1n00516LCl051YmLTS; Sun, 02 Feb 2014 20:46:20 +0000\r
+Received: from odin.tremily.us ([24.18.63.50])\r
+       by omta06.westchester.pa.mail.comcast.net with comcast\r
+       id MYmK1n00E152l3L3SYmKoc; Sun, 02 Feb 2014 20:46:20 +0000\r
+Received: by odin.tremily.us (Postfix, from userid 1000)\r
+       id 8EB50FB067C; Sun,  2 Feb 2014 12:46:17 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tremily.us; s=odin;\r
+       t=1391373977; bh=XcX8eC78IwtVg8Uji22aGMQAHvvr5LgCO8tU9GKnE20=;\r
+       h=Date:From:To:Subject;\r
+       b=ery8RxIRh+9FBbfllTt5CqvJMIo+ADrcT7dZZSQ7ET6LSB3wwF8b2ngL5CHjb8wm6\r
+       tfupHdoBsjZp79Noq6arMwRB7dV8CCVwJbWCDI9ac3xinnz1vN0cVBjri5G+a9xEYQ\r
+       uy9nF+F8O+S3H9HQf956TU1pcbBJci2SKQg+F0Ok=\r
+Date: Sun, 2 Feb 2014 12:46:17 -0800\r
+From: "W. Trevor King" <wking@tremily.us>\r
+To: notmuch@notmuchmail.org\r
+Subject: [RFC] Content-Description when naming MIME parts in Emacs mode\r
+Message-ID: <20140202204616.GD14197@odin.tremily.us>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; micalg=pgp-sha1;\r
+       protocol="application/pgp-signature"; boundary="cHOhevsz5PKyTXvv"\r
+Content-Disposition: inline\r
+OpenPGP: id=39A2F3FA2AB17E5D8764F388FC29BDCDF15F5BE8;\r
+       url=http://tremily.us/pubkey.txt\r
+User-Agent: Mutt/1.5.22 (2013-10-16)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net;\r
+       s=q20121106; t=1391373980;\r
+       bh=kVNMZCpAdEgUE+AJlaP8p0JpEXDQHZN3PvccdLc4bZ0=;\r
+       h=Received:Received:Received:Date:From:To:Subject:Message-ID:\r
+       MIME-Version:Content-Type;\r
+       b=HpfG4Ip/7T77DeaFBu04M6DpRrdfCWnZouobboccTHVIx1qYN/Jl+jKooRXC8ptuS\r
+       /WF3D62ZU1hWkjySxTbIF/dn2tb9JxegyuH32NVzvx0HJnTFAAkPApRMs2ZM/4wcat\r
+       kTXUN8R2LQ9Utzl6Ix7Qr83s3cmmbPo2PsuPzKqx7mTAGLjaHOcvqlHEatq7wNMk1S\r
+       NTxM1gOvIWH3IPxo/OT/oYrzJbJPJUiXWJrsdAxVxCrtVc+S83If0/hlICGLo/A5aT\r
+       PMTMCXVwxzT2kfY+PKyyTh4/9QRZ6JyNySw9I7FQCv0MDXMHPL30CmhsoWtN4Tof1I\r
+       Hasr4rmS8blfg==\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, 02 Feb 2014 20:54:39 -0000\r
+\r
+\r
+--cHOhevsz5PKyTXvv\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Disposition: inline\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+On the rss2email list, Victor Orlikowski pointed out [1] that a number\r
+of MUAs don't use the Subject header of attached message/rfc822 parts\r
+to label multipart/digest subparts [2].  Instead, notmuch and several\r
+other MUAs use the filename parameter [3] as a content hint [4].\r
+Using the filename parameter seems more sane than diving into the\r
+message/rfc822 part header, but that's still not what the filename\r
+parameter was designed for.  It makes more sense to me to use the\r
+message/rfc822 part's Content-Description header [5,6], falling back\r
+on the filename parameter if Content-Description isn't set.\r
+\r
+It's pretty easy to patch notmuch-show-insert-bodypart to do this:\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 1ac80ca..485c7d1 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -874,13 +874,16 @@ useful for quoting in replies)."\r
+                         content-type))\r
+          (nth (plist-get part :id))\r
+          (beg (point))\r
++         (name (if (plist-get part :content-description)\r
++                   (plist-get part :content-description)\r
++                   (plist-get part :filename)))\r
+          ;; Hide the part initially if HIDE is t.\r
+          (show-part (not (equal hide t)))\r
+          ;; We omit the part button for the first (or only) part if\r
+          ;; this is text/plain, or HIDE is 'no-buttons.\r
+          (button (unless (or (equal hide 'no-buttons)\r
+                              (and (string=3D mime-type "text/plain") (<=3D=\r
+ nth 1)))\r
+-                   (notmuch-show-insert-part-header nth mime-type content-=\r
+type (plist-get part :filename))))\r
++                   (notmuch-show-insert-part-header nth mime-type content-=\r
+type name)))\r
+          (content-beg (point)))\r
+=20\r
+     ;; Store the computed mime-type for later use (e.g. by attachment hand=\r
+lers).\r
+\r
+But that doesn't work, because :content-description doesn't exist in\r
+the part plist.  I've looked through the source for a bit and can't\r
+figure out where that part plist is coming from.  Is it loaded from\r
+notmuch output in notmuch-show-build-buffer?  I assume that\r
+information comes from the index, in which case I'd need to tweak\r
+_index_mime_part in lib/index.cc to add the description.  Indexing\r
+descriptions seems like a generally useful thing, even outside of my\r
+digest usecase (e.g. search image/jpeg attachements with =E2=80=9Cgenome=E2=\r
+=80=9D in\r
+their description [6]).  However, adding a field to the schema is more\r
+invasive than changing the Emacs mode's attachment formatting; I\r
+thought I should check in here for feedback and advice before wading\r
+in with my =E2=80=94a=CC=B6x=CC=B6e=CC=B6=E2=80=94 scalpel ;).\r
+\r
+Thoughs?\r
+Trevor\r
+\r
+[1]: http://article.gmane.org/gmane.mail.rss2email/211\r
+[2]: Digests: http://tools.ietf.org/html/rfc2046#section-5.1.5\r
+[3]: Filename: http://tools.ietf.org/search/rfc2183#section-2.3\r
+[4]: Filename hint to notmuch-show-insert-part-header:\r
+     http://git.notmuchmail.org/git/notmuch/blob/HEAD:/emacs/notmuch-show.e=\r
+l#l883\r
+[5]: Content-Desciption:\r
+     http://tools.ietf.org/html/rfc2045#section-8\r
+[6]: Content-Description examples:\r
+     http://tools.ietf.org/html/rfc2183#section-3\r
+\r
+--=20\r
+This email may be signed or encrypted with GnuPG (http://www.gnupg.org).\r
+For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\r
+\r
+--cHOhevsz5PKyTXvv\r
+Content-Type: application/pgp-signature; name="signature.asc"\r
+Content-Description: OpenPGP digital signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2.0.22 (GNU/Linux)\r
+\r
+iQIcBAEBAgAGBQJS7q6UAAoJEKKfehoaNkbtDloQAKqHKmui8Ron0MtQSKgnDHMj\r
+NT4jftGDWGLtunq+1zr5+IIglzEQ88Z+Q2+2NpHq1IQYKfI1NPnScVGoCjJucv1O\r
+pB9TKxsWOPptVE8s8A2W50Hb01pVzXNt9oN5VsPzZ8GkjaLu3UL3E/UrY1mqGP92\r
+ChBWU/lMPED4we9KQAifFV4zM88c3gzHVQKCXHRRRDZ0FpjDWB7ZK5sqtfNXgmU5\r
+pnwBgxpE2OK4xTq3ZuttmsIPcxO7l0p6WD93kCxQRNcC/JjRyms5an+n4hv72Wop\r
+ulvCwGqm1kO6x7NMAqSCi4pDb8If8b9K39D6AnKXo9OKORnVrIdWS/y9pD8mI0nP\r
+3VRmcWVCezSutP5kod4022kd1GxmziHNV4a2MJ0rL8AICAd5ufiISXC7bVWqLppf\r
+RZm35nv51wNHGoouJgnVPaQFNlfNaZE6mlt+3jYc4dyLrU3UDyZ0bJ5w3qrJDLfD\r
+uud8mkHFx7TvssmgY+Qf8+OR14GI2MSvfabINhIXjIhrhFjxrQEKEtRpr1+WOwBQ\r
+l5gtPJEpigqmtARbzEcXcv964VGF9PsfJRNps48ZqEoyGLbTOTVu28qySouoaULR\r
+gmZVvSI18DB3cKIAgV/njolobn9MMwv5YR9VkKoLbaJYeNX0j4Er1Lp5ubXTfqvz\r
+tKNTxGYhjyYhphGxNPdo\r
+=Ppvq\r
+-----END PGP SIGNATURE-----\r
+\r
+--cHOhevsz5PKyTXvv--\r