summaryrefslogtreecommitdiffstats
path: root/pattern.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-12-23 15:57:00 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-12-23 15:57:00 +0000
commit5fa9d8a6db21c71321b4862b8daf644583e10f64 (patch)
treedf69e57e7503b251fb14541042b99d58cb003a38 /pattern.c
parenta4ad9e13292767f63fbb888074ae9eb87aa8cac5 (diff)
A slightly modified version of Vikas' pattern_match patch. This
changes the semantics of the pattern-something functions so they only apply to _visible_ messages. (With the exception of limit: In this case, the user can add another pattern if he wants to limit further, or he can give an entirely new pattern.)
Diffstat (limited to 'pattern.c')
-rw-r--r--pattern.c71
1 files changed, 41 insertions, 30 deletions
diff --git a/pattern.c b/pattern.c
index 18b05056..7f023a42 100644
--- a/pattern.c
+++ b/pattern.c
@@ -934,7 +934,8 @@ int mutt_pattern_func (int op, char *prompt)
BUFFER err;
int i;
- if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN) != 0 || !buf[0])
+ strfcpy (buf, NONULL (Context->pattern), sizeof (buf));
+ if (mutt_get_field (prompt, buf, sizeof (buf), M_PATTERN | M_CLEAR) != 0 || !buf[0])
return (-1);
mutt_message _("Compiling search pattern...");
@@ -953,49 +954,59 @@ int mutt_pattern_func (int op, char *prompt)
mutt_message _("Executing command on matching messages...");
+#define THIS_BODY Context->hdrs[i]->content
+
if (op == M_LIMIT)
{
+ Context->vcount = 0;
+ Context->vsize = 0;
+ Context->collapsed = 0;
+
for (i = 0; i < Context->msgcount; i++)
{
- Context->hdrs[i]->virtual = -1;
- Context->hdrs[i]->limited = 0;
- Context->hdrs[i]->collapsed = 0;
- Context->hdrs[i]->num_hidden = 0;
+ if (mutt_pattern_exec (pat, M_MATCH_FULL_ADDRESS, Context, Context->hdrs[i]))
+ {
+ Context->hdrs[i]->virtual = Context->vcount;
+ Context->hdrs[i]->limited = 1;
+ Context->v2r[Context->vcount] = i;
+ Context->vcount++;
+ Context->vsize+=THIS_BODY->length + THIS_BODY->offset -
+ THIS_BODY->hdr_offset;
+ }
+ else
+ {
+ Context->hdrs[i]->virtual = -1;
+ Context->hdrs[i]->limited = 0;
+ Context->hdrs[i]->collapsed = 0;
+ Context->hdrs[i]->num_hidden = 0;
+ }
}
- Context->vcount = 0;
- Context->vsize = 0;
- Context->collapsed = 0;
}
-
-#define THIS_BODY Context->hdrs[i]->content
-
- for (i = 0; i < Context->msgcount; i++)
- if (mutt_pattern_exec (pat, M_MATCH_FULL_ADDRESS, Context, Context->hdrs[i]))
+ else
+ {
+ for (i = 0; i < Context->vcount; i++)
{
- switch (op)
+ if (mutt_pattern_exec (pat, M_MATCH_FULL_ADDRESS, Context, Context->hdrs[Context->v2r[i]]))
{
- case M_DELETE:
- mutt_set_flag (Context, Context->hdrs[i], M_DELETE, 1);
- break;
- case M_UNDELETE:
- mutt_set_flag (Context, Context->hdrs[i], M_DELETE, 0);
+ switch (op)
+ {
+ case M_DELETE:
+ mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, 1);
break;
- case M_TAG:
- mutt_set_flag (Context, Context->hdrs[i], M_TAG, 1);
+ case M_UNDELETE:
+ mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, 0);
break;
- case M_UNTAG:
- mutt_set_flag (Context, Context->hdrs[i], M_TAG, 0);
+ case M_TAG:
+ mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_TAG, 1);
break;
- case M_LIMIT:
- Context->hdrs[i]->virtual = Context->vcount;
- Context->hdrs[i]->limited = 1;
- Context->v2r[Context->vcount] = i;
- Context->vcount++;
- Context->vsize+=THIS_BODY->length + THIS_BODY->offset -
- THIS_BODY->hdr_offset;
+ case M_UNTAG:
+ mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_TAG, 0);
break;
+ }
}
}
+ }
+
#undef THIS_BODY
mutt_clear_error ();