From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Jul 18 00:00:18 2009 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1747106567A for ; Sat, 18 Jul 2009 00:00:18 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1A4278FC13 for ; Sat, 18 Jul 2009 00:00:17 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n6I00G7v039566 for ; Sat, 18 Jul 2009 00:00:16 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n6I00GF9039565; Sat, 18 Jul 2009 00:00:16 GMT (envelope-from gnats) Resent-Date: Sat, 18 Jul 2009 00:00:16 GMT Resent-Message-Id: <200907180000.n6I00GF9039565@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jeremie Le Hen Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74F12106564A for ; Fri, 17 Jul 2009 23:56:42 +0000 (UTC) (envelope-from tataz@obiwan.tataz.chchile.org) Received: from smtpfb2-g21.free.fr (smtpfb2-g21.free.fr [212.27.42.10]) by mx1.freebsd.org (Postfix) with ESMTP id D7F518FC08 for ; Fri, 17 Jul 2009 23:56:40 +0000 (UTC) (envelope-from tataz@obiwan.tataz.chchile.org) Received: from smtp1-g21.free.fr (smtp1-g21.free.fr [212.27.42.1]) by smtpfb2-g21.free.fr (Postfix) with ESMTP id CD91AD19CAA for ; Sat, 18 Jul 2009 01:40:01 +0200 (CEST) Received: from smtp1-g21.free.fr (localhost [127.0.0.1]) by smtp1-g21.free.fr (Postfix) with ESMTP id BF0AC9400CC; Sat, 18 Jul 2009 01:39:55 +0200 (CEST) Received: from endor.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp1-g21.free.fr (Postfix) with ESMTP id CA43C940055; Sat, 18 Jul 2009 01:39:52 +0200 (CEST) Received: from obiwan.tataz.chchile.org (obiwan.tataz.chchile.org [192.168.1.222]) by endor.tataz.chchile.org (Postfix) with ESMTP id 7B49F36313; Fri, 17 Jul 2009 23:39:16 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id 63C7B50835; Sat, 18 Jul 2009 01:39:16 +0200 (CEST) Message-Id: <20090717233916.63C7B50835@obiwan.tataz.chchile.org> Date: Sat, 18 Jul 2009 01:39:16 +0200 (CEST) From: Jeremie Le Hen To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Jeremie Le Hen Subject: ports/136878: [patch] [mail/mutt-devel] Add new parent/child match knob X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jeremie Le Hen List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Jul 2009 00:00:19 -0000 >Number: 136878 >Category: ports >Synopsis: [patch] [mail/mutt-devel] Add new parent/child match knob >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Jul 18 00:00:16 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Jeremie Le Hen >Release: FreeBSD 7-STABLE >Organization: None >Environment: FreeBSD >Description: Provide an optional knob to enable parent/match knob (WITH_MUTT_PARENT_CHILD_MATCH_PATCH). For instance, to match all messages that have read duplicates: >(~N ~=) This patch waits in Mutt's Trac during code slush. It should to be committed in Mutt 1.7 developpement version. http://dev.mutt.org/trac/ticket/3144 --- Makefile.diff begins here --- Index: Makefile =================================================================== RCS file: /space/repos/freebsd-cvsroot/ports/mail/mutt-devel/Makefile,v retrieving revision 1.304 diff -u -p -u -r1.304 Makefile --- Makefile 15 Jul 2009 16:47:41 -0000 1.304 +++ Makefile 17 Jul 2009 23:19:05 -0000 @@ -102,6 +102,9 @@ # If you want to enable the `greeting' option define: # WITH_MUTT_GREETING_PATCH # +# If you want to enable the parent/child match support define: +# WITH_MUTT_PARENT_CHILD_MATCH_PATCH +# # If you want to enable the internal SMTP relay support define: # WITH_MUTT_SMTP # @@ -335,6 +338,11 @@ post-patch:: @${PATCH} ${PATCH_ARGS} < ${PATCHDIR}/extra-patch-reverse_reply .endif +.if defined(WITH_MUTT_PARENT_CHILD_MATCH_PATCH) +post-patch:: + @${PATCH} ${PATCH_ARGS} -p1 < ${PATCHDIR}/extra-patch-parent-child-match +.endif + .if defined(WITHOUT_MUTT_FLOCK) CONFIGURE_ARGS+= --disable-flock .else --- Makefile.diff ends here --- --- extra-patch-parent-child-match begins here --- diff -urNp mutt-1.5.20/doc/manual.xml.head mutt-1.5.20-parentchildmatch/doc/manual.xml.head --- mutt-1.5.20/doc/manual.xml.head 2009-05-30 19:20:08.000000000 +0200 +++ mutt-1.5.20-parentchildmatch/doc/manual.xml.head 2009-07-18 01:09:23.000000000 +0200 @@ -3947,6 +3947,22 @@ With the reset comman which allows you to reset all variables to their system defaults. + +Parent and child match. +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: + + + + + +>(~= ~N) + + + + diff -urNp mutt-1.5.20/mutt.h mutt-1.5.20-parentchildmatch/mutt.h --- mutt-1.5.20/mutt.h 2009-06-13 00:15:42.000000000 +0200 +++ mutt-1.5.20-parentchildmatch/mutt.h 2009-07-18 01:14:21.000000000 +0200 @@ -819,6 +819,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; unsigned int ign_case : 1; /* ignore case for local stringmatch searches */ int min; int max; diff -urNp mutt-1.5.20/pattern.c mutt-1.5.20-parentchildmatch/pattern.c --- mutt-1.5.20/pattern.c 2009-06-03 22:48:31.000000000 +0200 +++ mutt-1.5.20-parentchildmatch/pattern.c 2009-07-18 01:09:23.000000000 +0200 @@ -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); static struct pattern_flags { @@ -769,6 +770,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; @@ -793,6 +796,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) { @@ -818,6 +839,8 @@ pattern_t *mutt_pattern_comp (/* const * implicit = 0; not = 0; alladdr = 0; + parentmatch = 0; + childsmatch = 0; break; case '%': case '=': @@ -841,8 +864,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) @@ -870,10 +897,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; @@ -939,8 +970,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: @@ -1081,6 +1116,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: --- extra-patch-parent-child-match ends here --- >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: