This is a quick and dirty hack to utilize notmuch api version 4.
The main problem is the deprecated apis. I believe those apis work
correctly in version 3, so perhaps just changing the api and leaving
the version definitions alone is sufficient. Or I can further
pollute the code with more #ifdef stuff.
I don't know which way to go here. Let me know and I can respin a
proper patch.
Cheers,
Don
---
configure.ac | 2 +-
mutt_notmuch.c | 25 ++++++++++++++++---------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/configure.ac b/configure.ac
index 6e14662..cd9f864 100644
--- a/configure.ac
+++ b/configure.ac
@@ -189,7 +189,7 @@ AC_ARG_ENABLE(notmuch, AC_HELP_STRING([--enable-notmuch], [Enable
NOTMUCH suppor
[[notmuch_database_open("/path", NOTMUCH_DATABASE_MODE_READ_ONLY,
(notmuch_database_t**)NULL);]]
)],
[notmuch_api_3=yes
- AC_DEFINE([NOTMUCH_API_3], 1, [Define to 1 if you have the notmuch api version 3.])
+ AC_DEFINE([NOTMUCH_API_4], 1, [Define to 1 if you have the notmuch api version 3.])
],
[notmuch_api_3=no]
)
diff --git a/mutt_notmuch.c b/mutt_notmuch.c
index 3a25cc1..966037d 100644
--- a/mutt_notmuch.c
+++ b/mutt_notmuch.c
@@ -230,7 +230,7 @@ static void free_ctxdata(struct nm_ctxdata *data)
dprint(1, (debugfile, "nm: freeing context data %p\n", data));
if (data->db)
-#ifdef NOTMUCH_API_3
+#if defined NOTMUCH_API_3 || defined NOTMUCH_API_4
notmuch_database_destroy(data->db);
#else
notmuch_database_close(data->db);
@@ -454,7 +454,7 @@ static notmuch_database_t *do_database_open(const char *filename,
dprint(1, (debugfile, "nm: db open '%s' %s (timeout %d)\n", filename,
writable ? "[WRITE]" : "[READ]", NotmuchOpenTimeout));
do {
-#ifdef NOTMUCH_API_3
+#if defined NOTMUCH_API_3 || defined NOTMUCH_API_4
st = notmuch_database_open(filename,
writable ? NOTMUCH_DATABASE_MODE_READ_WRITE :
NOTMUCH_DATABASE_MODE_READ_ONLY, &db);
@@ -501,7 +501,8 @@ static int release_db(struct nm_ctxdata *data)
{
if (data && data->db) {
dprint(1, (debugfile, "nm: db close\n"));
-#ifdef NOTMUCH_API_3
+#if defined NOTMUCH_API_3 || defined NOTMUCH_API_4
+
notmuch_database_destroy(data->db);
#else
notmuch_database_close(data->db);
@@ -930,10 +931,13 @@ static void nm_progress_update(CONTEXT *ctx, notmuch_query_t *q)
if (!data->progress_ready && q) {
static char msg[STRING];
+ unsigned int count;
+
snprintf(msg, sizeof(msg), _("Reading messages..."));
+ notmuch_query_count_messages_st(q, &count);
mutt_progress_init(&data->progress, msg, M_PROGRESS_MSG,
- ReadInc, notmuch_query_count_messages(q));
+ ReadInc, count);
data->progress_ready = 1;
}
@@ -1082,7 +1086,8 @@ static void read_mesgs_query(CONTEXT *ctx, notmuch_query_t *q, int
dedup)
limit = get_limit(data);
- for (msgs = notmuch_query_search_messages(q);
+ notmuch_query_search_messages_st(q, &msgs);
+ for (;
notmuch_messages_valid(msgs) &&
(limit == 0 || ctx->msgcount < limit);
notmuch_messages_move_to_next(msgs)) {
@@ -1101,7 +1106,8 @@ static void read_threads_query(CONTEXT *ctx, notmuch_query_t *q, int
dedup, int
if (!data)
return;
- for (threads = notmuch_query_search_threads(q);
+ notmuch_query_search_threads_st(q, &threads);
+ for (;
notmuch_threads_valid(threads) &&
(limit == 0 || ctx->msgcount < limit);
notmuch_threads_move_to_next(threads)) {
@@ -1605,7 +1611,7 @@ static unsigned count_query(notmuch_database_t *db, const char
*qstr)
if (q) {
apply_exclude_tags(q);
- res = notmuch_query_count_messages(q);
+ notmuch_query_count_messages_st(q, &res);
notmuch_query_destroy(q);
dprint(1, (debugfile, "nm: count '%s', result=%d\n", qstr, res));
}
@@ -1672,7 +1678,7 @@ int nm_nonctx_get_count(char *path, int *all, int *new)
rc = 0;
done:
if (db) {
-#ifdef NOTMUCH_API_3
+#if defined NOTMUCH_API_3 || defined NOTMUCH_API_4
notmuch_database_destroy(db);
#else
notmuch_database_close(db);
@@ -1779,7 +1785,8 @@ int nm_check_database(CONTEXT *ctx, int *index_hint)
limit = get_limit(data);
- for (i = 0, msgs = notmuch_query_search_messages(q);
+ notmuch_query_search_messages_st(q, &msgs);
+ for (i = 0;
notmuch_messages_valid(msgs) && (limit == 0 || i < limit);
notmuch_messages_move_to_next(msgs), i++) {
--
1.8.4