--- /dev/null
+Return-Path: <dkg@fifthhorseman.net>\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 CD5E46DE1601\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:10 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.035\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.035 tagged_above=-999 required=5\r
+ tests=[AWL=-0.035] 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 zkScRCzV1gyZ for <notmuch@notmuchmail.org>;\r
+ Wed, 9 Dec 2015 19:40:09 -0800 (PST)\r
+Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 49A856DE1603\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 19:40:05 -0800 (PST)\r
+Received: from fifthhorseman.net (unknown [38.109.115.130])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 2D023F986\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2015 22:40:04 -0500 (EST)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id B564220DD2; Wed, 9 Dec 2015 22:40:03 -0500 (EST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 5/9] Enable cleartext indexing in python bindings\r
+Date: Wed, 9 Dec 2015 22:39:42 -0500\r
+Message-Id: <1449718786-28000-6-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.6.2\r
+In-Reply-To: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\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: Thu, 10 Dec 2015 03:40:11 -0000\r
+\r
+The python add_message function now includes a try_decrypt flag to\r
+permit indexing the cleartext of the mail where possible.\r
+---\r
+ bindings/python/notmuch/database.py | 22 +++++++++++++++++++---\r
+ 1 file changed, 19 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py\r
+index 5b58e09..8e25a05 100644\r
+--- a/bindings/python/notmuch/database.py\r
++++ b/bindings/python/notmuch/database.py\r
+@@ -388,8 +388,13 @@ class Database(object):\r
+ _add_message.argtypes = [NotmuchDatabaseP, c_char_p,\r
+ POINTER(NotmuchMessageP)]\r
+ _add_message.restype = c_uint\r
+-\r
+- def add_message(self, filename, sync_maildir_flags=False):\r
++ \r
++ _add_message_try_decrypt = nmlib.notmuch_database_add_message_try_decrypt\r
++ _add_message_try_decrypt.argtypes = [NotmuchDatabaseP, c_char_p,\r
++ POINTER(NotmuchMessageP)]\r
++ _add_message_try_decrypt.restype = c_uint\r
++ \r
++ def add_message(self, filename, sync_maildir_flags=False, try_decrypt=False):\r
+ """Adds a new message to the database\r
+ \r
+ :param filename: should be a path relative to the path of the\r
+@@ -410,6 +415,13 @@ class Database(object):\r
+ API. You might want to look into the underlying method\r
+ :meth:`Message.maildir_flags_to_tags`.\r
+ \r
++ :param try_decrypt: If the message hasn't been seen by the\r
++ index before, and it includes any encrypted parts, try to\r
++ index the cleartext if set to `True`. Note that this\r
++ means that the cleartext of the message is effectively\r
++ stored in the database index, so DO NOT SET THIS FLAG\r
++ without considering the security of your index.\r
++\r
+ :returns: On success, we return\r
+ \r
+ 1) a :class:`Message` object that can be used for things\r
+@@ -437,10 +449,14 @@ class Database(object):\r
+ :attr:`STATUS`.READ_ONLY_DATABASE\r
+ Database was opened in read-only mode so no message can\r
+ be added.\r
++\r
+ """\r
+ self._assert_db_is_initialized()\r
+ msg_p = NotmuchMessageP()\r
+- status = self._add_message(self._db, _str(filename), byref(msg_p))\r
++ if (try_decrypt):\r
++ status = self._add_message_try_decrypt(self._db, _str(filename), byref(msg_p))\r
++ else:\r
++ status = self._add_message(self._db, _str(filename), byref(msg_p))\r
+ \r
+ if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:\r
+ raise NotmuchError(status)\r
+-- \r
+2.6.2\r
+\r