: Patch by Aaron Schrab : http://pug.schrab.com/aaron/mutt/ This patch adds the % modifier to mutt's pattern matching capabilities. When this is used, the remainder of that criteria will match against the message's immediate parent (if it's in the current folder). For example, "%~P | ~P" would match messages from you and their immediate replies. --- PATCHES~ Tue Nov 6 19:59:33 2001 +++ PATCHES Tue Nov 6 19:59:42 2001 @@ -1,0 +1 @@ +patch-1.3.24.ats.parent_match.1 Index: mutt.h =================================================================== RCS file: /home/roessler/cvs/mutt/mutt.h,v retrieving revision 2.109 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.109 mutt.h --- mutt.h 2001/12/13 12:10:59 2.109 +++ mutt.h 2001/12/31 07:08:29 @@ -704,6 +704,7 @@ typedef struct pattern_t short op; short not; short alladdr; + short parent; int min; int max; struct pattern_t *next; Index: pattern.c =================================================================== RCS file: /home/roessler/cvs/mutt/pattern.c,v retrieving revision 2.21 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.21 pattern.c --- pattern.c 2001/04/26 13:36:34 2.21 +++ pattern.c 2001/12/31 07:08:30 @@ -715,6 +715,7 @@ pattern_t *mutt_pattern_comp (/* const * pattern_t *last = NULL; int not = 0; int alladdr = 0; + int parent = 0; int or = 0; int implicit = 1; /* used to detect logical AND operator */ struct pattern_flags *entry; @@ -735,6 +736,10 @@ pattern_t *mutt_pattern_comp (/* const * ps.dptr++; alladdr = !alladdr; break; + case '%': + ps.dptr++; + parent = !parent; + break; case '!': ps.dptr++; not = !not; @@ -764,6 +769,7 @@ pattern_t *mutt_pattern_comp (/* const * implicit = 0; not = 0; alladdr = 0; + parent = 0; break; case '~': if (implicit && or) @@ -780,8 +786,10 @@ pattern_t *mutt_pattern_comp (/* const * tmp = new_pattern (); tmp->not = not; tmp->alladdr = alladdr; + tmp->parent = parent; not = 0; alladdr=0; + parent=0; if (last) last->next = tmp; @@ -847,8 +855,10 @@ pattern_t *mutt_pattern_comp (/* const * last = tmp; tmp->not ^= not; tmp->alladdr |= alladdr; + tmp->parent |= parent; not = 0; alladdr = 0; + parent = 0; ps.dptr = p + 1; /* restore location */ break; default: @@ -962,13 +972,24 @@ int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h) { char buf[STRING]; + HEADER *cur_head; + + cur_head = h; + + if (pat->parent) + { + if (h->thread && h->thread->parent && h->thread->parent->message ) + h = h->thread->parent->message; + else + return pat->not; + } switch (pat->op) { case M_AND: - return (pat->not ^ (perform_and (pat->child, flags, ctx, h) > 0)); + return (pat->not ^ (perform_and (pat->child, flags, ctx, cur_head) > 0)); case M_OR: - return (pat->not ^ (perform_or (pat->child, flags, ctx, h) > 0)); + return (pat->not ^ (perform_or (pat->child, flags, ctx, cur_head) > 0)); case M_ALL: return (!pat->not); case M_EXPIRED: Index: send.c =================================================================== RCS file: /home/roessler/cvs/mutt/send.c,v retrieving revision 2.76 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.76 send.c --- send.c 2001/12/28 17:19:00 2.76 +++ send.c 2001/12/31 07:08:31 @@ -1164,6 +1164,13 @@ ci_send_message (int flags, /* send mod } } + /* set parent, for use by % flag in send-hooks */ + if (cur && !(flags & (SENDPOSTPONED|SENDRESEND))) + { + msg->thread = safe_calloc (1, sizeof (THREAD)); + msg->thread->parent = hash_find (ctx->thread_hash, cur->env->message_id); + } + /* this is handled here so that the user can match ~f in send-hook */ if (cur && option (OPTREVNAME) && !(flags & (SENDPOSTPONED|SENDRESEND))) { Index: doc/manual.sgml.head =================================================================== RCS file: /home/roessler/cvs/mutt/doc/manual.sgml.head,v retrieving revision 1.71 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r1.71 manual.sgml.head --- doc/manual.sgml.head 2001/11/06 10:34:04 1.71 +++ doc/manual.sgml.head 2001/12/31 07:08:33 @@ -1727,7 +1727,7 @@ Where EXPR, USER, ID, and SUBJECT are Pattern Modifier +Pattern Modifiers

Note that patterns matching 'lists' of addresses (notably c,C,p,P and t) @@ -1739,6 +1739,10 @@ This example matches all mails which onl ^~C \.de$ + +Normally patterns are compared with the message that is being created. +If you want a pattern to match against a message that you are replying to, +you can prefix the pattern with %. Complex Patterns