From: Ali Polatel <alip@exherbo.org>
To: David Bremner <bremner@unb.ca>
Cc: Ali Polatel <alip@exherbo.org>, notmuch@notmuchmail.org
Subject: [PATCH 1/4] ruby: Add wrapper for notmuch_query_count_messages
Date: Mon, 7 May 2012 18:02:43 +0300 [thread overview]
Message-ID: <9c4448b3a5dc2b62663545ea8579e27a17a3bb99.1336402558.git.alip@exherbo.org> (raw)
In-Reply-To: <cover.1336402558.git.alip@exherbo.org>
In-Reply-To: <cover.1336402558.git.alip@exherbo.org>
---
bindings/ruby/defs.h | 3 +++
bindings/ruby/init.c | 3 ++-
bindings/ruby/query.c | 21 ++++++++++++++++++++-
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index 81f652f..25222a6 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -222,6 +222,9 @@ notmuch_rb_query_search_threads (VALUE self);
VALUE
notmuch_rb_query_search_messages (VALUE self);
+VALUE
+notmuch_rb_query_count_messages (VALUE self);
+
/* threads.c */
VALUE
notmuch_rb_threads_destroy (VALUE self);
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index 4405f19..7ad0ecf 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library
*
- * Copyright © 2010, 2011 Ali Polatel
+ * Copyright © 2010, 2011, 2012 Ali Polatel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -236,6 +236,7 @@ Init_notmuch (void)
rb_define_method (notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0); /* in query.c */
rb_define_method (notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */
rb_define_method (notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */
+ rb_define_method (notmuch_rb_cQuery, "count_messages", notmuch_rb_query_count_messages, 0); /* in query.c */
/*
* Document-class: Notmuch::Threads
diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index 74fd585..02b7819 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -1,6 +1,6 @@
/* The Ruby interface to the notmuch mail library
*
- * Copyright © 2010, 2011 Ali Polatel
+ * Copyright © 2010, 2011, 2012 Ali Polatel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -127,3 +127,22 @@ notmuch_rb_query_search_messages (VALUE self)
return Data_Wrap_Struct (notmuch_rb_cMessages, NULL, NULL, messages);
}
+
+/*
+ * call-seq: QUERY.count_messages => Fixnum
+ *
+ * Return an estimate of the number of messages matching a search
+ */
+VALUE
+notmuch_rb_query_count_messages (VALUE self)
+{
+ notmuch_query_t *query;
+
+ Data_Get_Notmuch_Query (self, query);
+
+ /* Xapian exceptions are not handled properly.
+ * (function may return 0 after printing a message)
+ * Thus there is nothing we can do here...
+ */
+ return UINT2FIX(notmuch_query_count_messages(query));
+}
--
1.7.10.1
next prev parent reply other threads:[~2012-05-07 15:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87txzsgs4g.fsf@zancas.localnet>
2012-05-07 15:02 ` [PATCH 0/4] ruby: quick update before the freeze! Ali Polatel
2012-05-07 15:02 ` Ali Polatel [this message]
2012-05-07 15:02 ` [PATCH 2/4] ruby: Add wrapper for notmuch_query_add_tag_exclude Ali Polatel
2012-05-07 15:02 ` [PATCH 3/4] ruby: Add workarounds to use in-tree build not the installed one Ali Polatel
2012-05-23 22:02 ` Felipe Contreras
2012-05-24 1:22 ` David Bremner
2012-05-24 8:56 ` Felipe Contreras
2012-05-25 13:13 ` Felipe Contreras
2012-05-26 0:38 ` David Bremner
2012-05-07 15:02 ` [PATCH 4/4] ruby: Add wrapper for notmuch_query_set_omit_excluded() Ali Polatel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c4448b3a5dc2b62663545ea8579e27a17a3bb99.1336402558.git.alip@exherbo.org \
--to=alip@exherbo.org \
--cc=bremner@unb.ca \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).