--- /dev/null
+Return-Path: <dme@dme.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 D3069431FD0\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:53 -0700 (PDT)\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 2W7vIhcP3GC1 for <notmuch@notmuchmail.org>;\r
+ Mon, 12 May 2014 05:29:49 -0700 (PDT)\r
+Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
+ [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 999F3431FDA\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:35 -0700 (PDT)\r
+Received: by mail-wi0-f176.google.com with SMTP id n15so4354394wiw.9\r
+ for <notmuch@notmuchmail.org>; Mon, 12 May 2014 05:29:34 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=/aQI20AsLdN5n9SeuaGD0ctiKhRr1Kp0qlguVsyliB8=;\r
+ b=VtqR+c6e5CJZispBqbRwQWzhWiii9c0lVsPHWNYGzK6MctT9U6fseI7pUbYZ4wYpgY\r
+ auCFzw8jp3/xOpSR3mdn0UwbUzMfmVHUM6nDE+w/hwsTLZyzqOg+RcoMcvpE/nuYd8V9\r
+ hv+1dB85wnBwH2LV9K6AOftksyFbQjCnG9vUQhqmzYCv5qT13VFfHlaoR9hMWMXULCEL\r
+ R+x2prRBOJfvjWDIO0yil6/8rWebETcpZYeTdczdtcxF6/I9eMEndzjseb1iIdzJ8+3D\r
+ s9MvVDJ1NXIRP1gLM5Y6FHGHo1e+xrI5qqWKCjVVq6/0OFKW/NIhtOeXVEIlJuUkJvPP\r
+ 5eTQ==\r
+X-Gm-Message-State:\r
+ ALoCoQkmHGZ9MS9L5jla3XNA4Q9Veb2b3WX1XHBZlxuKLiiMBV8g2keKC/Som1QcG1iPb7TyIHt9\r
+X-Received: by 10.180.100.41 with SMTP id ev9mr15439102wib.22.1399897774439;\r
+ Mon, 12 May 2014 05:29:34 -0700 (PDT)\r
+Received: from hotblack-desiato.hh.sledj.net (disaster-area.hh.sledj.net.\r
+ [81.149.164.25]) by mx.google.com with ESMTPSA id\r
+ dn4sm15869601wib.18.2014.05.12.05.29.32 for <notmuch@notmuchmail.org>\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 12 May 2014 05:29:32 -0700 (PDT)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id 4B31410B330; Mon, 12 May 2014 13:29:29 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 8/9] emacs/mua: Insert part headers depending on the\r
+ message\r
+Date: Mon, 12 May 2014 13:29:28 +0100\r
+Message-Id: <1399897769-26809-9-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 2.0.0.rc0\r
+In-Reply-To: <1399897769-26809-1-git-send-email-dme@dme.org>\r
+References: <87sixdujkv.fsf@qmul.ac.uk>\r
+ <1399897769-26809-1-git-send-email-dme@dme.org>\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, 12 May 2014 12:29:54 -0000\r
+\r
+Whether to insert part headers should depend on the details of the\r
+message being cited.\r
+---\r
+ emacs/notmuch-mua.el | 45 +++++++++++++++++++++++++++++++++++++++++++--\r
+ 1 file changed, 43 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index c800c38..239cc1a 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -132,6 +132,47 @@ list."\r
+ (funcall original-func header references)\r
+ (unless (bolp) (insert "\n")))\r
+ \r
++(defun notmuch-mua-reply-determine-part-function (message)\r
++ "Determine the part header rendering function to use when\r
++citing MESSAGE."\r
++\r
++ (let* ((body (plist-get message :body))\r
++ (first-part (car body)))\r
++ (cond\r
++ ;; If there are multiple top-level parts, we need the\r
++ ;; headers. Will this ever happen?\r
++ ((> (length body) 1)\r
++ #'notmuch-show-insert-header-p-always)\r
++ \r
++ ;; If the type of the part is multipart/mixed, we need to see the\r
++ ;; part headers.\r
++ ((notmuch-match-content-type (plist-get first-part :content-type) "multipart/mixed")\r
++ #'notmuch-show-insert-header-p-always)\r
++\r
++ ;; If it is multipart/alternative the renderer will choose a\r
++ ;; default part and render it. There's no need to show the\r
++ ;; alternative part buttons, as they are not active.\r
++ ((notmuch-match-content-type (plist-get first-part :content-type) "multipart/alternative")\r
++ #'notmuch-show-insert-header-p-never)\r
++\r
++ ;; If it's a multipart/signed with a single text/* part and a\r
++ ;; signature, we don't need to see the headers.\r
++ ((let ((inner-content (plist-get first-part :content)))\r
++ (and (notmuch-match-content-type (plist-get first-part :content-type) "multipart/signed")\r
++ (eq (length inner-content) 2)\r
++ (notmuch-match-content-type (plist-get (nth 0 inner-content) :content-type) "text/*")\r
++ (notmuch-match-content-type (plist-get (nth 1 inner-content) :content-type) "application/pgp-signature")))\r
++ #'notmuch-show-insert-header-p-never)\r
++\r
++ ;; If the type of the part is text/*, we don't need to see the\r
++ ;; part headers.\r
++ ((notmuch-match-content-type (plist-get first-part :content-type) "text/*")\r
++ #'notmuch-show-insert-header-p-never)\r
++ \r
++ ;; Otherwise insert the part headers.\r
++ (t\r
++ #'notmuch-show-insert-header-p-always))))\r
++\r
+ (defun notmuch-mua-reply (query-string &optional sender reply-all)\r
+ (let ((args '("reply" "--format=sexp" "--format-version=1"))\r
+ (process-crypto notmuch-show-process-crypto)\r
+@@ -206,8 +247,8 @@ list."\r
+ ;; citations, etc. in the original message before\r
+ ;; quoting.\r
+ ((notmuch-show-insert-text/plain-hook nil)\r
+- ;; Don't insert part buttons.\r
+- (notmuch-show-insert-header-p-function #'notmuch-show-insert-header-p-never))\r
++ ;; Determine how to insert part headers.\r
++ (notmuch-show-insert-header-p-function (notmuch-mua-reply-determine-part-function original)))\r
+ (notmuch-show-insert-body original (plist-get original :body) 0)\r
+ (buffer-substring-no-properties (point-min) (point-max)))))\r
+ \r
+-- \r
+2.0.0.rc0\r
+\r