Rocco Rutte:
[apps/madmutt.git] / pattern.c
index ec46dca..a606ab9 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -20,6 +20,7 @@
 #include "mapping.h"
 #include "keymap.h"
 #include "copy.h"
 #include "mapping.h"
 #include "keymap.h"
 #include "copy.h"
+#include "mime.h"
 
 #include "lib/mem.h"
 #include "lib/intl.h"
 
 #include "lib/mem.h"
 #include "lib/intl.h"
@@ -65,6 +66,7 @@ struct pattern_flags {
   'L', M_ADDRESS, 0, eat_regexp}, {
   'l', M_LIST, 0, NULL}, {
   'm', M_MESSAGE, 0, eat_range}, {
   'L', M_ADDRESS, 0, eat_regexp}, {
   'l', M_LIST, 0, NULL}, {
   'm', M_MESSAGE, 0, eat_range}, {
+  'M', M_MULTIPART, 0, NULL}, {
   'n', M_SCORE, 0, eat_range}, {
   'N', M_NEW, 0, NULL}, {
   'O', M_OLD, 0, NULL}, {
   'n', M_SCORE, 0, eat_range}, {
   'N', M_NEW, 0, NULL}, {
   'O', M_OLD, 0, NULL}, {
@@ -78,6 +80,7 @@ struct pattern_flags {
   'T', M_TAG, 0, NULL}, {
   't', M_TO, 0, eat_regexp}, {
   'U', M_UNREAD, 0, NULL}, {
   'T', M_TAG, 0, NULL}, {
   't', M_TO, 0, eat_regexp}, {
   'U', M_UNREAD, 0, NULL}, {
+  'u', M_SUBSCRIBED_LIST, 0, NULL}, {
   'v', M_COLLAPSED, 0, NULL}, {
   'V', M_CRYPT_VERIFIED, 0, NULL},
 #ifdef USE_NNTP
   'v', M_COLLAPSED, 0, NULL}, {
   'V', M_CRYPT_VERIFIED, 0, NULL},
 #ifdef USE_NNTP
@@ -1004,6 +1007,11 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags,
                                      pat->alladdr, 2, h->env->to,
                                      h->env->cc)));
   case M_LIST:
                                      pat->alladdr, 2, h->env->to,
                                      h->env->cc)));
   case M_LIST:
+    return (pat->
+            not ^ (h->env
+                   && mutt_is_list_cc (pat->alladdr, h->env->to,
+                                       h->env->cc)));
+  case M_SUBSCRIBED_LIST:
     return (pat->
             not ^ (h->env
                    && mutt_is_list_recipient (pat->alladdr, h->env->to,
     return (pat->
             not ^ (h->env
                    && mutt_is_list_recipient (pat->alladdr, h->env->to,
@@ -1047,6 +1055,8 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags,
     return (pat->not ^ (h->thread && h->thread->duplicate_thread));
   case M_UNREFERENCED:
     return (pat->not ^ (h->thread && !h->thread->child));
     return (pat->not ^ (h->thread && h->thread->duplicate_thread));
   case M_UNREFERENCED:
     return (pat->not ^ (h->thread && !h->thread->child));
+  case M_MULTIPART:
+    return (pat->not ^ (h->content && h->content->type == TYPEMULTIPART));
   case M_REALNAME:
     /* realname filter:
      * we have a match if
   case M_REALNAME:
     /* realname filter:
      * we have a match if
@@ -1212,22 +1222,16 @@ int mutt_pattern_func (int op, char *prompt)
   mutt_clear_error ();
 
   if (op == M_LIMIT) {
   mutt_clear_error ();
 
   if (op == M_LIMIT) {
+    /* drop previous limit pattern */
     mem_free (&Context->pattern);
     if (Context->limit_pattern)
       mutt_pattern_free (&Context->limit_pattern);
     mem_free (&Context->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.");
       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 (str_ncmp (buf, "~A", 2) != 0) {
+
+    /* record new limit pattern, unless match all */
+    if (str_ncmp (buf, "~A", 2) != 0) {
       Context->pattern = simple;
       simple = NULL;            /* don't clobber it */
       Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err);
       Context->pattern = simple;
       simple = NULL;            /* don't clobber it */
       Context->limit_pattern = mutt_pattern_comp (buf, M_FULL_MSG, &err);