Bug 136878 - [patch] [mail/mutt-devel] Add new parent/child match knob
Summary: [patch] [mail/mutt-devel] Add new parent/child match knob
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-18 01:00 UTC by Jeremie Le Hen
Modified: 2009-11-11 11:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremie Le Hen 2009-07-18 01:00:16 UTC
	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 <command>reset</command> comman
 which allows you to reset all variables to their system defaults.
 </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 &lt; or one of its childs with &gt;.
+This example matches all mails which have at least an unread duplicate
+message:
+</para>
+
+<para>
+
+<screen>
+>(~= ~N)
+</screen>
+
+</para>
+
 </sect2>
 
 <sect2 id="set-myvar">
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 ---
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2009-07-18 01:00:26 UTC
Maintainer of mail/mutt-devel,

Please note that PR ports/136878 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/136878

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2009-07-18 01:00:29 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 3 Philip M. Gollucci freebsd_committer freebsd_triage 2009-07-18 05:00:58 UTC
Responsible Changed
From-To: freebsd-ports-bugs->pgollucci

I'll take it.
Comment 4 Pav Lucistnik freebsd_committer freebsd_triage 2009-09-17 13:45:54 UTC
State Changed
From-To: feedback->open

Maintainer timeout
Comment 5 Udo.Schweigert 2009-09-23 09:40:41 UTC
Please commit the patch below, it additonally adds a new knob
"WITH_TOKYOCABINET"

Cheers

Udo (maintainer)

diff -ru  /usr/ports/mail/mutt-devel/Makefile ./Makefile
--- /usr/ports/mail/mutt-devel/Makefile	2009-07-16 06:09:53.000000000 +0200
+++ ./Makefile	2009-09-22 13:26:16.000000000 +0200
@@ -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 @@
 	@${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
@@ -475,7 +483,11 @@
 SCRIPTS_ENV+=	MUTT_QUOTE_PATCH="yes"
 .endif
 .if defined(WITH_MUTT_IMAP_HEADER_CACHE)
+.if defined(WITH_TOKYOCABINET)
+CONFIGURE_ARGS+=	--enable-hcache --without-gdbm --without-bdb --with-tokyocabinet
+.else
 CONFIGURE_ARGS+=	--enable-hcache --without-gdbm --with-bdb
+.endif
 .else
 CONFIGURE_ARGS+=	--disable-hcache
 .endif
diff -ru  /usr/ports/mail/mutt-devel/files/extra-patch-parent-child-match ./files/extra-patch-parent-child-match
--- /usr/ports/mail/mutt-devel/files/extra-patch-parent-child-match	1970-01-01 01:00:00.000000000 +0100
+++ ./files/extra-patch-parent-child-match	2009-09-22 13:30:22.000000000 +0200
@@ -0,0 +1,169 @@
+--- 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 <command>reset</command> comman
+ which allows you to reset all variables to their system defaults.
+ </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 &lt; or one of its childs with &gt;.
++This example matches all mails which have at least an unread duplicate
++message:
++</para>
++
++<para>
++
++<screen>
++>(~= ~N)
++</screen>
++
++</para>
++
+ </sect2>
+ 
+ <sect2 id="set-myvar">
+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:
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2009-11-10 05:28:42 UTC
Responsible Changed
From-To: pgollucci->freebsd-ports-bugs

With bugmeister hat on, reassign this one to the general pool, since 
there has been no action on the newest patch for the last few weeks.
Comment 7 dfilter service freebsd_committer freebsd_triage 2009-11-11 11:01:05 UTC
miwi        2009-11-11 11:00:51 UTC

  FreeBSD ports repository

  Modified files:
    mail/mutt-devel      Makefile 
  Added files:
    mail/mutt-devel/files extra-patch-parent-child-match 
  Log:
   Add new parent/child and WITH_TOKYOCABINET match knob
  
  PR:             136878
  Submitted by:   Jeremie Le Hen <jeremie@le-hen.org>
  Approved by:    Udo Schweigert (maintainer)
  
  Revision  Changes    Path
  1.305     +13 -1     ports/mail/mutt-devel/Makefile
  1.1       +169 -0    ports/mail/mutt-devel/files/extra-patch-parent-child-match (new)
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 8 Martin Wilke freebsd_committer freebsd_triage 2009-11-11 11:01:12 UTC
State Changed
From-To: open->closed

Committed. Thanks!