1 diff -pruN mutt-1.5.5.1-orig/OPS mutt-1.5.5.1/OPS
2 --- mutt-1.5.5.1-orig/OPS Wed Nov 5 10:41:31 2003
3 +++ mutt-1.5.5.1/OPS Tue Nov 11 02:52:33 2003
4 @@ -96,6 +96,7 @@ OP_LAST_ENTRY "move to the last entry"
5 OP_LIST_REPLY "reply to specified mailing list"
6 OP_MACRO "execute a macro"
7 OP_MAIL "compose a new mail message"
8 +OP_MAIN_BREAK_THREAD "break the thread in two"
9 OP_MAIN_CHANGE_FOLDER "open a different folder"
10 OP_MAIN_CHANGE_FOLDER_READONLY "open a different folder in read only mode"
11 OP_MAIN_CLEAR_FLAG "clear a status flag from a message"
12 @@ -105,6 +106,7 @@ OP_MAIN_FETCH_MAIL "retrieve mail from P
13 OP_MAIN_FIRST_MESSAGE "move to the first message"
14 OP_MAIN_LAST_MESSAGE "move to the last message"
15 OP_MAIN_LIMIT "show only messages matching a pattern"
16 +OP_MAIN_LINK_THREADS "link tagged message to the current one"
17 OP_MAIN_NEXT_NEW "jump to the next new message"
18 OP_MAIN_NEXT_NEW_THEN_UNREAD "jump to the next new or unread message"
19 OP_MAIN_NEXT_SUBTHREAD "jump to the next subthread"
20 diff -pruN mutt-1.5.5.1-orig/acconfig.h mutt-1.5.5.1/acconfig.h
21 --- mutt-1.5.5.1-orig/acconfig.h Tue Jan 21 11:50:49 2003
22 +++ mutt-1.5.5.1/acconfig.h Tue Nov 11 02:52:33 2003
24 * all return values other than (size_t)(-1) as equivalent. */
27 +/* Do you want to use the rethreading functions with IMAP
28 + * (--enable-imap-edit-threads) */
29 +#undef IMAP_EDIT_THREADS
31 diff -pruN mutt-1.5.5.1-orig/config.h.in mutt-1.5.5.1/config.h.in
32 --- mutt-1.5.5.1-orig/config.h.in Tue Mar 4 08:50:34 2003
33 +++ mutt-1.5.5.1/config.h.in Tue Nov 11 02:52:33 2003
35 * all return values other than (size_t)(-1) as equivalent. */
38 +/* Do you want to use the rethreading functions with IMAP
39 + * (--enable-imap-edit-threads) */
40 +#undef IMAP_EDIT_THREADS
42 diff -pruN mutt-1.5.5.1-orig/configure mutt-1.5.5.1/configure
43 --- mutt-1.5.5.1-orig/configure Wed Nov 5 21:00:06 2003
44 +++ mutt-1.5.5.1/configure Tue Nov 11 02:52:33 2003
45 @@ -40,6 +40,8 @@ ac_help="$ac_help
47 --with-gss[=PFX] Compile in GSSAPI authentication for IMAP"
49 + --enable-imap-edit-threads Enable editing threads support for IMAP"
51 --with-ssl[=PFX] Compile in SSL support for POP/IMAP"
53 --with-nss[=PFX] Compile in SSL support for POP/IMAP via NSS"
54 @@ -5383,6 +5385,23 @@ if test x$need_gss = xyes; then
61 +# Check whether --enable-imap-edit-threads or --disable-imap-edit-threads was given.
62 +if test "${enable_imap_edit_threads+set}" = set; then
63 + enableval="$enable_imap_edit_threads"
65 + if test "$enableval" = "yes"; then
66 + if test "$need_imap" = "yes"; then
67 + cat >> confdefs.h <<\EOF
68 +#define IMAP_EDIT_THREADS 1
72 + echo "configure: warning: IMAP support for edit_threads is only useful with IMAP support" 1>&2
78 diff -pruN mutt-1.5.5.1-orig/configure.in mutt-1.5.5.1/configure.in
79 --- mutt-1.5.5.1-orig/configure.in Wed Nov 5 21:00:05 2003
80 +++ mutt-1.5.5.1/configure.in Tue Nov 11 02:52:33 2003
81 @@ -559,6 +559,16 @@ AM_CONDITIONAL(USE_GSS, test x$need_gss
83 dnl -- end imap dependencies --
85 +AC_ARG_ENABLE(imap-edit-threads, [ --enable-imap-edit-threads Enable editing threads support for IMAP],
87 + if test "$enableval" = "yes"; then
88 + if test "$need_imap" = "yes"; then
89 + AC_DEFINE(IMAP_EDIT_THREADS)
91 + AC_MSG_WARN([IMAP support for edit_threads is only useful with IMAP support])
95 AC_ARG_WITH(ssl, [ --with-ssl[=PFX] Compile in SSL support for POP/IMAP],
96 [ if test "$with_ssl" != "no"
98 diff -pruN mutt-1.5.5.1-orig/copy.c mutt-1.5.5.1/copy.c
99 --- mutt-1.5.5.1-orig/copy.c Wed Nov 5 10:41:31 2003
100 +++ mutt-1.5.5.1/copy.c Tue Nov 11 02:52:33 2003
101 @@ -95,6 +95,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long
102 (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
103 ascii_strncasecmp ("Lines:", buf, 6) == 0))
105 + if ((flags & CH_UPDATE_REFS) &&
106 + ascii_strncasecmp ("References:", buf, 11) == 0)
108 + if ((flags & CH_UPDATE_IRT) &&
109 + ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
114 @@ -193,6 +199,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long
115 ascii_strncasecmp ("type:", buf + 8, 5) == 0)) ||
116 ascii_strncasecmp ("mime-version:", buf, 13) == 0))
118 + if ((flags & CH_UPDATE_REFS) &&
119 + ascii_strncasecmp ("References:", buf, 11) == 0)
121 + if ((flags & CH_UPDATE_IRT) &&
122 + ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
125 /* Find x -- the array entry where this header is to be saved */
126 if (flags & CH_REORDER)
127 @@ -326,6 +338,8 @@ mutt_copy_hdr (FILE *in, FILE *out, long
128 CH_XMIT ignore Lines: and Content-Length:
129 CH_WEED do header weeding
130 CH_NOQFROM ignore ">From " line
131 + CH_UPDATE_IRT update the In-Reply-To: header
132 + CH_UPDATE_REFS update the References: header
135 string to use if CH_PREFIX is set
136 @@ -335,6 +349,9 @@ int
137 mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
139 char buffer[SHORT_STRING];
141 + flags |= (h->irt_changed ? CH_UPDATE_IRT : 0)
142 + | (h->refs_changed ? CH_UPDATE_REFS : 0);
144 if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
146 @@ -358,7 +375,56 @@ mutt_copy_header (FILE *in, HEADER *h, F
147 if (flags & CH_UPDATE)
149 if ((flags & CH_NOSTATUS) == 0)
150 +#ifdef IMAP_EDIT_THREADS
151 +#define NEW_ENV new_env
156 + if (h->irt_changed && h->NEW_ENV->in_reply_to)
158 + LIST *listp = h->NEW_ENV->in_reply_to;
160 + if (fputs ("In-Reply-To: ", out) == EOF)
163 + for (; listp; listp = listp->next)
164 + if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
167 + if (fputc ('\n', out) == EOF)
171 + if (h->refs_changed && h->NEW_ENV->references)
173 + LIST *listp = h->NEW_ENV->references, *refs = NULL, *t;
175 + if (fputs ("References: ", out) == EOF)
178 + /* Mutt stores references in reverse order, thus we create
179 + * a reordered refs list that we can put in the headers */
180 + for (; listp; listp = listp->next, refs = t)
182 + t = (LIST *)safe_malloc (sizeof (LIST));
183 + t->data = listp->data;
187 + for (; refs; refs = refs->next)
188 + if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
191 + /* clearing refs from memory */
192 + for (t = refs; refs; refs = t->next, t = refs)
193 + safe_free ((void **)&refs);
195 + if (fputc ('\n', out) == EOF)
200 if (h->old || h->read)
202 if (fputs ("Status: ", out) == EOF)
203 diff -pruN mutt-1.5.5.1-orig/curs_main.c mutt-1.5.5.1/curs_main.c
204 --- mutt-1.5.5.1-orig/curs_main.c Wed Nov 5 10:41:31 2003
205 +++ mutt-1.5.5.1/curs_main.c Tue Nov 11 02:52:33 2003
206 @@ -930,6 +930,11 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
209 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
211 + Context->last_tag = CURHDR->tagged ? CURHDR :
212 + ((Context->last_tag == CURHDR && !CURHDR->tagged)
213 + ? NULL : Context->last_tag);
215 menu->redraw = REDRAW_STATUS;
216 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
218 @@ -1162,6 +1167,89 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
224 + case OP_MAIN_BREAK_THREAD:
230 + if ((Sort & SORT_MASK) != SORT_THREADS)
231 + mutt_error _("Threading is not enabled.");
233 +#if defined (USE_IMAP) && ! defined (IMAP_EDIT_THREADS)
234 + else if (Context->magic == M_IMAP)
235 + mutt_error _("Compile Mutt with --enable-imap-edit-threads for break-thread support");
241 + HEADER *oldcur = CURHDR;
243 + mutt_break_thread (CURHDR);
244 + mutt_sort_headers (Context, 1);
245 + menu->current = oldcur->virtual;
248 + Context->changed = 1;
249 + mutt_message _("Thread broken");
251 + if (menu->menu == MENU_PAGER)
253 + op = OP_DISPLAY_MESSAGE;
257 + menu->redraw |= REDRAW_INDEX;
262 + case OP_MAIN_LINK_THREADS:
268 + if ((Sort & SORT_MASK) != SORT_THREADS)
269 + mutt_error _("Threading is not enabled.");
271 +#if defined (USE_IMAP) && ! defined (IMAP_EDIT_THREADS)
272 + else if (Context->magic == M_IMAP)
273 + mutt_error _("Compile Mutt with --enable-imap-edit-threads for link-threads support");
276 + else if (!CURHDR->env->message_id)
277 + mutt_error _("No Message-ID: header available to link thread");
278 + else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
279 + mutt_error _("First, please tag a message to be linked here");
282 + HEADER *oldcur = CURHDR;
284 + if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
287 + mutt_sort_headers (Context, 1);
288 + menu->current = oldcur->virtual;
290 + Context->changed = 1;
291 + mutt_message _("Threads linked");
294 + mutt_error _("No thread linked");
297 + if (menu->menu == MENU_PAGER)
299 + op = OP_DISPLAY_MESSAGE;
303 + menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
308 diff -pruN mutt-1.5.5.1-orig/doc/manual.sgml.head mutt-1.5.5.1/doc/manual.sgml.head
309 --- mutt-1.5.5.1-orig/doc/manual.sgml.head Wed Nov 5 10:41:34 2003
310 +++ mutt-1.5.5.1/doc/manual.sgml.head Tue Nov 11 02:52:33 2003
311 @@ -2170,8 +2170,43 @@ used a threaded news client, this is the
312 with large volume mailing lists easier because you can easily delete
313 uninteresting threads and quickly find topics of value.
315 +<sect1>Editing threads
317 +Mutt has the ability to dynamically restructure threads that are broken
318 +either by misconfigured software or bad behaviour from some
319 +correspondents. This allows to clean your mailboxes formats) from these
320 +annoyances which make it hard to follow a discussion.
322 +If you want to use these functions with IMAP, you need to compile Mutt
323 +with the <em/--enable-imap-edit-threads/ configure flag.
325 +<sect2>Linking threads
328 +Some mailers tend to "forget" to correctly set the "In-Reply-To:" and
329 +"References:" headers when replying to a message. This results in broken
330 +discussions because Mutt has not enough information to guess the correct
332 +You can fix this by tagging the reply, then moving to the parent message
333 +and using the ``link-threads'' function (bound to & by default). The
334 +reply will then be connected to this "parent" message.
336 +You can also connect multiple childs at once, tagging them and using the
337 +tag-prefix command (';') or the auto_tag option.
339 +<sect2>Breaking threads
342 +On mailing lists, some people are in the bad habit of starting a new
343 +discussion by hitting "reply" to any message from the list and changing
344 +the subject to a totally unrelated one.
345 +You can fix such threads by using the ``break-thread'' function (bound
346 +by default to #), which will turn the subthread starting from the
347 +current message into a whole different thread.
349 <sect1>Delivery Status Notification (DSN) Support
352 RFC1894 defines a set of MIME content types for relaying information
353 about the status of electronic mail messages. These can be thought of as
354 ``return receipts.'' Berkeley sendmail 8.8.x currently has some command
355 diff -pruN mutt-1.5.5.1-orig/functions.h mutt-1.5.5.1/functions.h
356 --- mutt-1.5.5.1-orig/functions.h Wed Nov 5 10:41:31 2003
357 +++ mutt-1.5.5.1/functions.h Tue Nov 11 02:52:33 2003
358 @@ -69,6 +69,7 @@ struct binding_t OpGeneric[] = {
359 struct binding_t OpMain[] = {
360 { "create-alias", OP_CREATE_ALIAS, "a" },
361 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
362 + { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
363 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
364 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
365 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
366 @@ -95,6 +96,7 @@ struct binding_t OpMain[] = {
367 { "next-undeleted", OP_MAIN_NEXT_UNDELETED, "j" },
368 { "previous-undeleted", OP_MAIN_PREV_UNDELETED, "k" },
369 { "limit", OP_MAIN_LIMIT, "l" },
370 + { "link-threads", OP_MAIN_LINK_THREADS, "&" },
371 { "list-reply", OP_LIST_REPLY, "L" },
372 { "mail", OP_MAIL, "m" },
373 { "toggle-new", OP_TOGGLE_NEW, "N" },
374 @@ -153,6 +155,7 @@ struct binding_t OpMain[] = {
377 struct binding_t OpPager[] = {
378 + { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
379 { "create-alias", OP_CREATE_ALIAS, "a" },
380 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
381 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
382 @@ -175,6 +178,7 @@ struct binding_t OpPager[] = {
383 { "next-entry", OP_NEXT_ENTRY, "J" },
384 { "previous-undeleted",OP_MAIN_PREV_UNDELETED, "k" },
385 { "previous-entry", OP_PREV_ENTRY, "K" },
386 + { "link-threads", OP_MAIN_LINK_THREADS, "&" },
387 { "list-reply", OP_LIST_REPLY, "L" },
388 { "redraw-screen", OP_REDRAW, "\014" },
389 { "mail", OP_MAIL, "m" },
390 diff -pruN mutt-1.5.5.1-orig/imap/imap.c mutt-1.5.5.1/imap/imap.c
391 --- mutt-1.5.5.1-orig/imap/imap.c Wed Nov 5 10:41:36 2003
392 +++ mutt-1.5.5.1/imap/imap.c Tue Nov 11 02:52:33 2003
393 @@ -980,9 +980,11 @@ int imap_sync_mailbox (CONTEXT* ctx, int
394 mutt_buffer_addstr (&cmd, "UID STORE ");
395 mutt_buffer_addstr (&cmd, uid);
397 - /* if attachments have been deleted we delete the message and reupload
398 - * it. This works better if we're expunging, of course. */
399 - if (ctx->hdrs[n]->attach_del)
400 + /* if the message has been rethreaded or attachments have been deleted
401 + * we delete the message and reupload it.
402 + * This works better if we're expunging, of course. */
403 + if (ctx->hdrs[n]->refs_changed || ctx->hdrs[n]->irt_changed ||
404 + ctx->hdrs[n]->attach_del)
406 dprint (3, (debugfile, "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
408 diff -pruN mutt-1.5.5.1-orig/main.c mutt-1.5.5.1/main.c
409 --- mutt-1.5.5.1-orig/main.c Tue Mar 4 08:49:48 2003
410 +++ mutt-1.5.5.1/main.c Tue Nov 11 02:52:33 2003
411 @@ -228,6 +228,12 @@ static void show_version (void)
415 +#ifdef IMAP_EDIT_THREADS
416 + "+IMAP_EDIT_THREADS "
418 + "-IMAP_EDIT_THREADS "
424 diff -pruN mutt-1.5.5.1-orig/mh.c mutt-1.5.5.1/mh.c
425 --- mutt-1.5.5.1-orig/mh.c Wed Nov 5 10:41:32 2003
426 +++ mutt-1.5.5.1/mh.c Tue Nov 11 02:52:33 2003
427 @@ -1220,7 +1220,7 @@ static int mh_sync_message (CONTEXT * ct
429 HEADER *h = ctx->hdrs[msgno];
432 + if (h->attach_del || h->refs_changed || h->irt_changed)
433 if (mh_rewrite_message (ctx, msgno) != 0)
436 @@ -1231,9 +1231,9 @@ static int maildir_sync_message (CONTEXT
438 HEADER *h = ctx->hdrs[msgno];
441 + if (h->attach_del || h->refs_changed || h->irt_changed)
443 - /* when doing attachment deletion, fall back to the MH case. */
444 + /* when doing attachment deletion/rethreading, fall back to the MH case. */
445 if (mh_rewrite_message (ctx, msgno) != 0)
448 diff -pruN mutt-1.5.5.1-orig/mutt.h mutt-1.5.5.1/mutt.h
449 --- mutt-1.5.5.1-orig/mutt.h Wed Nov 5 10:41:32 2003
450 +++ mutt-1.5.5.1/mutt.h Tue Nov 11 02:52:33 2003
452 #define CH_WEED_DELIVERED (1<<13) /* weed eventual Delivered-To headers */
453 #define CH_FORCE_FROM (1<<14) /* give CH_FROM precedence over CH_WEED? */
454 #define CH_NOQFROM (1<<15) /* give CH_FROM precedence over CH_WEED? */
455 +#define CH_UPDATE_IRT (1<<16) /* update In-Reply-To: */
456 +#define CH_UPDATE_REFS (1<<17) /* update References: */
458 /* flags for mutt_enter_string() */
459 #define M_ALIAS 1 /* do alias "completion" by calling up the alias-menu */
460 @@ -506,6 +508,7 @@ typedef struct list_t
462 #define mutt_new_list() safe_calloc (1, sizeof (LIST))
463 void mutt_free_list (LIST **);
464 +LIST *mutt_copy_list (LIST *);
465 int mutt_matches_ignore (const char *, LIST *);
467 /* add an element to a list */
468 @@ -647,6 +650,8 @@ typedef struct header
469 unsigned int subject_changed : 1; /* used for threading */
470 unsigned int threaded : 1; /* used for threading */
471 unsigned int display_subject : 1; /* used for threading */
472 + unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */
473 + unsigned int refs_changed : 1; /* References changed to break thread */
474 unsigned int recip_valid : 1; /* is_recipient is valid */
475 unsigned int active : 1; /* message is not to be removed */
476 unsigned int trash : 1; /* message is marked as trashed on disk.
477 @@ -687,6 +692,10 @@ typedef struct header
478 char *tree; /* character string to print thread tree */
479 struct thread *thread;
481 +#ifdef IMAP_EDIT_THREADS
482 + ENVELOPE *new_env; /* envelope information for rethreading */
488 @@ -752,6 +761,7 @@ typedef struct
489 char *pattern; /* limit pattern string */
490 pattern_t *limit_pattern; /* compiled limit pattern */
492 + HEADER *last_tag; /* last tagged msg. used to link threads */
493 THREAD *tree; /* top of thread tree */
494 HASH *id_hash; /* hash table by msg id */
495 HASH *subj_hash; /* hash table by subject */
496 diff -pruN mutt-1.5.5.1-orig/mx.c mutt-1.5.5.1/mx.c
497 --- mutt-1.5.5.1-orig/mx.c Wed Nov 5 10:41:32 2003
498 +++ mutt-1.5.5.1/mx.c Tue Nov 11 02:52:33 2003
499 @@ -1161,6 +1161,8 @@ int mx_sync_mailbox (CONTEXT *ctx, int *
503 + else if (ctx->last_tag && ctx->last_tag->deleted)
504 + ctx->last_tag = NULL; /* reset last tagged msg now useless */
507 /* really only for IMAP - imap_sync_mailbox results in a call to
508 diff -pruN mutt-1.5.5.1-orig/pager.c mutt-1.5.5.1/pager.c
509 --- mutt-1.5.5.1-orig/pager.c Wed Nov 5 10:41:32 2003
510 +++ mutt-1.5.5.1/pager.c Tue Nov 11 02:52:33 2003
511 @@ -2481,6 +2481,11 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
513 CHECK_MODE(IsHeader (extra));
514 mutt_set_flag (Context, extra->hdr, M_TAG, !extra->hdr->tagged);
516 + Context->last_tag = extra->hdr->tagged ? extra->hdr :
517 + ((Context->last_tag == extra->hdr && !extra->hdr->tagged)
518 + ? NULL : Context->last_tag);
520 redraw = REDRAW_STATUS | REDRAW_INDEX;
521 if (option (OPTRESOLVE))
523 diff -pruN mutt-1.5.5.1-orig/protos.h mutt-1.5.5.1/protos.h
524 --- mutt-1.5.5.1-orig/protos.h Wed Nov 5 10:41:33 2003
525 +++ mutt-1.5.5.1/protos.h Tue Nov 11 02:52:33 2003
526 @@ -146,6 +146,7 @@ void mutt_block_signals (void);
527 void mutt_block_signals_system (void);
528 void mutt_body_handler (BODY *, STATE *);
529 int mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *);
530 +void mutt_break_thread (HEADER *);
531 void mutt_buffy (char *, size_t);
532 int mutt_buffy_list (void);
533 void mutt_canonical_charset (char *, size_t, const char *);
534 @@ -286,6 +287,7 @@ int mutt_is_list_recipient (int, ADDRESS
535 int mutt_is_subscribed_list (ADDRESS *);
536 int mutt_is_text_part (BODY *);
537 int mutt_is_valid_mailbox (const char *);
538 +int mutt_link_threads (HEADER *, HEADER *, CONTEXT *);
539 int mutt_lookup_mime_type (BODY *, const char *);
540 int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
541 int mutt_multi_choice (char *prompt, char *letters);
542 diff -pruN mutt-1.5.5.1-orig/thread.c mutt-1.5.5.1/thread.c
543 --- mutt-1.5.5.1-orig/thread.c Wed Nov 5 10:41:34 2003
544 +++ mutt-1.5.5.1/thread.c Tue Nov 11 02:52:33 2003
545 @@ -1333,3 +1333,105 @@ HASH *mutt_make_subj_hash (CONTEXT *ctx)
550 +static void clean_references (THREAD *brk, THREAD *cur)
556 + for (; cur; cur = cur->next, done = 0)
558 + /* parse subthread recursively */
559 + clean_references (brk, cur->child);
562 + break; /* skip pseudo-message */
564 + /* Looking for the first bad reference according to the new threading.
565 + * Optimal since Mutt stores the references in reverse order, and the
566 + * first loop should match immediatly for mails respecting RFC2822. */
567 + for (p = brk; !done && p; p = p->parent)
568 + for (ref = cur->message->env->references; p->message && ref; ref = ref->next)
569 + if (!mutt_strcasecmp (ref->data, p->message->env->message_id))
577 + HEADER *h = cur->message;
579 + /* clearing the References: header from obsolete Message-Id(s) */
580 + mutt_free_list (&ref->next);
582 +#ifdef IMAP_EDIT_THREADS
584 + mutt_free_list (&h->new_env->references);
586 + h->new_env = mutt_new_envelope ();
588 + h->new_env->references = mutt_copy_list (h->env->references);
591 + h->refs_changed = h->changed = 1;
596 +void mutt_break_thread (HEADER *hdr)
598 + mutt_free_list (&hdr->env->in_reply_to);
599 + mutt_free_list (&hdr->env->references);
600 + hdr->irt_changed = hdr->refs_changed = hdr->changed = 1;
602 +#ifdef IMAP_EDIT_THREADS
605 + mutt_free_list (&hdr->new_env->in_reply_to);
606 + mutt_free_list (&hdr->new_env->references);
609 + hdr->new_env = mutt_new_envelope ();
612 + clean_references (hdr->thread, hdr->thread->child);
615 +static int link_threads (HEADER *parent, HEADER *child, CONTEXT *ctx)
617 + if (child == parent)
620 + mutt_break_thread (child);
622 + child->env->in_reply_to = mutt_new_list ();
623 + child->env->in_reply_to->data = safe_strdup (parent->env->message_id);
625 +#ifdef IMAP_EDIT_THREADS
626 + child->new_env->in_reply_to = mutt_new_list ();
627 + child->new_env->in_reply_to->data = safe_strdup (parent->env->message_id);
630 + mutt_set_flag (ctx, child, M_TAG, 0);
632 + child->irt_changed = child->changed = 1;
636 +int mutt_link_threads (HEADER *cur, HEADER *last, CONTEXT *ctx)
638 + int i, changed = 0;
642 + for (i = 0; i < ctx->vcount; i++)
643 + if (ctx->hdrs[Context->v2r[i]]->tagged)
644 + changed |= link_threads (cur, ctx->hdrs[Context->v2r[i]], ctx);
647 + changed = link_threads (cur, last, ctx);
651 diff -pruN mutt-1.5.5.1-orig/PATCHES mutt-1.5.5.1/PATCHES
652 --- mutt-1.5.5.1-orig/PATCHES Tue Apr 15 15:18:34 2003
653 +++ mutt-1.5.5.1/PATCHES Tue Nov 11 02:52:33 2003
655 +patch-1.5.5.1.cd.edit_threads.9.5