[PATCH 1/4] ruby: Add wrapper for notmuch_query_count_messages
authorAli Polatel <alip@exherbo.org>
Mon, 7 May 2012 15:02:43 +0000 (18:02 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:58 +0000 (09:46 -0800)
61/f31e415f5efc0e31facf8bee572bad8acae676 [new file with mode: 0644]

diff --git a/61/f31e415f5efc0e31facf8bee572bad8acae676 b/61/f31e415f5efc0e31facf8bee572bad8acae676
new file mode 100644 (file)
index 0000000..867b3d6
--- /dev/null
@@ -0,0 +1,152 @@
+Return-Path: <polatel@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 olra.theworths.org (Postfix) with ESMTP id 5F785431FD5\r
+       for <notmuch@notmuchmail.org>; Mon,  7 May 2012 08:03:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
+       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 OcnfDaWL7hww for <notmuch@notmuchmail.org>;\r
+       Mon,  7 May 2012 08:03:19 -0700 (PDT)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ C4019431FD4   for <notmuch@notmuchmail.org>; Mon,  7 May 2012 08:03:18 -0700\r
+ (PDT)\r
+Received: by wgbdt14 with SMTP id dt14so4053259wgb.2\r
+       for <notmuch@notmuchmail.org>; Mon, 07 May 2012 08:03:17 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+       :references:in-reply-to:references:organization:mime-version\r
+       :content-type:content-transfer-encoding;\r
+       bh=GBGUTmsRXL4o36c/DTspGhEa4itUxdnh6Y8rdphuK5g=;\r
+       b=TeLhAm6oCTK9hmhpX1jz4Q8aa2P1PK+EzmROfJp5N8/fDaKNiNo5D8VTQMpJe4rmv1\r
+       ZlYuOvKZP3lel12qWlGKgR+N9iiNtwvophma6trG6l18P32HHvHIg+rBQcIfxPUrPyP8\r
+       8dyQuVcQuOMTCwsgg/bEVzi1WojpofWFTgdP9GXg4QDZs3znIPMiyz4Vj5gtGx/9Zuzw\r
+       wB1QXZh+oT6bCFEx9NyLVix5+/b12ykBl5NovsGgTp4Pz+CLdnEwDi310+CbxVi+APET\r
+       /O94ZBlZtZSUgbBj5IqIZpHQebdj4Z8wgyYNc17S5pK7N8QvexGY5x0jZfMezr4VjEcQ\r
+       lCuQ==\r
+Received: by 10.180.81.166 with SMTP id b6mr36119775wiy.0.1336402997544;\r
+       Mon, 07 May 2012 08:03:17 -0700 (PDT)\r
+Received: from hayalet.ev ([88.234.38.242])\r
+       by mx.google.com with ESMTPS id ff2sm34852610wib.9.2012.05.07.08.03.16\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 07 May 2012 08:03:17 -0700 (PDT)\r
+Sender: Ali Polatel <polatel@gmail.com>\r
+From: Ali Polatel <alip@exherbo.org>\r
+To: David Bremner <bremner@unb.ca>\r
+Subject: [PATCH 1/4] ruby: Add wrapper for notmuch_query_count_messages\r
+Date: Mon,  7 May 2012 18:02:43 +0300\r
+Message-Id:\r
+ <9c4448b3a5dc2b62663545ea8579e27a17a3bb99.1336402558.git.alip@exherbo.org>\r
+X-Mailer: git-send-email 1.7.10.1\r
+In-Reply-To: <cover.1336402558.git.alip@exherbo.org>\r
+References: <87txzsgs4g.fsf@zancas.localnet>\r
+       <cover.1336402558.git.alip@exherbo.org>\r
+In-Reply-To: <cover.1336402558.git.alip@exherbo.org>\r
+References: <cover.1336402558.git.alip@exherbo.org>\r
+Organization: Pink Floyd\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+Cc: Ali Polatel <alip@exherbo.org>, notmuch@notmuchmail.org\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: Mon, 07 May 2012 15:03:20 -0000\r
+\r
+---\r
+ bindings/ruby/defs.h  |    3 +++\r
+ bindings/ruby/init.c  |    3 ++-\r
+ bindings/ruby/query.c |   21 ++++++++++++++++++++-\r
+ 3 files changed, 25 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h\r
+index 81f652f..25222a6 100644\r
+--- a/bindings/ruby/defs.h\r
++++ b/bindings/ruby/defs.h\r
+@@ -222,6 +222,9 @@ notmuch_rb_query_search_threads (VALUE self);\r
+ VALUE\r
+ notmuch_rb_query_search_messages (VALUE self);\r
\r
++VALUE\r
++notmuch_rb_query_count_messages (VALUE self);\r
++\r
+ /* threads.c */\r
+ VALUE\r
+ notmuch_rb_threads_destroy (VALUE self);\r
+diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c\r
+index 4405f19..7ad0ecf 100644\r
+--- a/bindings/ruby/init.c\r
++++ b/bindings/ruby/init.c\r
+@@ -1,6 +1,6 @@\r
+ /* The Ruby interface to the notmuch mail library\r
+  *\r
+- * Copyright © 2010, 2011 Ali Polatel\r
++ * Copyright © 2010, 2011, 2012 Ali Polatel\r
+  *\r
+  * This program is free software: you can redistribute it and/or modify\r
+  * it under the terms of the GNU General Public License as published by\r
+@@ -236,6 +236,7 @@ Init_notmuch (void)\r
+     rb_define_method (notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0); /* in query.c */\r
+     rb_define_method (notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */\r
+     rb_define_method (notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */\r
++    rb_define_method (notmuch_rb_cQuery, "count_messages", notmuch_rb_query_count_messages, 0); /* in query.c */\r
\r
+     /*\r
+      * Document-class: Notmuch::Threads\r
+diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c\r
+index 74fd585..02b7819 100644\r
+--- a/bindings/ruby/query.c\r
++++ b/bindings/ruby/query.c\r
+@@ -1,6 +1,6 @@\r
+ /* The Ruby interface to the notmuch mail library\r
+  *\r
+- * Copyright © 2010, 2011 Ali Polatel\r
++ * Copyright © 2010, 2011, 2012 Ali Polatel\r
+  *\r
+  * This program is free software: you can redistribute it and/or modify\r
+  * it under the terms of the GNU General Public License as published by\r
+@@ -127,3 +127,22 @@ notmuch_rb_query_search_messages (VALUE self)\r
\r
+     return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);\r
+ }\r
++\r
++/*\r
++ * call-seq: QUERY.count_messages => Fixnum\r
++ *\r
++ * Return an estimate of the number of messages matching a search\r
++ */\r
++VALUE\r
++notmuch_rb_query_count_messages (VALUE self)\r
++{\r
++    notmuch_query_t *query;\r
++\r
++    Data_Get_Notmuch_Query (self, query);\r
++\r
++    /* Xapian exceptions are not handled properly.\r
++     * (function may return 0 after printing a message)\r
++     * Thus there is nothing we can do here...\r
++     */\r
++    return UINT2FIX(notmuch_query_count_messages(query));\r
++}\r
+-- \r
+1.7.10.1\r
+\r