--- /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 arlo.cworth.org (Postfix) with ESMTP id E6E976DE0C3A\r
+ for <notmuch@notmuchmail.org>; Fri, 25 Sep 2015 13:49:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.528\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.528 tagged_above=-999 required=5 tests=[AWL=0.192,\r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]\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 Sl77b-x0hywe for <notmuch@notmuchmail.org>;\r
+ Fri, 25 Sep 2015 13:49:19 -0700 (PDT)\r
+Received: from mail-la0-f42.google.com (mail-la0-f42.google.com\r
+ [209.85.215.42])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id B5E316DE0C4A\r
+ for <notmuch@notmuchmail.org>; Fri, 25 Sep 2015 13:49:11 -0700 (PDT)\r
+Received: by lacrr8 with SMTP id rr8so31609443lac.2\r
+ for <notmuch@notmuchmail.org>; Fri, 25 Sep 2015 13:49:09 -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:in-reply-to:references;\r
+ bh=Hcd2BBXwMAtYuvsaAjNHAvemmryBrHYnZB4BlAjuSIE=;\r
+ b=G9WdYX/Yzmb9MY/XWpsgeP8k6lfOKp/dMlvNLNRSbNVgwzmMhqyxvCJK0i/EiRfSvX\r
+ 173RkzeyBG4k+Ua27Bn0ikifPiGq6IEsuiEhuJXCkMotm4F6WMehs+pusmRetBM++IPi\r
+ RnRf/fHt8uafbAO2D7X03jn7r1BHRi5LEaOJwisabNcNKTfvVOizFTZyiV4rnL6Awhb4\r
+ if2nr5ttOZft9UOsC0/Jh0896I/GtVfV9U3p1PbD/7LQs+els7nSpvtBzxcokaXEspwb\r
+ d3zDmjWuj2s5JDE4mYrUzinCbls2XqwK289CyeVgQzHLxjGxU5XmyUYZeehM4Cb3/lXk\r
+ 8FmQ==\r
+X-Gm-Message-State:\r
+ ALoCoQnEGX/B39Bko27qzAynzjieMMJ6qXHirr5YqmLquB37hZM3eZd4PXJfdr3HxL0lu8Pnmspx\r
+X-Received: by 10.25.210.206 with SMTP id j197mr1488122lfg.86.1443214149081;\r
+ Fri, 25 Sep 2015 13:49:09 -0700 (PDT)\r
+Received: from localhost (mobile-access-bcee63-221.dhcp.inet.fi.\r
+ [188.238.99.221])\r
+ by smtp.gmail.com with ESMTPSA id a140sm599484lfb.35.2015.09.25.13.49.08\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 25 Sep 2015 13:49:08 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/3] lib: add interface to delete directory documents\r
+Date: Fri, 25 Sep 2015 23:48:45 +0300\r
+Message-Id:\r
+ <a9303b1bb200dc529b3bdfa35dc8f9f7e603a06f.1443213654.git.jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <cover.1443213654.git.jani@nikula.org>\r
+References: <cover.1443213654.git.jani@nikula.org>\r
+In-Reply-To: <cover.1443213654.git.jani@nikula.org>\r
+References: <cover.1443213654.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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: Fri, 25 Sep 2015 20:49:21 -0000\r
+\r
+As mentioned in\r
+\r
+commit acd66cdec075312944e527febd46382e54d99367\r
+Author: Jani Nikula <jani@nikula.org>\r
+Date: Sat Sep 5 12:35:31 2015 +0300\r
+\r
+ cli: reset db directory mtime upon directory removal\r
+\r
+we don't have an interface to delete directory documents, and they're\r
+left behind. Add the interface.\r
+\r
+XXX: Should this also remove the files under it, or assume that's been\r
+done by the caller? Should this incorporate some or all of the\r
+functionality of _remove_directory() in notmuch-new.c?\r
+---\r
+ lib/directory.cc | 18 ++++++++++++++++++\r
+ lib/notmuch.h | 7 +++++++\r
+ 2 files changed, 25 insertions(+)\r
+\r
+diff --git a/lib/directory.cc b/lib/directory.cc\r
+index b836ea2812c8..f23b71769aef 100644\r
+--- a/lib/directory.cc\r
++++ b/lib/directory.cc\r
+@@ -281,6 +281,24 @@ notmuch_directory_get_child_directories (notmuch_directory_t *directory)\r
+ return child_directories;\r
+ }\r
+ \r
++notmuch_status_t\r
++notmuch_directory_delete (notmuch_directory_t *directory)\r
++{\r
++ notmuch_status_t status;\r
++ Xapian::WritableDatabase *db;\r
++\r
++ status = _notmuch_database_ensure_writable (directory->notmuch);\r
++ if (status)\r
++ return status;\r
++\r
++ db = static_cast <Xapian::WritableDatabase *> (directory->notmuch->xapian_db);\r
++ db->delete_document (directory->document_id);\r
++\r
++ notmuch_directory_destroy (directory);\r
++\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
++\r
+ void\r
+ notmuch_directory_destroy (notmuch_directory_t *directory)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index 87756838d072..1feda4521e4d 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -1720,6 +1720,13 @@ notmuch_filenames_t *\r
+ notmuch_directory_get_child_directories (notmuch_directory_t *directory);\r
+ \r
+ /**\r
++ * Delete directory document from the database, and destroy the\r
++ * notmuch_directory_t object.\r
++ */\r
++notmuch_status_t\r
++notmuch_directory_delete (notmuch_directory_t *directory);\r
++\r
++/**\r
+ * Destroy a notmuch_directory_t object.\r
+ */\r
+ void\r
+-- \r
+2.1.4\r
+\r