--- /dev/null
+Return-Path: <meskio@sindominio.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 olra.theworths.org (Postfix) with ESMTP id 164AF431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 05:08:11 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 IjlRJ3L9iplM for <notmuch@notmuchmail.org>;\r
+ Wed, 9 Dec 2009 05:08:10 -0800 (PST)\r
+Received: from flatline.sindominio.net (flatline.sindominio.net [82.144.4.26])\r
+ by olra.theworths.org (Postfix) with ESMTP id 5258D431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 05:08:09 -0800 (PST)\r
+Received: from localhost (localhost.localdomain [127.0.0.1])\r
+ by flatline.sindominio.net (Postfix) with ESMTP id C40E42623EE\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 14:08:07 +0100 (CET)\r
+X-Virus-Scanned: Debian amavisd-new at sindominio.net\r
+Received: from flatline.sindominio.net ([127.0.0.1])\r
+ by localhost (flatline.sindominio.net [127.0.0.1]) (amavisd-new,\r
+ port 10024) with ESMTP id LT45ACUAghL7 for <notmuch@notmuchmail.org>;\r
+ Wed, 9 Dec 2009 14:08:02 +0100 (CET)\r
+Received: from blackspot (rpollan-laptop.cern.ch [137.138.192.228])\r
+ by flatline.sindominio.net (Postfix) with ESMTPA id 024602624E3\r
+ for <notmuch@notmuchmail.org>; Wed, 9 Dec 2009 14:08:02 +0100 (CET)\r
+Received: by blackspot (Postfix, from userid 1000)\r
+ id 061868BBF1; Wed, 9 Dec 2009 14:10:07 +0100 (CET)\r
+From: Ruben Pollan <meskio@sindominio.net>\r
+To: notmuch@notmuchmail.org\r
+Date: Wed, 9 Dec 2009 14:10:06 +0100\r
+Message-Id: <1260364206-344-1-git-send-email-meskio@sindominio.net>\r
+X-Mailer: git-send-email 1.6.5.4\r
+In-Reply-To: <20091126202347.GA16654@blackspot>\r
+References: <20091126202347.GA16654@blackspot>\r
+Subject: [notmuch] [PATCH] Added regress option to tags iterator\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\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: Wed, 09 Dec 2009 13:08:11 -0000\r
+\r
+Added the functions notmuch_tags_regress and notmuch_tags_is_first to\r
+notmuch library. With them is possible to iterate backwards on tags.\r
+\r
+* notmuch_tags_regress do the opposite than notmuch_tags_advance,\r
+ getting the tags iterator one position backwards.\r
+\r
+* notmuch_tags_is_first return TRUE if the iterator is in the first\r
+ tag.\r
+---\r
+ lib/notmuch.h | 8 ++++++++\r
+ lib/tags.c | 19 +++++++++++++++++++\r
+ 2 files changed, 27 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index e28ce46..db051c8 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -917,6 +917,10 @@ notmuch_message_destroy (notmuch_message_t *message);\r
+ notmuch_bool_t\r
+ notmuch_tags_has_more (notmuch_tags_t *tags);\r
+ \r
++/* Is the given notmuch_tags_t object on the first tags */\r
++notmuch_bool_t\r
++notmuch_tags_is_first (notmuch_tags_t *tags);\r
++\r
+ /* Get the current tag from 'tags' as a string.\r
+ *\r
+ * Note: The returned string belongs to 'tags' and has a lifetime\r
+@@ -936,6 +940,10 @@ notmuch_tags_get (notmuch_tags_t *tags);\r
+ void\r
+ notmuch_tags_advance (notmuch_tags_t *tags);\r
+ \r
++/* Regress the 'tags' iterator to the previous result. */\r
++void\r
++notmuch_tags_regress (notmuch_tags_t *tags);\r
++\r
+ /* Destroy a notmuch_tags_t object.\r
+ *\r
+ * It's not strictly necessary to call this function. All memory from\r
+diff --git a/lib/tags.c b/lib/tags.c\r
+index 85507e9..cf9e030 100644\r
+--- a/lib/tags.c\r
++++ b/lib/tags.c\r
+@@ -25,6 +25,7 @@\r
+ struct _notmuch_tags {\r
+ int sorted;\r
+ GList *tags;\r
++ GList *previous_node;\r
+ GList *iterator;\r
+ };\r
+ \r
+@@ -55,6 +56,7 @@ _notmuch_tags_create (void *ctx)\r
+ \r
+ tags->sorted = 1;\r
+ tags->tags = NULL;\r
++ tags->previous_node = NULL;\r
+ tags->iterator = NULL;\r
+ \r
+ return tags;\r
+@@ -94,6 +96,12 @@ notmuch_tags_has_more (notmuch_tags_t *tags)\r
+ return tags->iterator != NULL;\r
+ }\r
+ \r
++notmuch_bool_t\r
++notmuch_tags_is_first (notmuch_tags_t *tags)\r
++{\r
++ return tags->previous_node == NULL;\r
++}\r
++\r
+ const char *\r
+ notmuch_tags_get (notmuch_tags_t *tags)\r
+ {\r
+@@ -109,10 +117,21 @@ notmuch_tags_advance (notmuch_tags_t *tags)\r
+ if (tags->iterator == NULL)\r
+ return;\r
+ \r
++ tags->previous_node = tags->iterator;\r
+ tags->iterator = tags->iterator->next;\r
+ }\r
+ \r
+ void\r
++notmuch_tags_regress (notmuch_tags_t *tags)\r
++{\r
++ if (tags->previous_node == NULL)\r
++ return;\r
++\r
++ tags->iterator = tags->previous_node;\r
++ tags->previous_node = tags->iterator->prev;\r
++}\r
++\r
++void\r
+ notmuch_tags_destroy (notmuch_tags_t *tags)\r
+ {\r
+ talloc_free (tags);\r
+-- \r
+1.6.5.4\r
+\r