]> granicus.if.org Git - neomutt/commitdiff
factor out Context from edit_or_view_one_message()
authorRichard Russon <rich@flatcap.org>
Thu, 22 Nov 2018 13:26:14 +0000 (13:26 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 22 Nov 2018 13:45:24 +0000 (13:45 +0000)
editmsg.c

index fc090f665ab110f51271127aab9e0badcc711ab1..6b9b820ac3f1ae8335f97bdee8616fc7c90200dd 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
  * edit_or_view_one_message - Edit an email or view it in an external editor
  * @param edit true if the message should be editable. If false, changes
  *            to the message (in the editor) will be ignored.
- * @param ctx Context
+ * @param m   Mailbox
  * @param cur Email
  * @retval 1  Message not modified
  * @retval 0  Message edited successfully
  * @retval -1 Error
  */
-static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Email *cur)
+static int edit_or_view_one_message(bool edit, struct Mailbox *m, struct Email *cur)
 {
   char tmp[PATH_MAX];
   char buf[STRING];
@@ -95,8 +95,8 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Email
 
   const int chflags =
       CH_NOLEN |
-      ((ctx->mailbox->magic == MUTT_MBOX || ctx->mailbox->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS);
-  rc = mutt_append_message(tmpctx->mailbox, ctx->mailbox, cur, 0, chflags);
+      ((m->magic == MUTT_MBOX || m->magic == MUTT_MMDF) ? 0 : CH_NOSTATUS);
+  rc = mutt_append_message(tmpctx->mailbox, m, cur, 0, chflags);
   oerrno = errno;
 
   mx_mbox_close(&tmpctx, NULL);
@@ -186,7 +186,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Email
     goto bail;
   }
 
-  tmpctx = mx_mbox_open(ctx->mailbox, NULL, MUTT_APPEND);
+  tmpctx = mx_mbox_open(m, NULL, MUTT_APPEND);
   if (!tmpctx)
   {
     rc = -1;
@@ -272,14 +272,14 @@ bail:
 int edit_or_view_message(bool edit, struct Context *ctx, struct Email *e)
 {
   if (e)
-    return edit_or_view_one_message(edit, ctx, e);
+    return edit_or_view_one_message(edit, ctx->mailbox, e);
 
   for (int i = 0; i < ctx->mailbox->msg_count; i++)
   {
     if (!message_is_tagged(ctx, i))
       continue;
 
-    if (edit_or_view_one_message(edit, ctx, ctx->mailbox->hdrs[i]) == -1)
+    if (edit_or_view_one_message(edit, ctx->mailbox, ctx->mailbox->hdrs[i]) == -1)
       return -1;
   }