]> granicus.if.org Git - neomutt/commitdiff
move ctx->tagged to mailbox->msg_tagged
authorMehdi Abaakouk <sileht@sileht.net>
Tue, 20 Nov 2018 22:58:03 +0000 (23:58 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 21 Nov 2018 11:19:30 +0000 (11:19 +0000)
context.h
flags.c
index.c
mailbox.h
mbox/mbox.c
mx.c
nntp/nntp.c
send.c
sidebar.c
status.c

index f5184a40330498f16cdda28356b4a14cb528bc5e..d1a2778376e4733343ff467ed48af8b4d1be7cda 100644 (file)
--- a/context.h
+++ b/context.h
@@ -41,7 +41,6 @@ struct Context
   struct Email *last_tag;  /**< last tagged msg. used to link threads */
   struct MuttThread *tree;  /**< top of thread tree */
   struct Hash *thread_hash; /**< hash table for threading */
-  int tagged;               /**< how many messages are tagged? */
   int msgnotreadyet;        /**< which msg "new" in pager, -1 if none */
 
   struct Menu *menu; /**< needed for pattern compilation */
diff --git a/flags.c b/flags.c
index 8de9a95c7b6d647ccd1977a8c0793a1becb29f52..ec2b81dff9f0ce3520f3aaa794003201acefe946 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -62,7 +62,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool b
 
   bool changed = e->changed;
   int deleted = m->msg_deleted;
-  int tagged = ctx->tagged;
+  int tagged = m->msg_tagged;
   int flagged = m->msg_flagged;
   int update = false;
 
@@ -317,7 +317,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool b
           update = true;
           e->tagged = true;
           if (upd_ctx)
-            ctx->tagged++;
+            m->msg_tagged++;
         }
       }
       else if (e->tagged)
@@ -325,7 +325,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool b
         update = true;
         e->tagged = false;
         if (upd_ctx)
-          ctx->tagged--;
+          m->msg_tagged--;
       }
       break;
   }
@@ -343,7 +343,7 @@ void mutt_set_flag_update(struct Context *ctx, struct Email *e, int flag, bool b
    * of this message and not what it was at the time it was last searched.
    */
   if (e->searched && (changed != e->changed || deleted != m->msg_deleted ||
-                      tagged != ctx->tagged || flagged != m->msg_flagged))
+                      tagged != m->msg_tagged || flagged != m->msg_flagged))
   {
     e->searched = false;
   }
diff --git a/index.c b/index.c
index 8fe11e412f02fc73a2d283967ac7ca9b89258bc6..5ca93fbb1c4ead4b7e0abf4bc6e6455801813a5d 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1197,13 +1197,13 @@ int mutt_index_menu(void)
           continue;
         }
 
-        if (!Context)
+        if (!Context || !Context->mailbox)
         {
           mutt_error(_("No mailbox is open"));
           continue;
         }
 
-        if (!Context->tagged)
+        if (!Context->mailbox->msg_tagged)
         {
           if (op == OP_TAG_PREFIX)
             mutt_error(_("No tagged messages"));
@@ -1219,7 +1219,7 @@ int mutt_index_menu(void)
         tag = true;
         continue;
       }
-      else if (AutoTag && Context && Context->tagged)
+      else if (AutoTag && Context && Context->mailbox && Context->mailbox->msg_tagged)
         tag = true;
 
       mutt_clear_error();
@@ -1991,7 +1991,7 @@ int mutt_index_menu(void)
           {
             char msgbuf[STRING];
             snprintf(msgbuf, sizeof(msgbuf), _("Update tags..."));
-            mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, 1, Context->tagged);
+            mutt_progress_init(&progress, msgbuf, MUTT_PROGRESS_MSG, 1, Context->mailbox->msg_tagged);
           }
 
 #ifdef USE_NOTMUCH
index 502dfea31fd28269c4191f2433d8f1642c51500b..8ee48209250f309a47756da6d98522e8b4e45dfd 100644 (file)
--- a/mailbox.h
+++ b/mailbox.h
@@ -89,6 +89,7 @@ struct Mailbox
   int msg_flagged;           /**< number of flagged messages */
   int msg_new;               /**< number of new messages */
   int msg_deleted;           /**< number of deleted messages */
+  int msg_tagged;            /**< how many messages are tagged? */
 
   struct Email **hdrs;
   int hdrmax;               /**< number of pointers in hdrs */
index 28cade859603fea5b67a81760da751591b10e7d3..0638c7ffa9b555d6575ebdb688eb3070d7fc5fe1 100644 (file)
@@ -626,7 +626,7 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint)
   m->msg_count = 0;
   m->vcount = 0;
   ctx->vsize = 0;
