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 (); \
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++)
{
- 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]))
{
- 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;
- }
+ 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
break;
case OP_MAIN_SHOW_LIMIT:
- CHECK_MSGCOUNT;
+ CHECK_IN_MAILBOX;
if (!Context->pattern)
mutt_message _("No limit pattern is in effect.");
else
case OP_MAIN_LIMIT:
- CHECK_MSGCOUNT;
+ CHECK_IN_MAILBOX;
menu->oldcurrent = (Context->vcount && menu->current >= 0 && menu->current < Context->vcount) ?
CURHDR->index : -1;
if (mutt_pattern_func (M_LIMIT, _("Limit to messages matching: ")) == 0)
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;
}
case OP_TOGGLE_WRITE:
- CHECK_MSGCOUNT;
+ CHECK_IN_MAILBOX;
if (mx_toggle_write (Context) == 0)
menu->redraw |= REDRAW_STATUS;
break;
if (op == M_LIMIT)
{
+ /* drop previous limit pattern */
FREE (&Context->pattern);
- if (Context->limit_pattern)
+ if (Context->limit_pattern)
mutt_pattern_free (&Context->limit_pattern);
- if (!Context->vcount)
- {
+
+ if (Context->msgcount && !Context->vcount)
mutt_error _("No messages matched criteria.");
-#if 0
- Context->vcount = Context->msgcount;
- /* restore full display */
- for (i = 0; i < Context->msgcount; i++)
- {
- Context->hdrs[i]->virtual = i;
- Context->v2r[i] = i;
- }
-#endif
- }
- else if (mutt_strncmp (buf, "~A", 2) != 0)
+
+ /* record new limit pattern, unless match all */
+ if (mutt_strcmp (buf, "~A") != 0)
{
Context->pattern = simple;
simple = NULL; /* don't clobber it */