: 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. Index: PATCHES =================================================================== RCS file: /home/roessler/cvs/mutt/PATCHES,v retrieving revision 3.6 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r3.6 PATCHES --- PATCHES 9 Dec 2002 17:44:54 -0000 3.6 +++ PATCHES 30 Jun 2003 01:26:03 -0000 @@ -0,0 +1 @@ +patch-1.5.4.ats.parent_match.1 Index: mutt.h =================================================================== RCS file: /home/roessler/cvs/mutt/mutt.h,v retrieving revision 3.18 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r3.18 mutt.h --- mutt.h 3 May 2003 20:07:40 -0000 3.18 +++ mutt.h 30 Jun 2003 01:26:04 -0000 @@ -728,6 +728,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 3.8 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r3.8 pattern.c --- pattern.c 21 Jan 2003 12:33:41 -0000 3.8 +++ pattern.c 30 Jun 2003 01:26:05 -0000 @@ -702,6 +702,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; @@ -722,6 +723,10 @@ pattern_t *mutt_pattern_comp (/* const * ps.dptr++; alladdr = !alladdr; break; + case '%': + ps.dptr++; + parent = !parent; + break; case '!': ps.dptr++; not = !not; @@ -751,6 +756,7 @@ pattern_t *mutt_pattern_comp (/* const * implicit = 0; not = 0; alladdr = 0; + parent = 0; break; case '~': if (implicit && or) @@ -767,8 +773,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; @@ -834,8 +842,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: @@ -949,13 +959,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 3.24 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r3.24 send.c --- send.c 14 Apr 2003 09:09:53 -0000 3.24 +++ send.c 30 Jun 2003 01:26:07 -0000 @@ -1127,6 +1127,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 = cur->thread; + } + /* 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 3.21 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r3.21 manual.sgml.head --- doc/manual.sgml.head 13 May 2003 12:53:20 -0000 3.21 +++ doc/manual.sgml.head 30 Jun 2003 01:26:10 -0000 @@ -1771,7 +1771,7 @@ instead (\\). Pattern Modifier +Pattern Modifiers

Note that patterns matching 'lists' of addresses (notably c,C,p,P and t) @@ -1783,6 +1783,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