From b352b8949af4965e7a82b343322de1f1e736b615 Mon Sep 17 00:00:00 2001 From: Austin Ray Date: Wed, 9 Jan 2019 17:28:08 -0500 Subject: [PATCH] notmuch: remove Context in nm_read_entire_thread() Removed the coupling between `nm_read_entire_thread()` and `struct Context` by replacing it with `struct Mailbox`. `Context` had two uses: `Mailbox` reference source and `ctx_update()`. The introduction of mailbox notification code allows mailbox events to trigger `ctx_update()`, which removes the hard dependency on `Context`. Passing a `Mailbox` reference removes the remaining soft dependency on `Context`. --- index.c | 2 +- notmuch/mutt_notmuch.c | 10 ++++------ notmuch/mutt_notmuch.h | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/index.c b/index.c index 05fa83462..728cf3224 100644 --- a/index.c +++ b/index.c @@ -1947,7 +1947,7 @@ int mutt_index_menu(void) CHECK_MSGCOUNT; CHECK_VISIBLE; int oc = Context->mailbox->msg_count; - if (nm_read_entire_thread(Context, CUR_EMAIL) < 0) + if (nm_read_entire_thread(Context->mailbox, CUR_EMAIL) < 0) { mutt_message(_("Failed to read thread, aborting")); break; diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index 6e204e533..bcb31d3d0 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -1584,18 +1584,16 @@ char *nm_email_get_folder(struct Email *e) /** * nm_read_entire_thread - Get the entire thread of an email - * @param ctx Mailbox + * @param m Mailbox * @param e Email * @retval 0 Success * @retval -1 Failure */ -int nm_read_entire_thread(struct Context *ctx, struct Email *e) +int nm_read_entire_thread(struct Mailbox *m, struct Email *e) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; - struct Mailbox *m = ctx->mailbox; - struct NmMboxData *mdata = nm_mdata_get(m); if (!mdata) return -1; @@ -1632,7 +1630,7 @@ int nm_read_entire_thread(struct Context *ctx, struct Email *e) rc = 0; if (m->msg_count > mdata->oldmsgcount) - ctx_update(ctx); + mutt_mailbox_changed(m, MBN_INVALID); done: if (q) notmuch_query_destroy(q); diff --git a/notmuch/mutt_notmuch.h b/notmuch/mutt_notmuch.h index 01e3cafc7..9c38b8ae4 100644 --- a/notmuch/mutt_notmuch.h +++ b/notmuch/mutt_notmuch.h @@ -38,7 +38,6 @@ #include #include "mx.h" -struct Context; struct Email; struct NmMboxData; @@ -68,7 +67,7 @@ void nm_parse_type_from_query (struct NmMboxData *mdata, char *buf); int nm_path_probe (const char *path, const struct stat *st); void nm_query_window_backward (void); void nm_query_window_forward (void); -int nm_read_entire_thread (struct Context *ctx, struct Email *e); +int nm_read_entire_thread (struct Mailbox *m, struct Email *e); int nm_record_message (struct Mailbox *m, char *path, struct Email *e); int nm_update_filename (struct Mailbox *m, const char *old, const char *new, struct Email *e); char *nm_uri_from_query (struct Mailbox *m, char *buf, size_t buflen); -- 2.40.0