]> granicus.if.org Git - neomutt/commitdiff
mutt_ev_message: factor out Context
authorRichard Russon <rich@flatcap.org>
Thu, 10 Jan 2019 13:44:17 +0000 (13:44 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 8 Feb 2019 14:34:07 +0000 (14:34 +0000)
editmsg.c
index.c
protos.h

index a9781126a7f6a75bd9923298de8492fe45bb929f..9955fb5fe980b47e1f79d5d99a8c5ecff4f4dd1c 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -244,24 +244,19 @@ bail:
 
 /**
  * mutt_ev_message - Edit or view a message
- * @param ctx    Mailbox Context
- * @param e      Email
+ * @param m      Mailbox
+ * @param el     List of Emails
  * @param action Action to perform, e.g. #EVM_EDIT
  * @retval 1  Message not modified
  * @retval 0  Message edited successfully
  * @retval -1 Error
  */
-int mutt_ev_message(struct Context *ctx, struct Email *e, enum EvMessage action)
+int mutt_ev_message(struct Mailbox *m, struct EmailList *el, enum EvMessage action)
 {
-  if (e)
-    return ev_message(action, ctx->mailbox, e);
-
-  for (int i = 0; i < ctx->mailbox->msg_count; i++)
+  struct EmailNode *en = NULL;
+  STAILQ_FOREACH(en, el, entries)
   {
-    if (!message_is_tagged(ctx, i))
-      continue;
-
-    if (ev_message(action, ctx->mailbox, ctx->mailbox->emails[i]) == -1)
+    if (ev_message(action, m, en->email) == -1)
       return -1;
   }
 
diff --git a/index.c b/index.c
index 3865ef30b87c88ac512ad1548acac9ac6b9941ac..20cf45d649d49d1e4d8e17862712a8a00fc96985 100644 (file)
--- a/index.c
+++ b/index.c
@@ -3051,7 +3051,7 @@ int mutt_index_menu(void)
       case OP_EDIT_OR_VIEW_RAW_MESSAGE:
       case OP_EDIT_RAW_MESSAGE:
       case OP_VIEW_RAW_MESSAGE:
-
+      {
         /* TODO split this into 3 cases? */
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
@@ -3074,10 +3074,14 @@ int mutt_index_menu(void)
         {
           mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
         }
-        mutt_ev_message(Context, tag ? NULL : CUR_EMAIL, edit ? EVM_EDIT : EVM_VIEW);
+        struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+        el_add_tagged(&el, Context, CUR_EMAIL, tag);
+        mutt_ev_message(Context->mailbox, &el, edit ? EVM_EDIT : EVM_VIEW);
+        el_free(&el);
         menu->redraw = REDRAW_FULL;
 
         break;
+      }
 
       case OP_FORWARD_MESSAGE:
 
index 69ae8e0533ed537edd15d78e55307c0a6d5e9812..b206b4a275799e0ecf6311aae98568197ec1e6d3 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -34,6 +34,7 @@ struct Context;
 struct EnterState;
 struct Envelope;
 struct Email;
+struct EmailList;
 struct Mailbox;
 
 /**
@@ -54,7 +55,7 @@ enum EvMessage
   EVM_EDIT, ///< Edit the message
 };
 
-int mutt_ev_message(struct Context *ctx, struct Email *e, enum EvMessage action);
+int mutt_ev_message(struct Mailbox *m, struct EmailList *el, enum EvMessage action);
 
 int mutt_system(const char *cmd);