Rocco Rutte:
[apps/madmutt.git] / curs_main.c
index 4811ba4..39973fa 100644 (file)
@@ -61,9 +61,16 @@ static const char *Function_not_permitted_in_attach_message_mode =
 N_("Function not permitted in attach-message mode.");
 static const char *No_visible = N_("No visible messages.");
 
+#define CHECK_IN_MAILBOX if (!Context) \
+        { \
+                mutt_flushinp (); \
+                mutt_error (_(No_mailbox_is_open)); \
+                break; \
+        }
+
 #define CHECK_MSGCOUNT if (!Context) \
         { \
-                  mutt_flushinp (); \
+                mutt_flushinp (); \
                 mutt_error(_(No_mailbox_is_open)); \
                 break; \
         } \
@@ -269,19 +276,16 @@ static void update_index (MUTTMENU * menu, CONTEXT * ctx, int check,
    * they will be visible in the limited view */
   if (Context->pattern) {
 #define THIS_BODY Context->hdrs[j]->content
-    if (oldcount || check == M_REOPENED) {
-      for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount;
-           j++) {
-        if (mutt_pattern_exec
-            (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
-             Context->hdrs[j])) {
-          Context->hdrs[j]->virtual = Context->vcount;
-          Context->v2r[Context->vcount] = j;
-          Context->hdrs[j]->limited = 1;
-          Context->vcount++;
-          Context->vsize +=
-            THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
-        }
+    for (j = (check == M_REOPENED) ? 0 : oldcount; j < Context->msgcount; j++) {
+      if (mutt_pattern_exec
+          (Context->limit_pattern, M_MATCH_FULL_ADDRESS, Context,
+            Context->hdrs[j])) {
+        Context->hdrs[j]->virtual = Context->vcount;
+        Context->v2r[Context->vcount] = j;
+        Context->hdrs[j]->limited = 1;
+        Context->vcount++;
+        Context->vsize +=
+          THIS_BODY->length + THIS_BODY->offset - THIS_BODY->hdr_offset;
       }
     }
 #undef THIS_BODY
@@ -922,7 +926,7 @@ int mutt_index_menu (void)
       break;
 
     case OP_MAIN_SHOW_LIMIT:
-      CHECK_MSGCOUNT;
+      CHECK_IN_MAILBOX;
       if (!Context->pattern)
         mutt_message (_("No limit pattern is in effect."));
 
@@ -938,7 +942,7 @@ int mutt_index_menu (void)
     case OP_MAIN_LIMIT:
     case OP_TOGGLE_READ:
 
-      CHECK_MSGCOUNT;
+      CHECK_IN_MAILBOX;
       menu->oldcurrent = (Context->vcount && menu->current >= 0
                           && menu->current <
                           Context->vcount) ? CURHDR->index : -1;
@@ -977,7 +981,7 @@ int mutt_index_menu (void)
         else
           menu->current = 0;
         menu->redraw = REDRAW_INDEX | REDRAW_STATUS;
-        if ((Sort & SORT_MASK) == SORT_THREADS)
+        if (Context->msgcount && (Sort & SORT_MASK) == SORT_THREADS)
           mutt_draw_tree (Context);
         menu->redraw = REDRAW_FULL;
       }
@@ -1699,7 +1703,7 @@ int mutt_index_menu (void)
 
     case OP_TOGGLE_WRITE:
 
-      CHECK_MSGCOUNT;
+      CHECK_IN_MAILBOX;
       if (mx_toggle_write (Context) == 0)
         menu->redraw |= REDRAW_STATUS;
       break;