--- mutt-1.5.8/PATCHES~ never +++ mutt-1.5.8/PATCHES Tue Feb 22 15:35:14 CST 2005 @@ -1,0 +1 @@ +patch-1.5.8.ats.parent_match.1 diff -Pur mutt-1.5.8-base/doc/manual.sgml.head mutt-1.5.8/doc/manual.sgml.head --- mutt-1.5.8-base/doc/manual.sgml.head Sat Feb 12 13:41:36 2005 +++ mutt-1.5.8/doc/manual.sgml.head Tue Feb 22 15:35:13 2005 @@ -1925,7 +1925,7 @@ Pattern Modifier +Pattern Modifiers

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

diff -Pur mutt-1.5.8-base/mutt.h mutt-1.5.8/mutt.h --- mutt-1.5.8-base/mutt.h Sat Feb 12 14:01:20 2005 +++ mutt-1.5.8/mutt.h Tue Feb 22 15:35:13 2005 @@ -787,6 +787,7 @@ short op; short not; short alladdr; + short parent; int min; int max; struct pattern_t *next; diff -Pur mutt-1.5.8-base/pattern.c mutt-1.5.8/pattern.c --- mutt-1.5.8-base/pattern.c Wed Feb 9 03:07:45 2005 +++ mutt-1.5.8/pattern.c Tue Feb 22 15:35:14 2005 @@ -708,6 +708,7 @@ 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; @@ -728,6 +729,10 @@ ps.dptr++; alladdr = !alladdr; break; + case '%': + ps.dptr++; + parent = !parent; + break; case '!': ps.dptr++; not = !not; @@ -757,6 +762,7 @@ implicit = 0; not = 0; alladdr = 0; + parent = 0; break; case '~': if (implicit && or) @@ -773,8 +779,10 @@ tmp = new_pattern (); tmp->not = not; tmp->alladdr = alladdr; + tmp->parent = parent; not = 0; alladdr=0; + parent=0; if (last) last->next = tmp; @@ -840,8 +848,10 @@ 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: @@ -955,13 +965,24 @@ 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: diff -Pur mutt-1.5.8-base/send.c mutt-1.5.8/send.c --- mutt-1.5.8-base/send.c Thu Feb 3 12:47:53 2005 +++ mutt-1.5.8/send.c Tue Feb 22 15:35:14 2005 @@ -1149,6 +1149,13 @@ } } + /* 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))) {