<<< Date Index >>>     <<< Thread Index >>>

[PATCH] Re: limit view to threads with n or more messages



On Mon, Sep 13, 2010 at 10:11:45PM +0200, Oivvio Polite wrote:
I'm trying to find a way to limit the messages index to threads that
contain n or more messages. So far I've found that %E inserts the number
of messages in the current thread index_format. Unfortunately it seems
like mutt does not that whatever is on your index_format into account
when limiting the index.

Might there be an other way of doing it?

No, but it was straightforward to add this feature. Try the attached patch. It adds a ~Z pattern and you can use it with a range.

me
# HG changeset patch
# User Michael Elkins <me@xxxxxxxx>
# Date 1284435058 25200
# Branch HEAD
# Node ID 402965345270d55ec792b3af39efc79f6e2a3925
# Parent  20b2d496349fb8982b6d30ad7d635b5e8a598279
add ~Z pattern to allow matching on the number of messages in a thread

diff --git a/mutt.h b/mutt.h
--- a/mutt.h
+++ b/mutt.h
@@ -229,6 +229,7 @@
   M_PGP_KEY,
   M_XLABEL,
   M_MIMEATTACH,
+  M_THREAD_COUNT,
   
   /* Options for Mailcap lookup */
   M_EDIT,
diff --git a/pattern.c b/pattern.c
--- a/pattern.c
+++ b/pattern.c
@@ -96,6 +96,7 @@
   { 'X', M_MIMEATTACH,         0,              eat_range },
   { 'y', M_XLABEL,             0,              eat_regexp },
   { 'z', M_SIZE,               0,              eat_range },
+  { 'Z', M_THREAD_COUNT,       0,              eat_range },
   { '=', M_DUPLICATED,         0,              NULL },
   { '$', M_UNREFERENCED,       0,              NULL },
   { 0,   0,                    0,              NULL }
@@ -1213,6 +1214,12 @@
       }
     case M_UNREFERENCED:
       return (pat->not ^ (h->thread && !h->thread->child));
+    case M_THREAD_COUNT:
+      {
+       /* match a message if the thread containing it has the specified number 
of messages */
+       int count = mutt_messages_in_thread(ctx, h, 0);
+       return (pat->not ^ (count >= pat->min && (pat->max == M_MAXRANGE || 
count <= pat->max)));
+      }
   }
   mutt_error (_("error: unknown op %d (report this error)."), pat->op);
   return (-1);