]> granicus.if.org Git - neomutt/commitdiff
notmuch: reconstruct thread on-the-fly upon entire-thread and no vfolder 1346/head
authorStefano Zacchiroli <zack@upsilon.cc>
Sun, 23 Sep 2018 07:48:52 +0000 (09:48 +0200)
committerRichard Russon <rich@flatcap.org>
Sun, 7 Oct 2018 15:37:28 +0000 (16:37 +0100)
Before this change <entire-thread> worked only if invoked from a virtual
folder.

Now <entire-thread> 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)

- <entire-thread> is invoked as before, expanding the thread of the original
  message

Closes #1345

curs_main.c

index f18228e1be32f226ea6fba15515d17233d89673f..0e1d38b015e8aefacec8820a5dca0ce0e90016d6 100644 (file)
@@ -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;