From d0000daab3f2b04b6b39210dd219de26fa2c8c13 Mon Sep 17 00:00:00 2001 From: Ali Polatel Date: Mon, 7 May 2012 18:02:43 +0300 Subject: ruby: Add wrapper for notmuch_query_count_messages --- bindings/ruby/defs.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bindings/ruby/defs.h') 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); -- cgit v1.2.3 From 92680f12ebd276952ae51ff271526f4dd995a18a Mon Sep 17 00:00:00 2001 From: Ali Polatel Date: Mon, 7 May 2012 18:02:44 +0300 Subject: ruby: Add wrapper for notmuch_query_add_tag_exclude --- bindings/ruby/defs.h | 3 +++ bindings/ruby/init.c | 1 + bindings/ruby/query.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) (limited to 'bindings/ruby/defs.h') diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 25222a6..a41cf10 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -216,6 +216,9 @@ notmuch_rb_query_set_sort (VALUE self, VALUE sortv); VALUE notmuch_rb_query_get_string (VALUE self); +VALUE +notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv); + VALUE notmuch_rb_query_search_threads (VALUE self); diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index 7ad0ecf..edcf101 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -234,6 +234,7 @@ Init_notmuch (void) rb_define_method (notmuch_rb_cQuery, "sort", notmuch_rb_query_get_sort, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0); /* in query.c */ + rb_define_method (notmuch_rb_cQuery, "add_tag_exclude", notmuch_rb_query_add_tag_exclude, 1); /* 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 */ diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 02b7819..2a80008 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -88,6 +88,24 @@ notmuch_rb_query_get_string (VALUE self) return rb_str_new2 (notmuch_query_get_query_string (query)); } +/* + * call-seq: QUERY.add_tag_exclude(tag) => nil + * + * Add a tag that will be excluded from the query results by default. + */ +VALUE +notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv) +{ + notmuch_query_t *query; + const char *tag; + + Data_Get_Notmuch_Query (self, query); + tag = RSTRING_PTR(tagv); + + notmuch_query_add_tag_exclude(query, tag); + return Qnil; +} + /* * call-seq: QUERY.search_threads => THREADS * -- cgit v1.2.3 From 82b73ffd7380b85d259eeb91100dd6ac2d14223a Mon Sep 17 00:00:00 2001 From: Ali Polatel Date: Mon, 7 May 2012 18:02:45 +0300 Subject: ruby: Add workarounds to use in-tree build not the installed one - Make mkmf use the notmuch.h under ../../lib - Use libnotmuch.a instead of linking to the installed libnotmuch.so --- bindings/ruby/defs.h | 4 ++-- bindings/ruby/extconf.rb | 26 ++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'bindings/ruby/defs.h') diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index a41cf10..6fe5787 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -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 @@ -21,8 +21,8 @@ #ifndef DEFS_H #define DEFS_H -#include #include +#include "notmuch.h" VALUE notmuch_rb_cDatabase; VALUE notmuch_rb_cDirectory; diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb index ccac609..933f34a 100644 --- a/bindings/ruby/extconf.rb +++ b/bindings/ruby/extconf.rb @@ -1,13 +1,31 @@ #!/usr/bin/env ruby # coding: utf-8 -# Copyright 2010, 2011 Ali Polatel +# Copyright 2010, 2011, 2012 Ali Polatel # Distributed under the terms of the GNU General Public License v3 require 'mkmf' -# Notmuch Library -find_header('notmuch.h', '../../lib') -find_library('notmuch', 'notmuch_database_create', '../../lib') +NOTDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')) +NOTHDR = File.join(NOTDIR, 'notmuch.h') +NOTLIB = File.join(NOTDIR, 'libnotmuch.a') + +unless File.exists? NOTHDR + $stderr.puts "notmuch.h is missing under #{NOTDIR}" + exit 1 +end + +unless File.exists? NOTLIB + $stderr.puts "libnotmuch.a is missing under #{NOTDIR}" + exit 1 +end + +# Small hack to build with in-tree version not the installed one. +# find_header() and friends use standard include/library paths first. +$stderr.puts "Added -I#{NOTDIR} to $INCFLAGS" +$INCFLAGS = "-I#{NOTDIR}".quote + " " + $INCFLAGS +find_header('notmuch.h', NOTDIR) + +$LOCAL_LIBS += NOTLIB # Create Makefile dir_config('notmuch') -- cgit v1.2.3 From a8e010962f257aaba0218392542cbfb1d14eddfd Mon Sep 17 00:00:00 2001 From: Ali Polatel Date: Mon, 7 May 2012 18:02:46 +0300 Subject: ruby: Add wrapper for notmuch_query_set_omit_excluded() --- bindings/ruby/defs.h | 3 +++ bindings/ruby/init.c | 7 +++++++ bindings/ruby/query.c | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) (limited to 'bindings/ruby/defs.h') diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 6fe5787..85d8205 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -219,6 +219,9 @@ notmuch_rb_query_get_string (VALUE self); VALUE notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv); +VALUE +notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv); + VALUE notmuch_rb_query_search_threads (VALUE self); diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index edcf101..3fe60fb 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -95,6 +95,12 @@ Init_notmuch (void) * Message flag "match" */ rb_define_const (mod, "MESSAGE_FLAG_MATCH", INT2FIX (NOTMUCH_MESSAGE_FLAG_MATCH)); + /* + * Document-const: Notmuch::MESSAGE_FLAG_EXCLUDED + * + * Message flag "excluded" + */ + rb_define_const (mod, "MESSAGE_FLAG_EXCLUDED", INT2FIX (NOTMUCH_MESSAGE_FLAG_EXCLUDED)); /* * Document-const: Notmuch::TAG_MAX * @@ -235,6 +241,7 @@ Init_notmuch (void) rb_define_method (notmuch_rb_cQuery, "sort=", notmuch_rb_query_set_sort, 1); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "to_s", notmuch_rb_query_get_string, 0); /* in query.c */ rb_define_method (notmuch_rb_cQuery, "add_tag_exclude", notmuch_rb_query_add_tag_exclude, 1); /* in query.c */ + rb_define_method (notmuch_rb_cQuery, "omit_excluded=", notmuch_rb_query_set_omit_excluded, 1); /* 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 */ diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c index 2a80008..e5ba1b7 100644 --- a/bindings/ruby/query.c +++ b/bindings/ruby/query.c @@ -106,6 +106,24 @@ notmuch_rb_query_add_tag_exclude (VALUE self, VALUE tagv) return Qnil; } +/* + * call-seq: QUERY.omit_excluded=(boolean) => nil + * + * Specify whether to omit excluded results or simply flag them. + * By default, this is set to +true+. + */ +VALUE +notmuch_rb_query_set_omit_excluded (VALUE self, VALUE omitv) +{ + notmuch_query_t *query; + + Data_Get_Notmuch_Query (self, query); + + notmuch_query_set_omit_excluded (query, RTEST (omitv)); + + return Qnil; +} + /* * call-seq: QUERY.search_threads => THREADS * -- cgit v1.2.3 From 35cb1c95cc8afa964900d29c813349ad8e24e7a8 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Fri, 25 May 2012 15:08:17 +0200 Subject: Revert "ruby: Add workarounds to use in-tree build not the installed one" This reverts commit 82b73ffd7380b85d259eeb91100dd6ac2d14223a. Only leave the copyright changes. Signed-off-by: Felipe Contreras --- bindings/ruby/defs.h | 2 +- bindings/ruby/extconf.rb | 24 +++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) (limited to 'bindings/ruby/defs.h') diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 85d8205..3f9512b 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -21,8 +21,8 @@ #ifndef DEFS_H #define DEFS_H +#include #include -#include "notmuch.h" VALUE notmuch_rb_cDatabase; VALUE notmuch_rb_cDirectory; diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb index 933f34a..7b9750f 100644 --- a/bindings/ruby/extconf.rb +++ b/bindings/ruby/extconf.rb @@ -5,27 +5,9 @@ require 'mkmf' -NOTDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')) -NOTHDR = File.join(NOTDIR, 'notmuch.h') -NOTLIB = File.join(NOTDIR, 'libnotmuch.a') - -unless File.exists? NOTHDR - $stderr.puts "notmuch.h is missing under #{NOTDIR}" - exit 1 -end - -unless File.exists? NOTLIB - $stderr.puts "libnotmuch.a is missing under #{NOTDIR}" - exit 1 -end - -# Small hack to build with in-tree version not the installed one. -# find_header() and friends use standard include/library paths first. -$stderr.puts "Added -I#{NOTDIR} to $INCFLAGS" -$INCFLAGS = "-I#{NOTDIR}".quote + " " + $INCFLAGS -find_header('notmuch.h', NOTDIR) - -$LOCAL_LIBS += NOTLIB +# Notmuch Library +find_header('notmuch.h', '../../lib') +find_library('notmuch', 'notmuch_database_create', '../../lib') # Create Makefile dir_config('notmuch') -- cgit v1.2.3 From d796dad4edce71c1cfb245ffd2c438f26c84f804 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sun, 24 Jun 2012 21:48:34 +0300 Subject: ruby: extern linkage portability improvement Some C compilers are stricter when it comes to (tentative) definition of a variable -- in those compilers introducing variable without 'extern' keyword always allocates new 'storage' to the variable and linking all these modules fails due to duplicate symbols. This is reimplementation of Charlie Allom's patch: id:"1336481467-66356-1-git-send-email-charlie@mediasp.com", written originally by Ali Polatel. This version has more accurate commit message. --- bindings/ruby/defs.h | 50 +++++++++++++++++++++++++------------------------- bindings/ruby/init.c | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 25 deletions(-) (limited to 'bindings/ruby/defs.h') diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h index 3f9512b..fe81b3f 100644 --- a/bindings/ruby/defs.h +++ b/bindings/ruby/defs.h @@ -24,31 +24,31 @@ #include #include -VALUE notmuch_rb_cDatabase; -VALUE notmuch_rb_cDirectory; -VALUE notmuch_rb_cFileNames; -VALUE notmuch_rb_cQuery; -VALUE notmuch_rb_cThreads; -VALUE notmuch_rb_cThread; -VALUE notmuch_rb_cMessages; -VALUE notmuch_rb_cMessage; -VALUE notmuch_rb_cTags; - -VALUE notmuch_rb_eBaseError; -VALUE notmuch_rb_eDatabaseError; -VALUE notmuch_rb_eMemoryError; -VALUE notmuch_rb_eReadOnlyError; -VALUE notmuch_rb_eXapianError; -VALUE notmuch_rb_eFileError; -VALUE notmuch_rb_eFileNotEmailError; -VALUE notmuch_rb_eNullPointerError; -VALUE notmuch_rb_eTagTooLongError; -VALUE notmuch_rb_eUnbalancedFreezeThawError; -VALUE notmuch_rb_eUnbalancedAtomicError; - -ID ID_call; -ID ID_db_create; -ID ID_db_mode; +extern VALUE notmuch_rb_cDatabase; +extern VALUE notmuch_rb_cDirectory; +extern VALUE notmuch_rb_cFileNames; +extern VALUE notmuch_rb_cQuery; +extern VALUE notmuch_rb_cThreads; +extern VALUE notmuch_rb_cThread; +extern VALUE notmuch_rb_cMessages; +extern VALUE notmuch_rb_cMessage; +extern VALUE notmuch_rb_cTags; + +extern VALUE notmuch_rb_eBaseError; +extern VALUE notmuch_rb_eDatabaseError; +extern VALUE notmuch_rb_eMemoryError; +extern VALUE notmuch_rb_eReadOnlyError; +extern VALUE notmuch_rb_eXapianError; +extern VALUE notmuch_rb_eFileError; +extern VALUE notmuch_rb_eFileNotEmailError; +extern VALUE notmuch_rb_eNullPointerError; +extern VALUE notmuch_rb_eTagTooLongError; +extern VALUE notmuch_rb_eUnbalancedFreezeThawError; +extern VALUE notmuch_rb_eUnbalancedAtomicError; + +extern ID ID_call; +extern ID ID_db_create; +extern ID ID_db_mode; /* RSTRING_PTR() is new in ruby-1.9 */ #if !defined(RSTRING_PTR) diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c index 3fe60fb..f4931d3 100644 --- a/bindings/ruby/init.c +++ b/bindings/ruby/init.c @@ -20,6 +20,32 @@ #include "defs.h" +VALUE notmuch_rb_cDatabase; +VALUE notmuch_rb_cDirectory; +VALUE notmuch_rb_cFileNames; +VALUE notmuch_rb_cQuery; +VALUE notmuch_rb_cThreads; +VALUE notmuch_rb_cThread; +VALUE notmuch_rb_cMessages; +VALUE notmuch_rb_cMessage; +VALUE notmuch_rb_cTags; + +VALUE notmuch_rb_eBaseError; +VALUE notmuch_rb_eDatabaseError; +VALUE notmuch_rb_eMemoryError; +VALUE notmuch_rb_eReadOnlyError; +VALUE notmuch_rb_eXapianError; +VALUE notmuch_rb_eFileError; +VALUE notmuch_rb_eFileNotEmailError; +VALUE notmuch_rb_eNullPointerError; +VALUE notmuch_rb_eTagTooLongError; +VALUE notmuch_rb_eUnbalancedFreezeThawError; +VALUE notmuch_rb_eUnbalancedAtomicError; + +ID ID_call; +ID ID_db_create; +ID ID_db_mode; + /* * Document-module: Notmuch * -- cgit v1.2.3