--- /dev/null
+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 91588431FDC\r
+ for <notmuch@notmuchmail.org>; Mon, 19 Aug 2013 01:38:22 -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 DZq697wWaxWv for <notmuch@notmuchmail.org>;\r
+ Mon, 19 Aug 2013 01:38:15 -0700 (PDT)\r
+Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com\r
+ [209.85.214.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id CE7C3431FBD\r
+ for <notmuch@notmuchmail.org>; Mon, 19 Aug 2013 01:38:14 -0700 (PDT)\r
+Received: by mail-bk0-f41.google.com with SMTP id na10so1334627bkb.14\r
+ for <notmuch@notmuchmail.org>; Mon, 19 Aug 2013 01:38:13 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+ bh=e/LQhyA7rjusE9XyBJ0qgcGNiPMc7WR0DpiIINMgpEk=;\r
+ b=MwuUGhN/2ErSWqOi6qax5FcesD9EPFfBQo8r2/JU57XONDNR3fvO4D8+P5X7FYPWoe\r
+ U2BIOqOsT/81Kc4Hm8Q8JgAFLvLh/PxKU8I2vwz0BXWeMviDPtjuo8dKMEHfqSzjGwDV\r
+ SfsPo8EUDxSjfiI9Umxp9X26GuBnbPe8unwCXN2tKedKakngt8kHG/Gaq/ue3IIlXheR\r
+ kcCR/bDuYtNGHntSgr5cZeq2wC6tpfwEY1HRf5r5GbFVdXGk7wfkpPePOSBi2i25AmJ2\r
+ X+5Cukuxbu2LkHlSsgskALXIrvQ6X+FQxH3ibIyLvzdOxzVMbo3XI/1an8VXSSn4Jj7y\r
+ k10Q==\r
+X-Gm-Message-State:\r
+ ALoCoQknIJg+P1EgcjWdisQh/UAZIWu1jdhL68FoukG1kvU5tc3cbv0E/zAE5abiAIEVazD9hjW4\r
+X-Received: by 10.205.10.200 with SMTP id pb8mr7149161bkb.16.1376901493489;\r
+ Mon, 19 Aug 2013 01:38:13 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91]) by mx.google.com with ESMTPSA id\r
+ if11sm1421624bkc.15.1969.12.31.16.00.00\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Mon, 19 Aug 2013 01:38:12 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: insert quotable parts in reply as they are displayed\r
+ in show view\r
+Date: Mon, 19 Aug 2013 11:38:15 +0300\r
+Message-Id: <1376901495-17349-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\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, 19 Aug 2013 08:38:22 -0000\r
+\r
+In reply, insert quotable parts using notmuch-show-insert-bodypart\r
+instead of calling notmuch-mm-display-part-inline directly to render\r
+the quoted parts as they are rendered in show view.\r
+\r
+The notable change is that replies to text/calendar parts quote the\r
+pretty printed output of icalendar-import-buffer rather than the ugly\r
+raw vcalendar.\r
+---\r
+ emacs/notmuch-mua.el | 7 ++++---\r
+ emacs/notmuch-show.el | 9 ++++++---\r
+ 2 files changed, 10 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 2baae5f..24b0d0f 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -130,9 +130,10 @@ list."\r
+ (defun notmuch-mua-insert-quotable-part (message part)\r
+ (save-restriction\r
+ (narrow-to-region (point) (point))\r
+- (notmuch-mm-display-part-inline message part (plist-get part :id)\r
+- (plist-get part :content-type)\r
+- notmuch-show-process-crypto)\r
++ ;; We don't want hooks, such as notmuch-wash-*, to be run on the\r
++ ;; quotable part.\r
++ (let ((notmuch-show-insert-text/plain-hook nil))\r
++ (notmuch-show-insert-bodypart message part 0 nil t))\r
+ (goto-char (point-max))))\r
+ \r
+ ;; There is a bug in emacs 23's message.el that results in a newline\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 82b70ba..1fb48aa 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -874,7 +874,7 @@ message at DEPTH in the current thread."\r
+ ;; showable this returns nil.\r
+ (notmuch-show-create-part-overlays button part-beg part-end))))\r
+ \r
+-(defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
++(defun notmuch-show-insert-bodypart (msg part depth &optional hide quote)\r
+ "Insert the body part PART at depth DEPTH in the current thread.\r
+ \r
+ If HIDE is non-nil then initially hide this part."\r
+@@ -887,8 +887,11 @@ If HIDE is non-nil then initially hide this part."\r
+ content-type))\r
+ (nth (plist-get part :id))\r
+ (beg (point))\r
+- ;; We omit the part button for the first (or only) part if this is text/plain.\r
+- (button (unless (and (string= mime-type "text/plain") (<= nth 1))\r
++ ;; We omit the part button for the first (or only) part if\r
++ ;; this is text/plain, or we're inserting the part for\r
++ ;; quoting in reply.\r
++ (button (unless (or quote\r
++ (and (string= mime-type "text/plain") (<= nth 1)))\r
+ (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
+ (content-beg (point)))\r
+ \r
+-- \r
+1.7.10.4\r
+\r