On Thu, Aug 02, 2001 at 08:39:57AM +0200, Bonhote Andre <[EMAIL PROTECTED]> wrote:
> I am subscribed to some so-called sysadmin lists. Unfortunately, the
> list users don't seem to know much about E-Mail: They just hit Outlurks
> "Reply"-button, erase the subject and start another thread. The result
> is a completely messed-up mailfolder, following threads is just a pain
> in the a. They completely ignore threads, perhaps because they're
> program doesn't use the Message-ID and References fields but the
> subject for threading.
> 
> Can I do something like this in mutt? I don't mind if I need an external
> program to pipe my boxfile through, if it helps.

    Attached is a patch that I use.  If the subject line changes
(besides "RE:", etc.), mutt will not put the message in the same thread,
irregardles of the "In-reply-to" or "References" fields.  Works quite
well for me.  Note that you'll also have to turn on the
subj_breaks_thread option.

-- 
Bob Bell <[EMAIL PROTECTED]>
-------------------------------------------------------------------------
 "UNIX *is* user friendly.
  It's just selective about who its friends are."
   -- Author unknown
diff -ru -x CVS mutt-cvs/commands.c mutt/commands.c
--- mutt-cvs/commands.c Tue Jun  5 03:55:55 2001
+++ mutt/commands.c     Wed Jun 20 12:09:14 2001
@@ -529,6 +529,7 @@
   char buffer[LONG_STRING], errbuf[SHORT_STRING];
   int r;
   int old_strictthreads = option (OPTSTRICTTHREADS);
+  int old_subjnothread  = option (OPTSUBJNOTHREAD);
   int old_sortre       = option (OPTSORTRE);
 
   buffer[0] = 0;
@@ -550,6 +551,7 @@
       mutt_error ("%s", errbuf);
   }
   if (option (OPTSTRICTTHREADS) != old_strictthreads ||
+      option (OPTSUBJNOTHREAD) != old_subjnothread ||
       option (OPTSORTRE) != old_sortre)
     set_option (OPTNEEDRESORT);
 }
diff -ru -x CVS mutt-cvs/init.h mutt/init.h
--- mutt-cvs/init.h     Mon Jun 18 11:56:46 2001
+++ mutt/init.h Wed Jun 20 12:09:14 2001
@@ -2109,6 +2109,16 @@
   ** personal mailbox where you might have several unrelated messages with
   ** the subject ``hi'' which will get grouped together.
   */
+  { "subj_breaks_thread", DT_BOOL, R_RESORT|R_INDEX, OPTSUBJNOTHREAD, 0 },
+  /*
+  ** .pp
+  ** If set, a message that would normally be a member of a thread will
+  ** not be a member of that thread if the subject has changed.  This is
+  ** useful when a message reply updates the ``References'' and/or
+  ** ``In-Reply-To'' fields, but the sender changes the subject line
+  ** with the intent to indicate that the subject of discussion has
+  ** changed.
+  */
   { "suspend",         DT_BOOL, R_NONE, OPTSUSPEND, 1 },
   /*
   ** .pp
diff -ru -x CVS mutt-cvs/mutt.h mutt/mutt.h
--- mutt-cvs/mutt.h     Mon Jun 18 11:56:46 2001
+++ mutt/mutt.h Wed Jun 20 12:09:14 2001
@@ -380,6 +380,7 @@
   OPTSORTRE,
   OPTSTATUSONTOP,
   OPTSTRICTTHREADS,
+  OPTSUBJNOTHREAD,
   OPTSUSPEND,
   OPTTEXTFLOWED,
   OPTTHOROUGHSRC,
@@ -614,6 +615,7 @@
   unsigned int display_subject : 1; /* used for threading */
   unsigned int fake_thread : 1;     /* no ref matched, but subject did */
   unsigned int threaded : 1;        /* message has been threaded */
+  unsigned int subj_broke_thread : 1; /* not with thread due to subject change */
   unsigned int recip_valid : 1;  /* is_recipient is valid */
   unsigned int active : 1;         /* message is not to be removed */
   
diff -ru -x CVS mutt-cvs/thread.c mutt/thread.c
--- mutt-cvs/thread.c   Wed Apr 25 18:08:41 2001
+++ mutt/thread.c       Wed Jun 20 12:09:14 2001
@@ -529,6 +529,7 @@
     ctx->hdrs[i]->child = NULL;
     ctx->hdrs[i]->threaded = 0;
     ctx->hdrs[i]->fake_thread = 0;
+    ctx->hdrs[i]->subj_broke_thread = 0;
   }
   ctx->tree = NULL;
 }
@@ -582,15 +583,37 @@
       CUR->parent = NULL;
       insert_message (&ctx->tree, CUR, usefunc);
     }
-    else if (!CUR->threaded)
+    /* Check if (1) message is not yet threaded, or (2) a change in
+     * subject broke the thread but that option has been turned off,
+     * or (3) if the message is a candidate to break from the thread
+     * and the option is currently set
+     */
+    else if (!CUR->threaded ||
+            (CUR->subj_broke_thread && !option (OPTSUBJNOTHREAD)) ||
+            (!CUR->subj_broke_thread && option (OPTSUBJNOTHREAD) &&
+             CUR->subject_changed && CUR->parent != NULL))
     {
+      if (CUR->threaded)
+      {
+       unlink_message (&CUR->parent->child, CUR);
+       CUR->parent = NULL;
+      }
       if ((tmp = find_reference (CUR, ctx)) != NULL)
       {
-       CUR->parent = tmp;
        if (CUR->env->real_subj && tmp->env->real_subj)
          CUR->subject_changed = mutt_strcmp (tmp->env->real_subj, 
CUR->env->real_subj) ? 1 : 0;
        else
          CUR->subject_changed = (CUR->env->real_subj || tmp->env->real_subj) ? 1 : 0;
+       if (CUR->subject_changed && option (OPTSUBJNOTHREAD))
+       {
+         CUR->subj_broke_thread = 1;
+         tmp = NULL;
+       }
+       else
+       {
+         CUR->subj_broke_thread = 0;
+         CUR->parent = tmp;
+       }
       }
       else
        CUR->subject_changed = 1;

Reply via email to