--- /dev/null
+Return-Path: <igor.contato@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 102026DE021D\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Nov 2015 18:16:54 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.801\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.801 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001,\r
+ SPF_PASS=-0.001] 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 MsVd5ov0_EZP for <notmuch@notmuchmail.org>;\r
+ Wed, 25 Nov 2015 18:16:50 -0800 (PST)\r
+Received: from mail-qg0-f41.google.com (mail-qg0-f41.google.com\r
+ [209.85.192.41])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 49A1E6DE18F2\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Nov 2015 18:16:50 -0800 (PST)\r
+Received: by qgea14 with SMTP id a14so45748138qge.0\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Nov 2015 18:16:49 -0800 (PST)\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:in-reply-to:references;\r
+ bh=/XitwozIVezmpJjXOJchGJm9LBEPzSd28ook1esCBOg=;\r
+ b=T/52MbLPS0TDBoJsJ1sV3QcVOz6B+6EbridfKQYTwfDlNGo3iGH3UM4D9thR7UEDCu\r
+ xwGLzYUEFQ9T5blknpbQNEcVVMYoTuk3/Y3fX8yjYhgJBl3UtjIj/Z8cu/wNK2J0sEKE\r
+ MbHuFgArcgrSGAvx6ICxnLA+ZfiZcnx3B+bXaZpYDIKXRCOCkBOIwBcjCasgcKsn7UuW\r
+ kNkZ5ChD8iL6aMnxxnX+mSrx0NwiIYwgh3u8+zP6jXzeYVxbwxOoLvlpYU0j/2Is5BdR\r
+ sHsFKOOf+3I52rIC4lgsl7217+S7hHqa7FrwGaQcH+eaXxSv4b3zgC9bObWMQ9Ow2S+p\r
+ QkxQ==\r
+X-Received: by 10.140.105.101 with SMTP id b92mr34664504qgf.5.1448504209256;\r
+ Wed, 25 Nov 2015 18:16:49 -0800 (PST)\r
+Received: from arch-laptop.localdomain ([200.195.16.216])\r
+ by smtp.gmail.com with ESMTPSA id h206sm1566011qhc.43.2015.11.25.18.16.47\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\r
+ Wed, 25 Nov 2015 18:16:48 -0800 (PST)\r
+From: Igor Almeida <igor.contato@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH/RFC 1/3] David Bremner's patch for custom maildir flags\r
+Date: Wed, 25 Nov 2015 23:16:29 -0300\r
+Message-Id: <1448504191-30974-2-git-send-email-igor.contato@gmail.com>\r
+X-Mailer: git-send-email 2.5.3\r
+In-Reply-To: <1448504191-30974-1-git-send-email-igor.contato@gmail.com>\r
+References: <1448504191-30974-1-git-send-email-igor.contato@gmail.com>\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, 26 Nov 2015 02:16:54 -0000\r
+\r
+---\r
+ lib/database.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ lib/notmuch.h | 18 +++++++++++++++++\r
+ 2 files changed, 79 insertions(+)\r
+\r
+diff --git a/lib/database.cc b/lib/database.cc\r
+index 3b342f1..592cbcc 100644\r
+--- a/lib/database.cc\r
++++ b/lib/database.cc\r
+@@ -1329,6 +1329,67 @@ notmuch_database_get_version (notmuch_database_t *notmuch)\r
+ return version;\r
+ }\r
+ \r
++notmuch_status_t\r
++notmuch_database_get_maildir_keyword (notmuch_database_t *notmuch,\r
++ int index, const char **tag)\r
++{\r
++ string tag_string;\r
++ const char *key;\r
++ const char *str;\r
++\r
++ if (!notmuch || !tag)\r
++ return NOTMUCH_STATUS_NULL_POINTER;\r
++\r
++ if (index < 0 || index > ('z' - 'a'))\r
++ return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;\r
++\r
++ key = talloc_asprintf(notmuch, "maildir_keyword_%c", 'a' + index);\r
++ if (!key)\r
++ return NOTMUCH_STATUS_OUT_OF_MEMORY;\r
++\r
++ *tag = NULL;\r
++ tag_string = notmuch->xapian_db->get_metadata (key);\r
++ if (tag_string.empty ())\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++\r
++ str = tag_string.c_str ();\r
++ if (str == NULL || *str == '\0')\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++\r
++ *tag = str;\r
++\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
++\r
++notmuch_status_t\r
++notmuch_database_set_maildir_keyword (notmuch_database_t *notmuch,\r
++ int index, const char *tag)\r
++{\r
++ string tag_string;\r
++ const char *key;\r
++ notmuch_status_t ret;\r
++ Xapian::WritableDatabase *db;\r
++\r
++ if (!notmuch || !tag)\r
++ return NOTMUCH_STATUS_NULL_POINTER;\r
++\r
++ ret = _notmuch_database_ensure_writable (notmuch);\r
++ if (ret)\r
++ return ret;\r
++\r
++ if (index < 0 || index > ('z' - 'a'))\r
++ return NOTMUCH_STATUS_UNSUPPORTED_OPERATION;\r
++\r
++ key = talloc_asprintf(notmuch, "maildir_keyword_%c", 'a' + index);\r
++ if (!key)\r
++ return NOTMUCH_STATUS_OUT_OF_MEMORY;\r
++\r
++ db = static_cast <Xapian::WritableDatabase *> (notmuch->xapian_db);\r
++ db->set_metadata (key, tag);\r
++\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
++\r
+ notmuch_bool_t\r
+ notmuch_database_needs_upgrade (notmuch_database_t *notmuch)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index 310a8b8..779a5ea 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -674,6 +674,24 @@ notmuch_tags_t *\r
+ notmuch_database_get_all_tags (notmuch_database_t *db);\r
+ \r
+ /**\r
++ * Return the tag corresponding to a maildir keyword.\r
++ *\r
++ */\r
++notmuch_status_t\r
++notmuch_database_get_maildir_keyword(notmuch_database_t *db,\r
++ int index, const char **tag);\r
++\r
++/**\r
++ * Set the tag corresponding to a maildir keyword.\r
++ *\r
++ * Note that no messages have their tags modified by this call.\r
++ */\r
++\r
++notmuch_status_t\r
++notmuch_database_set_maildir_keyword(notmuch_database_t *db,\r
++ int index, const char *tag);\r
++\r
++/**\r
+ * Create a new query for 'database'.\r
+ *\r
+ * Here, 'database' should be an open database, (see\r
+-- \r
+2.5.3\r
+\r