--- /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 38E21431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 02:18:20 -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 7z23kfWnNqNu for <notmuch@notmuchmail.org>;\r
+ Sat, 5 Apr 2014 02:18:14 -0700 (PDT)\r
+Received: from mail-we0-f182.google.com (mail-we0-f182.google.com\r
+ [74.125.82.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 83889431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 5 Apr 2014 02:18:14 -0700 (PDT)\r
+Received: by mail-we0-f182.google.com with SMTP id p61so4532076wes.27\r
+ for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 02:18:11 -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:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=8LJq/kSp1nWUYUrMDz9AGj8wCQkmfW9jh7oagRmZWsE=;\r
+ b=RTgL9pGDL4Wc77oiL7tV/TPOy3CFuSKsUZmpDlwlYFx/2a3zWat/QS5D69yF5xgXpi\r
+ cFThOtfp61570JMwfHTF8ghTcaV+SQL5S+9pRTG2wsVcEp6G6tjvB2Oo3jK04ikbvt6G\r
+ dm9RfJNFnBUdCVgb2XI64kRWu7bSF/KSP2W0MlmEurMifKQUtwR7wevaGWUhhCliyidK\r
+ VS63UGbYCgzcQQawDdkKKrWNqaIRrSiI+NpSjNbebv1qLsiaaxuCWD3DU7KJ6v9NxuZT\r
+ OXjOJeeYMEcavQOwL37rC8RiRr1kWgYqTDrYUQCWqNUiQTrtBDHOnoeWc+tLszCK8rw6\r
+ 5hbA==\r
+X-Gm-Message-State:\r
+ ALoCoQk2g8AQcn5oOslChySuwAC6Rti21+1l/20JxTAWmCSXulqy0ZxKz6RTVXJ1hlxwDqUnGdW3\r
+X-Received: by 10.194.187.107 with SMTP id fr11mr26542331wjc.70.1396689490550;\r
+ Sat, 05 Apr 2014 02:18:10 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id w1sm25636216eel.16.2014.04.05.02.18.08\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 05 Apr 2014 02:18:09 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: sign/encrypt replies to signed/encrypted messages\r
+Date: Sat, 5 Apr 2014 12:18:06 +0300\r
+Message-Id: <1396689486-19232-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.9.1\r
+In-Reply-To: <87a9f1c8aq.fsf@servo.finestructure.net>\r
+References: <87a9f1c8aq.fsf@servo.finestructure.net>\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: Sat, 05 Apr 2014 09:18:20 -0000\r
+\r
+This is a simple approach to improving security when replying to\r
+signed or encrypted messages. If the message being replied to was\r
+signed, add mml tag to sign the reply. If the message being replied to\r
+was encrypted, add mml tag to sign and encrypt the reply.\r
+\r
+This may need configuration; I for one might want to encrypt replies\r
+to encrypted messages, but not always sign replies to signed messages.\r
+\r
+This still includes a slight bug: if any mml tags are added, they are\r
+included in the region containing the quoted parts. Killing the region\r
+will kill the mml tags too.\r
+---\r
+ emacs/notmuch-mua.el | 14 +++++++++++++-\r
+ 1 file changed, 13 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index ba3ef275ec5e..9fb84b57b030 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -115,6 +115,15 @@ list."\r
+ (push header message-hidden-headers)))\r
+ notmuch-mua-hidden-headers))\r
+ \r
++(defun notmuch-mua-reply-crypto (parts)\r
++ (loop for part in parts\r
++ if (notmuch-match-content-type (plist-get part :content-type) "multipart/signed")\r
++ do (mml-secure-message-sign)\r
++ else if (notmuch-match-content-type (plist-get part :content-type) "multipart/encrypted")\r
++ do (mml-secure-message-sign-encrypt)\r
++ else if (notmuch-match-content-type (plist-get part :content-type) "multipart/*")\r
++ do (notmuch-mua-reply-crypto (plist-get part :content))))\r
++\r
+ (defun notmuch-mua-get-quotable-parts (parts)\r
+ (loop for part in parts\r
+ if (notmuch-match-content-type (plist-get part :content-type) "multipart/alternative")\r
+@@ -224,7 +233,10 @@ list."\r
+ (set-mark (point))\r
+ (goto-char start)\r
+ ;; Quote the original message according to the user's configured style.\r
+- (message-cite-original))))\r
++ (message-cite-original)))\r
++\r
++ ;; Sign and/or encrypt replies to signed and/or encrypted messages.\r
++ (notmuch-mua-reply-crypto (plist-get original :body)))\r
+ \r
+ ;; Push mark right before signature, if any.\r
+ (message-goto-signature)\r
+-- \r
+1.9.1\r
+\r