From ea8ae9bb22b83b141c6403cad45bb822f911994b Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Sun, 23 Sep 2018 09:48:52 +0200 Subject: [PATCH] notmuch: reconstruct thread on-the-fly upon entire-thread and no vfolder Before this change worked only if invoked from a virtual folder. Now works also from regular folders, with the following semantics: - a notmuch search is done on the fly using as query the message-id of the currently selected message - mutt switches to the query result (a vfolder) - is invoked as before, expanding the thread of the original message Closes #1345 --- curs_main.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/curs_main.c b/curs_main.c index f18228e1b..0e1d38b01 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1898,8 +1898,25 @@ int mutt_index_menu(void) { if (!Context || (Context->mailbox->magic != MUTT_NOTMUCH)) { - mutt_message(_("No virtual folder, aborting")); - break; + if (!CURHDR || !CURHDR->env || !CURHDR->env->message_id) + { + mutt_message(_("No virtual folder and no Message-Id, aborting")); + break; + } // no virtual folder, but we have message-id, reconstruct thread on-the-fly + strncpy(buf, "id:", sizeof(buf)); + int msg_id_offset = 0; + if ((CURHDR->env->message_id)[0] == '<') + msg_id_offset = 1; + mutt_str_strcat(buf, sizeof(buf), (CURHDR->env->message_id) + msg_id_offset); + if (buf[strlen(buf) - 1] == '>') + buf[strlen(buf) - 1] = '\0'; + if (!nm_uri_from_query(Context->mailbox, buf, sizeof(buf))) + { + mutt_message(_("Failed to create query, aborting")); + break; + } + else + main_change_folder(menu, op, buf, sizeof(buf), &oldcount, &index_hint); } CHECK_MSGCOUNT; CHECK_VISIBLE; -- 2.50.0