--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id A1B316DE01D0\r
+ for <notmuch@notmuchmail.org>; Fri, 20 May 2016 04:38:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.316\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.316 tagged_above=-999 required=5 tests=[AWL=0.254,\r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id NlKYqNX52kzc for <notmuch@notmuchmail.org>;\r
+ Fri, 20 May 2016 04:38:21 -0700 (PDT)\r
+Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
+ [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 826666DE00F5 for\r
+ <notmuch@notmuchmail.org>; Fri, 20 May 2016 04:38:21 -0700 (PDT)\r
+Received: by mail-wm0-f66.google.com with SMTP id 67so5312157wmg.0\r
+ for <notmuch@notmuchmail.org>; Fri, 20 May 2016 04:38:21 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id;\r
+ bh=9Umt+YZvpt70W8T8rAVpIkYNnRC78Ea2e+bULr+eQJE=;\r
+ b=hpmTeuupXOeE78vChOBSOYbumAwobmvqaKQxskIvyjV+jv18HOXeodTSWSm+SPiFpr\r
+ n+IYw5fRSEFmYB38FUa7WmcQjjY4hSlqeBnv4O1Rh3m5pEGuL+xnduPafc/mn92N8C4K\r
+ 7+PHeksUYQjKhzvu71qAJmGDnUhUChTMBJSDYNmZQFkHnxoV2aNg2wLbMAPzqWHv0Vik\r
+ H9VoVD9YQ3ExBNfRltdDo2DV9bLqamy9OSwgKpYGYdX6QdtDp6BAKpmbQ/JGgWZpxpCi\r
+ jTKuR0GdbttAlmgoQ0FIYyCRnJRPvQ0XuafbiecihuXbC2/dKHFb4jvSWi/HBdAtduY6\r
+ J23w==\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:cc:subject:date:message-id;\r
+ bh=9Umt+YZvpt70W8T8rAVpIkYNnRC78Ea2e+bULr+eQJE=;\r
+ b=Lu+Py/1TeErY8z6HyJbbFGVJ9klrblkNWbYj5Aw9ZJLHLRKJibgThYkFAyXTURJnD4\r
+ CfNZWw/MHeTR9NZkfTkwQaRKJ7XA5g6HAeBbUQlb5G9pzD2BSXRRp3O6GaFGwXmSIb/f\r
+ VLHMwib9izGsMZvKl/zIJDAb3RTkmw9J+bXopHKgIzdXibvcpeaoRIoLUQWdpwdk2EBP\r
+ 2yxHd+igsF4KZNT+D7KZLJGAzFWGhs108GmkjI2vYKwbv8/2+QQAnhvitSLRgfrFMue3\r
+ v3IWZVGpwHlKZgtakVsjX4Ax12mIgcpifl28N9vxnZXM85QnTJ/TQjWgxj12oN3R00BA\r
+ ptFw==\r
+X-Gm-Message-State:\r
+ AOPr4FUDKLg3Cl0I6BFQ3vQaFZOSZC4227Ne1nX1VAt4//aCW5+f9+8PqOpgNQc0j89keg==\r
+X-Received: by 10.28.22.134 with SMTP id 128mr3155801wmw.16.1463744299380;\r
+ Fri, 20 May 2016 04:38:19 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id a75sm4172475wme.18.2016.05.20.04.38.18\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 20 May 2016 04:38:18 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: show: allow user to insert rfc822 parts as messages\r
+Date: Fri, 20 May 2016 12:38:15 +0100\r
+Message-Id: <1463744295-12533-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 20 May 2016 11:38:29 -0000\r
+\r
+This adds a part-handler function that uses notmuch-insert to insert\r
+an rfc822 part as a message in its own right. This allows the user to\r
+reply directly to that message.\r
+---\r
+\r
+I receive quite a lot of forwarded messages which include the original\r
+message as an rfc822 part, and have used this for quite some time\r
+without any problems.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+emacs/notmuch-show.el | 29 ++++++++++++++++++++++++-----\r
+ 1 file changed, 24 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 5d9b7b4..de41a8f 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -141,6 +141,11 @@ indentation."\r
+ (const :tag "View interactively"\r
+ notmuch-show-interactively-view-part)))\r
+ \r
++(defcustom notmuch-show-part-insert-folder ""\r
++ "Default folder to insert rfc822 parts"\r
++ :group 'notmuch-show\r
++ :type 'string)\r
++\r
+ (defcustom notmuch-show-only-matching-messages nil\r
+ "Only matching messages are shown by default."\r
+ :type 'boolean\r
+@@ -1403,6 +1408,7 @@ reset based on the original query."\r
+ (define-key map "v" 'notmuch-show-view-part)\r
+ (define-key map "o" 'notmuch-show-interactively-view-part)\r
+ (define-key map "|" 'notmuch-show-pipe-part)\r
++ (define-key map "i" 'notmuch-show-insert-part)\r
+ (define-key map "?" 'notmuch-subkeymap-help)\r
+ map)\r
+ "Submap for part commands")\r
+@@ -2330,11 +2336,13 @@ caller is responsible for killing this buffer as appropriate."\r
+ (disposition (if filename `(attachment (filename . ,filename)))))\r
+ (mm-make-handle buf (list computed-type) nil nil disposition)))\r
+ \r
+-(defun notmuch-show-apply-to-current-part-handle (fn)\r
++(defun notmuch-show-apply-to-current-part-handle (fn &rest args)\r
+ "Apply FN to an mm-handle for the part containing point.\r
+ \r
+-This ensures that the temporary buffer created for the mm-handle\r
+-is destroyed when FN returns."\r
++Any ARGS are passed to the function FN as arguments after the mm-handle.\r
++\r
++This function ensures that the temporary buffer created for the\r
++mm-handle is destroyed when FN returns."\r
+ (let ((handle (notmuch-show-current-part-handle)))\r
+ ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we\r
+ ;; call it from a temp-buffer, unless\r
+@@ -2343,9 +2351,9 @@ is destroyed when FN returns."\r
+ (unwind-protect\r
+ (if notmuch-show-attachment-debug\r
+ (with-current-buffer (generate-new-buffer " *notmuch-part*")\r
+- (funcall fn handle))\r
++ (apply fn handle args))\r
+ (with-temp-buffer\r
+- (funcall fn handle)))\r
++ (apply fn handle args)))\r
+ (kill-buffer (mm-handle-buffer handle)))))\r
+ \r
+ (defun notmuch-show-part-button-default (&optional button)\r
+@@ -2379,6 +2387,17 @@ is destroyed when FN returns."\r
+ (interactive)\r
+ (notmuch-show-apply-to-current-part-handle #'mm-pipe-part))\r
+ \r
++(defun notmuch-show-insert-part ()\r
++ "If the current part is rfc822 then insert into the mailstore"\r
++ (interactive)\r
++ (let* ((part (notmuch-show-get-part-properties))\r
++ (computed-type (plist-get part :computed-type)))\r
++ (if (notmuch-match-content-type computed-type "message/rfc822")\r
++ (let* ((folder (read-from-minibuffer "Folder to save part to: "\r
++ notmuch-show-part-insert-folder))\r
++ (cmd (concat notmuch-command " insert --folder=" folder)))\r
++ (notmuch-show-apply-to-current-part-handle #'mm-pipe-part cmd))\r
++ (message "Not a message/rfc822 part."))))\r
+ \r
+ (provide 'notmuch-show)\r
+ \r
+-- \r
+2.1.4\r
+\r