X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fruby%2Fquery.c;h=02b7819eb6856e12aa25975dde9d506a15be8d01;hp=74fd58586dc34232fe26b3064d98fc787c42004b;hb=d0000daab3f2b04b6b39210dd219de26fa2c8c13;hpb=4997ec95719a50a1882ec9b84dcb31e7984a3565 diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 74fd5858..02b7819e 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)); +}