-  ctx->tagged = 0;
+  m->msg_tagged = 0;
   m->msg_deleted = 0;
   m->msg_new = 0;
   m->msg_unread = 0;
diff --git a/mx.c b/mx.c
index eeff7db6e4964825dcb278de4a260c6c3c40bc06..2cdbff0a6cbc66ab485921b0d73f7168ea30f5ec 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -824,7 +824,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
   /* update memory to reflect the new state of the mailbox */
   m->vcount = 0;
   ctx->vsize = 0;
-  ctx->tagged = 0;
+  m->msg_tagged = 0;
   m->msg_deleted = 0;
   m->msg_new = 0;
   m->msg_unread = 0;
@@ -863,7 +863,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
       }
 
       if (m->hdrs[j]->tagged)
-        ctx->tagged++;
+        m->msg_tagged++;
       if (m->hdrs[j]->flagged)
         m->msg_flagged++;
       if (!m->hdrs[j]->read)
index 1e4bbb1ae1e814e4e939743ab04a4fa4d363b342..71ba7bc5c6c22b86ec2ec7db9922751994bc7366 100644 (file)
@@ -1565,7 +1565,7 @@ static int check_mailbox(struct Context *ctx)
     for (int i = 0; i < m->msg_count; i++)
       mutt_email_free(&m->hdrs[i]);
     m->msg_count = 0;
-    ctx->tagged = 0;
+    m->msg_tagged = 0;
 
     if (mdata->last_message < mdata->last_loaded)
     {
diff --git a/send.c b/send.c
index bf8c72ae1b709b211bc750e5153eb0f69242f157..75445ff8d2f5e89a1b563c76604738c8f54256b8 100644 (file)
--- a/send.c
+++ b/send.c
@@ -906,7 +906,7 @@ void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv
 static void make_reference_headers(struct Envelope *curenv,
                                    struct Envelope *env, struct Context *ctx)
 {
-  if (!env || !ctx)
+  if (!env || !ctx || !ctx->mailbox)
     return;
 
   if (!curenv)
@@ -923,7 +923,7 @@ static void make_reference_headers(struct Envelope *curenv,
   /* if there's more than entry in In-Reply-To (i.e. message has
      multiple parents), don't generate a References: header as it's
      discouraged by RFC2822, sect. 3.6.4 */
-  if (ctx->tagged > 0 && !STAILQ_EMPTY(&env->in_reply_to) &&
+  if (ctx->mailbox->msg_tagged > 0 && !STAILQ_EMPTY(&env->in_reply_to) &&
       STAILQ_NEXT(STAILQ_FIRST(&env->in_reply_to), entries))
   {
     mutt_list_free(&env->references);
@@ -2416,7 +2416,8 @@ int ci_send_message(int flags, struct Email *msg, char *tempfile,
   {
     if (cur && ctx)
       mutt_set_flag(ctx, cur, MUTT_REPLIED, is_reply(cur, msg));
-    else if (!(flags & SEND_POSTPONED) && ctx && ctx->tagged)
+    else if (!(flags & SEND_POSTPONED) && ctx && ctx->mailbox &&
+             ctx->mailbox->msg_tagged)
     {
       for (i = 0; i < ctx->mailbox->msg_count; i++)
       {
index 5f9357caeb2d9a5be656776f4cbcfc2ea05cf46d..ccf64b9081f6f198a39a167c1c0c2c4a4f9da295 100644 (file)
--- a/sidebar.c
+++ b/sidebar.c
@@ -209,9 +209,9 @@ static const char *sidebar_format_str(char *buf, size_t buflen, size_t col, int
       if (!optional)
       {
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
-        snprintf(buf, buflen, fmt, c ? Context->tagged : 0);
+        snprintf(buf, buflen, fmt, c ? Context->mailbox->msg_tagged : 0);
       }
-      else if ((c && Context->tagged == 0) || !c)
+      else if ((c && Context->mailbox->msg_tagged == 0) || !c)
         optional = 0;
       break;
 
index 318b555e1b5fc45f8db4098a9a5c7f3f22d1afef..436120d7ed7b1ecee9be898d72df214658917190 100644 (file)
--- a/status.c
+++ b/status.c
@@ -324,9 +324,9 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c
       if (!optional)
       {
         snprintf(fmt, sizeof(fmt), "%%%sd", prec);
-        snprintf(buf, buflen, fmt, Context ? Context->tagged : 0);
+        snprintf(buf, buflen, fmt, Context ? Context->mailbox->msg_tagged : 0);
       }
-      else if (!Context || !Context->tagged)
+      else if (!Context || !Context->mailbox || !Context->mailbox->msg_tagged)
         optional = 0;
       break;