On 2008-12-05 16:28:55 +0100, Vincent Lefevre wrote: > Since 5517:4cc92c30543b, doc/manual.xml.head has: > > pattern with <quote>ˆ</quote>.
Another line was a problem too. Here's a corrected version of the patch. -- Vincent Lefèvre <[EMAIL PROTECTED]> - Web: <http://www.vinc17.org/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/> Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
diff -urp mutt-1.5.18/doc/manual.xml.head mutt-1.5.18-parentchildmatch/doc/manual.xml.head --- mutt-1.5.18/doc/manual.xml.head 2008-05-16 07:50:13.000000000 +0200 +++ mutt-1.5.18-parentchildmatch/doc/manual.xml.head 2008-11-17 17:55:31.000000000 +0100 @@ -3935,11 +3935,12 @@ are allowed, too. <title>Pattern Modifier</title> <para> +<emphasis role="bold">Whole list</emphasis>. Note that patterns matching 'lists' of addresses (notably c, C, p, P and t) match if there is at least one match in the whole list. If you want to make sure that all elements of that list match, you need to prefix your pattern with <quote>ˆ</quote>. -This example matches all mails which only has recipients from Germany. +This example matches all mails which only has recipients from Germany: </para> <para> @@ -3950,6 +3951,22 @@ This example matches all mails which onl </para> +<para> +<emphasis role="bold">Parent and child match</emphasis>. +You can tell mutt that the following pattern has to be matched against +the parent message with < or one of its childs with >. +This example matches all mails which have at least an unread duplicate +message: +</para> + +<para> + +<screen> +>(~= ~N) +</screen> + +</para> + </sect2> <sect2> diff -urp mutt-1.5.18/mutt.h mutt-1.5.18-parentchildmatch/mutt.h --- mutt-1.5.18/mutt.h 2008-01-30 05:26:50.000000000 +0100 +++ mutt-1.5.18-parentchildmatch/mutt.h 2008-11-17 11:10:01.000000000 +0100 @@ -829,6 +829,8 @@ typedef struct pattern_t unsigned int alladdr : 1; unsigned int stringmatch : 1; unsigned int groupmatch : 1; + unsigned int parentmatch : 1; + unsigned int childsmatch : 1; int min; int max; struct pattern_t *next; diff -urp mutt-1.5.18/pattern.c mutt-1.5.18-parentchildmatch/pattern.c --- mutt-1.5.18/pattern.c 2008-01-30 05:26:51.000000000 +0100 +++ mutt-1.5.18-parentchildmatch/pattern.c 2008-11-18 15:51:14.000000000 +0100 @@ -45,6 +45,7 @@ static int eat_regexp (pattern_t *pat, B static int eat_date (pattern_t *pat, BUFFER *, BUFFER *); static int eat_range (pattern_t *pat, BUFFER *, BUFFER *); static int patmatch (const pattern_t *pat, const char *buf); +static int pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h); struct pattern_flags { @@ -780,6 +781,8 @@ pattern_t *mutt_pattern_comp (/* const * pattern_t *last = NULL; int not = 0; int alladdr = 0; + int parentmatch = 0; + int childsmatch = 0; int or = 0; int implicit = 1; /* used to detect logical AND operator */ struct pattern_flags *entry; @@ -804,6 +807,24 @@ pattern_t *mutt_pattern_comp (/* const * ps.dptr++; not = !not; break; + case '<': + ps.dptr++; + if (childsmatch) { + snprintf (err->data, err->dsize, _("cannot use both < and > as a pattern modifier")); + mutt_pattern_free (&curlist); + return NULL; + } + parentmatch = 1; + break; + case '>': + ps.dptr++; + if (parentmatch) { + snprintf (err->data, err->dsize, _("cannot use both < and > as a pattern modifier")); + mutt_pattern_free (&curlist); + return NULL; + } + childsmatch = 1; + break; case '|': if (!or) { @@ -829,6 +850,8 @@ pattern_t *mutt_pattern_comp (/* const * implicit = 0; not = 0; alladdr = 0; + parentmatch = 0; + childsmatch = 0; break; case '%': case '=': @@ -852,8 +875,12 @@ pattern_t *mutt_pattern_comp (/* const * last = tmp; tmp->not ^= not; tmp->alladdr |= alladdr; + tmp->parentmatch |= parentmatch; + tmp->childsmatch |= childsmatch; not = 0; alladdr = 0; + parentmatch = 0; + childsmatch = 0; /* compile the sub-expression */ buf = mutt_substrdup (ps.dptr + 1, p); if ((tmp2 = mutt_pattern_comp (buf, flags, err)) == NULL) @@ -881,10 +908,14 @@ pattern_t *mutt_pattern_comp (/* const * tmp = new_pattern (); tmp->not = not; tmp->alladdr = alladdr; + tmp->parentmatch = parentmatch; + tmp->childsmatch = childsmatch; tmp->stringmatch = (*ps.dptr == '=') ? 1 : 0; tmp->groupmatch = (*ps.dptr == '%') ? 1 : 0; not = 0; alladdr = 0; + parentmatch = 0; + childsmatch = 0; if (last) last->next = tmp; @@ -950,8 +981,12 @@ pattern_t *mutt_pattern_comp (/* const * last = tmp; tmp->not ^= not; tmp->alladdr |= alladdr; + tmp->parentmatch |= parentmatch; + tmp->childsmatch |= childsmatch; not = 0; alladdr = 0; + parentmatch = 0; + childsmatch = 0; ps.dptr = p + 1; /* restore location */ break; default: @@ -1092,6 +1127,36 @@ static int match_threadcomplete(struct p int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h) { + THREAD *t; + + if (pat->parentmatch) { + if (h->thread && h->thread->parent && h->thread->parent->message) + return pattern_exec (pat, flags, ctx, h->thread->parent->message); + else + return pat->not; + } + if (pat->childsmatch) { + if (!h->thread) + return pat->not; + if (!h->thread->child) + return pat->not; + t = h->thread->child; + while (t->prev) + t = t->prev; + for (; t; t = t->next) { + if (!t->message) + continue; + if (pattern_exec (pat, flags, ctx, t->message)) + return !pat->not; + } + return pat->not; + } + return pattern_exec (pat, flags, ctx, h); +} + +static int +pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h) +{ switch (pat->op) { case M_AND: