]> git.pld-linux.org Git - packages/mutt.git/blame - mutt-cd.edit_threads.patch
- updated for 1.5.9 (minus autogenerated files, plus my pl.po update)
[packages/mutt.git] / mutt-cd.edit_threads.patch
CommitLineData
d7ac7919
JB
1diff -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"
9de0e450 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"
d7ac7919
JB
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"
9de0e450 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"
d7ac7919 18 OP_MAIN_NEXT_NEW_THEN_UNREAD "jump to the next new or unread message"
9de0e450 19 OP_MAIN_NEXT_SUBTHREAD "jump to the next subthread"
bcac18a8
JB
20--- mutt-1.5.9/configure.in.orig 2005-03-31 15:58:18.833976352 +0200
21+++ mutt-1.5.9/configure.in 2005-03-31 15:59:03.298216760 +0200
22@@ -557,6 +557,16 @@
d7ac7919
JB
23
24 dnl -- end imap dependencies --
25
26+AC_ARG_ENABLE(imap-edit-threads, [ --enable-imap-edit-threads Enable editing threads support for IMAP],
27+[
28+ if test "$enableval" = "yes"; then
29+ if test "$need_imap" = "yes"; then
bcac18a8 30+ AC_DEFINE([IMAP_EDIT_THREADS],,[Do you want to use the rethreading functions with IMAP])
d7ac7919
JB
31+ else
32+ AC_MSG_WARN([IMAP support for edit_threads is only useful with IMAP support])
33+ fi
34+fi])
35+
bcac18a8 36 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl[=PFX]], [Compile in SSL support for POP/IMAP]),
d7ac7919
JB
37 [ if test "$with_ssl" != "no"
38 then
39diff -pruN mutt-1.5.5.1-orig/copy.c mutt-1.5.5.1/copy.c
40--- mutt-1.5.5.1-orig/copy.c Wed Nov 5 10:41:31 2003
41+++ mutt-1.5.5.1/copy.c Tue Nov 11 02:52:33 2003
42@@ -95,6 +95,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long
43 (ascii_strncasecmp ("Content-Length:", buf, 15) == 0 ||
9de0e450 44 ascii_strncasecmp ("Lines:", buf, 6) == 0))
45 continue;
46+ if ((flags & CH_UPDATE_REFS) &&
47+ ascii_strncasecmp ("References:", buf, 11) == 0)
48+ continue;
49+ if ((flags & CH_UPDATE_IRT) &&
50+ ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
51+ continue;
52 ignore = 0;
53 }
d7ac7919
JB
54
55@@ -193,6 +199,12 @@ mutt_copy_hdr (FILE *in, FILE *out, long
56 ascii_strncasecmp ("type:", buf + 8, 5) == 0)) ||
9de0e450 57 ascii_strncasecmp ("mime-version:", buf, 13) == 0))
58 continue;
59+ if ((flags & CH_UPDATE_REFS) &&
60+ ascii_strncasecmp ("References:", buf, 11) == 0)
61+ continue;
62+ if ((flags & CH_UPDATE_IRT) &&
63+ ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
64+ continue;
65
66 /* Find x -- the array entry where this header is to be saved */
d7ac7919
JB
67 if (flags & CH_REORDER)
68@@ -326,6 +338,8 @@ mutt_copy_hdr (FILE *in, FILE *out, long
9de0e450 69 CH_XMIT ignore Lines: and Content-Length:
70 CH_WEED do header weeding
d7ac7919 71 CH_NOQFROM ignore ">From " line
9de0e450 72+ CH_UPDATE_IRT update the In-Reply-To: header
73+ CH_UPDATE_REFS update the References: header
74
75 prefix
d7ac7919
JB
76 string to use if CH_PREFIX is set
77@@ -335,6 +349,9 @@ int
78 mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix)
9de0e450 79 {
80 char buffer[SHORT_STRING];
81+
82+ flags |= (h->irt_changed ? CH_UPDATE_IRT : 0)
83+ | (h->refs_changed ? CH_UPDATE_REFS : 0);
84
85 if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
d7ac7919
JB
86 return (-1);
87@@ -358,7 +375,56 @@ mutt_copy_header (FILE *in, HEADER *h, F
88 if (flags & CH_UPDATE)
89 {
9de0e450 90 if ((flags & CH_NOSTATUS) == 0)
d7ac7919
JB
91+#ifdef IMAP_EDIT_THREADS
92+#define NEW_ENV new_env
93+#else
94+#define NEW_ENV env
95+#endif
9de0e450 96 {
d7ac7919 97+ if (h->irt_changed && h->NEW_ENV->in_reply_to)
9de0e450 98+ {
d7ac7919 99+ LIST *listp = h->NEW_ENV->in_reply_to;
9de0e450 100+
101+ if (fputs ("In-Reply-To: ", out) == EOF)
102+ return (-1);
103+
104+ for (; listp; listp = listp->next)
105+ if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
106+ return (-1);
107+
108+ if (fputc ('\n', out) == EOF)
109+ return (-1);
110+ }
111+
d7ac7919 112+ if (h->refs_changed && h->NEW_ENV->references)
9de0e450 113+ {
d7ac7919 114+ LIST *listp = h->NEW_ENV->references, *refs = NULL, *t;
9de0e450 115+
116+ if (fputs ("References: ", out) == EOF)
117+ return (-1);
118+
119+ /* Mutt stores references in reverse order, thus we create
120+ * a reordered refs list that we can put in the headers */
121+ for (; listp; listp = listp->next, refs = t)
122+ {
123+ t = (LIST *)safe_malloc (sizeof (LIST));
124+ t->data = listp->data;
125+ t->next = refs;
126+ }
127+
128+ for (; refs; refs = refs->next)
129+ if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
130+ return (-1);
131+
132+ /* clearing refs from memory */
133+ for (t = refs; refs; refs = t->next, t = refs)
134+ safe_free ((void **)&refs);
135+
136+ if (fputc ('\n', out) == EOF)
137+ return (-1);
138+ }
d7ac7919 139+#undef NEW_ENV
9de0e450 140+
141 if (h->old || h->read)
142 {
d7ac7919
JB
143 if (fputs ("Status: ", out) == EOF)
144diff -pruN mutt-1.5.5.1-orig/curs_main.c mutt-1.5.5.1/curs_main.c
145--- mutt-1.5.5.1-orig/curs_main.c Wed Nov 5 10:41:31 2003
146+++ mutt-1.5.5.1/curs_main.c Tue Nov 11 02:52:33 2003
147@@ -930,6 +930,11 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
148 else
9de0e450 149 {
150 mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
151+
152+ Context->last_tag = CURHDR->tagged ? CURHDR :
153+ ((Context->last_tag == CURHDR && !CURHDR->tagged)
154+ ? NULL : Context->last_tag);
155+
156 menu->redraw = REDRAW_STATUS;
157 if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
d7ac7919
JB
158 {
159@@ -1162,6 +1167,89 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
160 }
9de0e450 161 done = 1;
162 }
163+ break;
164+
165+ case OP_MAIN_BREAK_THREAD:
166+
167+ CHECK_MSGCOUNT;
168+ CHECK_VISIBLE;
169+ CHECK_READONLY;
170+
171+ if ((Sort & SORT_MASK) != SORT_THREADS)
9de0e450 172+ mutt_error _("Threading is not enabled.");
9de0e450 173+
d7ac7919
JB
174+#if defined (USE_IMAP) && ! defined (IMAP_EDIT_THREADS)
175+ else if (Context->magic == M_IMAP)
176+ mutt_error _("Compile Mutt with --enable-imap-edit-threads for break-thread support");
177+#endif
178+
179+ else
180+ {
181+ {
182+ HEADER *oldcur = CURHDR;
9de0e450 183+
d7ac7919
JB
184+ mutt_break_thread (CURHDR);
185+ mutt_sort_headers (Context, 1);
186+ menu->current = oldcur->virtual;
187+ }
9de0e450 188+
d7ac7919
JB
189+ Context->changed = 1;
190+ mutt_message _("Thread broken");
9de0e450 191+
d7ac7919
JB
192+ if (menu->menu == MENU_PAGER)
193+ {
194+ op = OP_DISPLAY_MESSAGE;
195+ continue;
196+ }
197+ else
198+ menu->redraw |= REDRAW_INDEX;
9de0e450 199+ }
9de0e450 200+
d7ac7919 201+ break;
9de0e450 202+
203+ case OP_MAIN_LINK_THREADS:
204+
205+ CHECK_MSGCOUNT;
206+ CHECK_VISIBLE;
207+ CHECK_READONLY;
208+
209+ if ((Sort & SORT_MASK) != SORT_THREADS)
210+ mutt_error _("Threading is not enabled.");
d7ac7919
JB
211+
212+#if defined (USE_IMAP) && ! defined (IMAP_EDIT_THREADS)
213+ else if (Context->magic == M_IMAP)
214+ mutt_error _("Compile Mutt with --enable-imap-edit-threads for link-threads support");
215+#endif
216+
9de0e450 217+ else if (!CURHDR->env->message_id)
218+ mutt_error _("No Message-ID: header available to link thread");
219+ else if (!tag && (!Context->last_tag || !Context->last_tag->tagged))
220+ mutt_error _("First, please tag a message to be linked here");
221+ else
222+ {
223+ HEADER *oldcur = CURHDR;
224+
225+ if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
226+ Context))
227+ {
228+ mutt_sort_headers (Context, 1);
229+ menu->current = oldcur->virtual;
230+
231+ Context->changed = 1;
232+ mutt_message _("Threads linked");
233+ }
234+ else
235+ mutt_error _("No thread linked");
236+ }
237+
238+ if (menu->menu == MENU_PAGER)
239+ {
240+ op = OP_DISPLAY_MESSAGE;
241+ continue;
242+ }
243+ else
244+ menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
245+
246 break;
247
d7ac7919
JB
248 case OP_EDIT_TYPE:
249diff -pruN mutt-1.5.5.1-orig/doc/manual.sgml.head mutt-1.5.5.1/doc/manual.sgml.head
250--- mutt-1.5.5.1-orig/doc/manual.sgml.head Wed Nov 5 10:41:34 2003
251+++ mutt-1.5.5.1/doc/manual.sgml.head Tue Nov 11 02:52:33 2003
252@@ -2170,8 +2170,43 @@ used a threaded news client, this is the
253 with large volume mailing lists easier because you can easily delete
9de0e450 254 uninteresting threads and quickly find topics of value.
255
256+<sect1>Editing threads
257+<p>
258+Mutt has the ability to dynamically restructure threads that are broken
259+either by misconfigured software or bad behaviour from some
d7ac7919
JB
260+correspondents. This allows to clean your mailboxes formats) from these
261+annoyances which make it hard to follow a discussion.
262+
263+If you want to use these functions with IMAP, you need to compile Mutt
264+with the <em/--enable-imap-edit-threads/ configure flag.
9de0e450 265+
266+<sect2>Linking threads
267+<p>
268+
269+Some mailers tend to "forget" to correctly set the "In-Reply-To:" and
270+"References:" headers when replying to a message. This results in broken
271+discussions because Mutt has not enough information to guess the correct
272+threading.
d7ac7919
JB
273+You can fix this by tagging the reply, then moving to the parent message
274+and using the ``link-threads'' function (bound to & by default). The
275+reply will then be connected to this "parent" message.
9de0e450 276+
277+You can also connect multiple childs at once, tagging them and using the
278+tag-prefix command (';') or the auto_tag option.
279+
280+<sect2>Breaking threads
281+<p>
282+
283+On mailing lists, some people are in the bad habit of starting a new
284+discussion by hitting "reply" to any message from the list and changing
285+the subject to a totally unrelated one.
286+You can fix such threads by using the ``break-thread'' function (bound
287+by default to #), which will turn the subthread starting from the
288+current message into a whole different thread.
289+
290 <sect1>Delivery Status Notification (DSN) Support
291 <p>
292+
293 RFC1894 defines a set of MIME content types for relaying information
294 about the status of electronic mail messages. These can be thought of as
d7ac7919
JB
295 ``return receipts.'' Berkeley sendmail 8.8.x currently has some command
296diff -pruN mutt-1.5.5.1-orig/functions.h mutt-1.5.5.1/functions.h
297--- mutt-1.5.5.1-orig/functions.h Wed Nov 5 10:41:31 2003
298+++ mutt-1.5.5.1/functions.h Tue Nov 11 02:52:33 2003
299@@ -69,6 +69,7 @@ struct binding_t OpGeneric[] = {
300 struct binding_t OpMain[] = {
9de0e450 301 { "create-alias", OP_CREATE_ALIAS, "a" },
302 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
303+ { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
304 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
305 { "change-folder-readonly", OP_MAIN_CHANGE_FOLDER_READONLY, "\033c" },
d7ac7919
JB
306 { "collapse-thread", OP_MAIN_COLLAPSE_THREAD, "\033v" },
307@@ -95,6 +96,7 @@ struct binding_t OpMain[] = {
308 { "next-undeleted", OP_MAIN_NEXT_UNDELETED, "j" },
9de0e450 309 { "previous-undeleted", OP_MAIN_PREV_UNDELETED, "k" },
310 { "limit", OP_MAIN_LIMIT, "l" },
311+ { "link-threads", OP_MAIN_LINK_THREADS, "&" },
312 { "list-reply", OP_LIST_REPLY, "L" },
313 { "mail", OP_MAIL, "m" },
d7ac7919
JB
314 { "toggle-new", OP_TOGGLE_NEW, "N" },
315@@ -153,6 +155,7 @@ struct binding_t OpMain[] = {
316 };
9de0e450 317
318 struct binding_t OpPager[] = {
319+ { "break-thread", OP_MAIN_BREAK_THREAD, "#" },
320 { "create-alias", OP_CREATE_ALIAS, "a" },
321 { "bounce-message", OP_BOUNCE_MESSAGE, "b" },
d7ac7919
JB
322 { "change-folder", OP_MAIN_CHANGE_FOLDER, "c" },
323@@ -175,6 +178,7 @@ struct binding_t OpPager[] = {
324 { "next-entry", OP_NEXT_ENTRY, "J" },
9de0e450 325 { "previous-undeleted",OP_MAIN_PREV_UNDELETED, "k" },
326 { "previous-entry", OP_PREV_ENTRY, "K" },
327+ { "link-threads", OP_MAIN_LINK_THREADS, "&" },
328 { "list-reply", OP_LIST_REPLY, "L" },
329 { "redraw-screen", OP_REDRAW, "\014" },
d7ac7919
JB
330 { "mail", OP_MAIL, "m" },
331diff -pruN mutt-1.5.5.1-orig/imap/imap.c mutt-1.5.5.1/imap/imap.c
332--- mutt-1.5.5.1-orig/imap/imap.c Wed Nov 5 10:41:36 2003
333+++ mutt-1.5.5.1/imap/imap.c Tue Nov 11 02:52:33 2003
334@@ -980,9 +980,11 @@ int imap_sync_mailbox (CONTEXT* ctx, int
335 mutt_buffer_addstr (&cmd, "UID STORE ");
336 mutt_buffer_addstr (&cmd, uid);
337
338- /* if attachments have been deleted we delete the message and reupload
339- * it. This works better if we're expunging, of course. */
340- if (ctx->hdrs[n]->attach_del)
341+ /* if the message has been rethreaded or attachments have been deleted
342+ * we delete the message and reupload it.
343+ * This works better if we're expunging, of course. */
344+ if (ctx->hdrs[n]->refs_changed || ctx->hdrs[n]->irt_changed ||
345+ ctx->hdrs[n]->attach_del)
346 {
347 dprint (3, (debugfile, "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
348 if (!appendctx)
349diff -pruN mutt-1.5.5.1-orig/main.c mutt-1.5.5.1/main.c
350--- mutt-1.5.5.1-orig/main.c Tue Mar 4 08:49:48 2003
351+++ mutt-1.5.5.1/main.c Tue Nov 11 02:52:33 2003
352@@ -228,6 +228,12 @@ static void show_version (void)
353 "-USE_IMAP "
354 #endif
355
356+#ifdef IMAP_EDIT_THREADS
357+ "+IMAP_EDIT_THREADS "
358+#else
359+ "-IMAP_EDIT_THREADS "
360+#endif
361+
362 #ifdef USE_GSS
363 "+USE_GSS "
364 #else
365diff -pruN mutt-1.5.5.1-orig/mh.c mutt-1.5.5.1/mh.c
366--- mutt-1.5.5.1-orig/mh.c Wed Nov 5 10:41:32 2003
367+++ mutt-1.5.5.1/mh.c Tue Nov 11 02:52:33 2003
368@@ -1220,7 +1220,7 @@ static int mh_sync_message (CONTEXT * ct
369 {
370 HEADER *h = ctx->hdrs[msgno];
371
372- if (h->attach_del)
373+ if (h->attach_del || h->refs_changed || h->irt_changed)
374 if (mh_rewrite_message (ctx, msgno) != 0)
375 return -1;
376
377@@ -1231,9 +1231,9 @@ static int maildir_sync_message (CONTEXT
378 {
379 HEADER *h = ctx->hdrs[msgno];
380
381- if (h->attach_del)
382+ if (h->attach_del || h->refs_changed || h->irt_changed)
383 {
384- /* when doing attachment deletion, fall back to the MH case. */
385+ /* when doing attachment deletion/rethreading, fall back to the MH case. */
386 if (mh_rewrite_message (ctx, msgno) != 0)
387 return (-1);
388 }
bcac18a8
JB
389--- mutt-1.5.9/mutt.h.orig 2005-03-31 15:58:18.891967536 +0200
390+++ mutt-1.5.9/mutt.h 2005-03-31 15:59:31.109988728 +0200
391@@ -94,6 +94,8 @@
9de0e450 392 #define CH_WEED_DELIVERED (1<<13) /* weed eventual Delivered-To headers */
393 #define CH_FORCE_FROM (1<<14) /* give CH_FROM precedence over CH_WEED? */
d7ac7919
JB
394 #define CH_NOQFROM (1<<15) /* give CH_FROM precedence over CH_WEED? */
395+#define CH_UPDATE_IRT (1<<16) /* update In-Reply-To: */
396+#define CH_UPDATE_REFS (1<<17) /* update References: */
9de0e450 397
398 /* flags for mutt_enter_string() */
d7ac7919 399 #define M_ALIAS 1 /* do alias "completion" by calling up the alias-menu */
bcac18a8
JB
400@@ -550,6 +552,7 @@
401 #define mutt_new_rx_list() safe_calloc (1, sizeof (RX_LIST))
402 #define mutt_new_spam_list() safe_calloc (1, sizeof (SPAM_LIST))
d7ac7919
JB
403 void mutt_free_list (LIST **);
404+LIST *mutt_copy_list (LIST *);
bcac18a8
JB
405 void mutt_free_rx_list (RX_LIST **);
406 void mutt_free_spam_list (SPAM_LIST **);
d7ac7919 407 int mutt_matches_ignore (const char *, LIST *);
bcac18a8 408@@ -707,6 +710,8 @@
d7ac7919 409 unsigned int subject_changed : 1; /* used for threading */
9de0e450 410 unsigned int threaded : 1; /* used for threading */
411 unsigned int display_subject : 1; /* used for threading */
d7ac7919
JB
412+ unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */
413+ unsigned int refs_changed : 1; /* References changed to break thread */
9de0e450 414 unsigned int recip_valid : 1; /* is_recipient is valid */
415 unsigned int active : 1; /* message is not to be removed */
d7ac7919 416 unsigned int trash : 1; /* message is marked as trashed on disk.
bcac18a8 417@@ -747,6 +752,10 @@
d7ac7919
JB
418 char *tree; /* character string to print thread tree */
419 struct thread *thread;
420
421+#ifdef IMAP_EDIT_THREADS
422+ ENVELOPE *new_env; /* envelope information for rethreading */
423+#endif
424+
425 #ifdef MIXMASTER
426 LIST *chain;
427 #endif
bcac18a8 428@@ -811,6 +820,7 @@
d7ac7919 429 char *pattern; /* limit pattern string */
9de0e450 430 pattern_t *limit_pattern; /* compiled limit pattern */
431 HEADER **hdrs;
432+ HEADER *last_tag; /* last tagged msg. used to link threads */
433 THREAD *tree; /* top of thread tree */
434 HASH *id_hash; /* hash table by msg id */
d7ac7919
JB
435 HASH *subj_hash; /* hash table by subject */
436diff -pruN mutt-1.5.5.1-orig/mx.c mutt-1.5.5.1/mx.c
437--- mutt-1.5.5.1-orig/mx.c Wed Nov 5 10:41:32 2003
438+++ mutt-1.5.5.1/mx.c Tue Nov 11 02:52:33 2003
439@@ -1161,6 +1161,8 @@ int mx_sync_mailbox (CONTEXT *ctx, int *
440 ctx->deleted = 0;
9de0e450 441 }
442 }
443+ else if (ctx->last_tag && ctx->last_tag->deleted)
444+ ctx->last_tag = NULL; /* reset last tagged msg now useless */
445 }
446
d7ac7919
JB
447 /* really only for IMAP - imap_sync_mailbox results in a call to
448diff -pruN mutt-1.5.5.1-orig/pager.c mutt-1.5.5.1/pager.c
449--- mutt-1.5.5.1-orig/pager.c Wed Nov 5 10:41:32 2003
450+++ mutt-1.5.5.1/pager.c Tue Nov 11 02:52:33 2003
451@@ -2481,6 +2481,11 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE);
452 case OP_TAG:
9de0e450 453 CHECK_MODE(IsHeader (extra));
454 mutt_set_flag (Context, extra->hdr, M_TAG, !extra->hdr->tagged);
455+
456+ Context->last_tag = extra->hdr->tagged ? extra->hdr :
457+ ((Context->last_tag == extra->hdr && !extra->hdr->tagged)
458+ ? NULL : Context->last_tag);
459+
460 redraw = REDRAW_STATUS | REDRAW_INDEX;
461 if (option (OPTRESOLVE))
d7ac7919
JB
462 {
463diff -pruN mutt-1.5.5.1-orig/protos.h mutt-1.5.5.1/protos.h
464--- mutt-1.5.5.1-orig/protos.h Wed Nov 5 10:41:33 2003
465+++ mutt-1.5.5.1/protos.h Tue Nov 11 02:52:33 2003
466@@ -146,6 +146,7 @@ void mutt_block_signals (void);
467 void mutt_block_signals_system (void);
9de0e450 468 void mutt_body_handler (BODY *, STATE *);
d7ac7919 469 int mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *);
9de0e450 470+void mutt_break_thread (HEADER *);
471 void mutt_buffy (char *, size_t);
d7ac7919 472 int mutt_buffy_list (void);
9de0e450 473 void mutt_canonical_charset (char *, size_t, const char *);
d7ac7919
JB
474@@ -286,6 +287,7 @@ int mutt_is_list_recipient (int, ADDRESS
475 int mutt_is_subscribed_list (ADDRESS *);
476 int mutt_is_text_part (BODY *);
9de0e450 477 int mutt_is_valid_mailbox (const char *);
478+int mutt_link_threads (HEADER *, HEADER *, CONTEXT *);
d7ac7919 479 int mutt_lookup_mime_type (BODY *, const char *);
9de0e450 480 int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
481 int mutt_multi_choice (char *prompt, char *letters);
d7ac7919
JB
482diff -pruN mutt-1.5.5.1-orig/thread.c mutt-1.5.5.1/thread.c
483--- mutt-1.5.5.1-orig/thread.c Wed Nov 5 10:41:34 2003
484+++ mutt-1.5.5.1/thread.c Tue Nov 11 02:52:33 2003
485@@ -1333,3 +1333,105 @@ HASH *mutt_make_subj_hash (CONTEXT *ctx)
486
487 return hash;
488 }
489+
490+static void clean_references (THREAD *brk, THREAD *cur)
491+{
492+ THREAD *p;
493+ LIST *ref = NULL;
494+ int done = 0;
495+
496+ for (; cur; cur = cur->next, done = 0)
497+ {
498+ /* parse subthread recursively */
499+ clean_references (brk, cur->child);
500+
501+ if (!cur->message)
502+ break; /* skip pseudo-message */
503+
504+ /* Looking for the first bad reference according to the new threading.
505+ * Optimal since Mutt stores the references in reverse order, and the
506+ * first loop should match immediatly for mails respecting RFC2822. */
507+ for (p = brk; !done && p; p = p->parent)
508+ for (ref = cur->message->env->references; p->message && ref; ref = ref->next)
509+ if (!mutt_strcasecmp (ref->data, p->message->env->message_id))
510+ {
511+ done = 1;
512+ break;
513+ }
514+
515+ if (done)
516+ {
517+ HEADER *h = cur->message;
518+
519+ /* clearing the References: header from obsolete Message-Id(s) */
520+ mutt_free_list (&ref->next);
521+
522+#ifdef IMAP_EDIT_THREADS
523+ if (h->new_env)
524+ mutt_free_list (&h->new_env->references);
525+ else
526+ h->new_env = mutt_new_envelope ();
527+
528+ h->new_env->references = mutt_copy_list (h->env->references);
529+#endif
530+
531+ h->refs_changed = h->changed = 1;
532+ }
533+ }
534+}
535+
536+void mutt_break_thread (HEADER *hdr)
537+{
538+ mutt_free_list (&hdr->env->in_reply_to);
539+ mutt_free_list (&hdr->env->references);
540+ hdr->irt_changed = hdr->refs_changed = hdr->changed = 1;
541+
542+#ifdef IMAP_EDIT_THREADS
543+ if (hdr->new_env)
544+ {
545+ mutt_free_list (&hdr->new_env->in_reply_to);
546+ mutt_free_list (&hdr->new_env->references);
547+ }
548+ else
549+ hdr->new_env = mutt_new_envelope ();
550+#endif
551+
552+ clean_references (hdr->thread, hdr->thread->child);
553+}
554+
555+static int link_threads (HEADER *parent, HEADER *child, CONTEXT *ctx)
556+{
557+ if (child == parent)
558+ return 0;
559+
560+ mutt_break_thread (child);
561+
562+ child->env->in_reply_to = mutt_new_list ();
563+ child->env->in_reply_to->data = safe_strdup (parent->env->message_id);
564+
565+#ifdef IMAP_EDIT_THREADS
566+ child->new_env->in_reply_to = mutt_new_list ();
567+ child->new_env->in_reply_to->data = safe_strdup (parent->env->message_id);
568+#endif
569+
570+ mutt_set_flag (ctx, child, M_TAG, 0);
571+
572+ child->irt_changed = child->changed = 1;
573+ return 1;
574+}
575+
576+int mutt_link_threads (HEADER *cur, HEADER *last, CONTEXT *ctx)
577+{
578+ int i, changed = 0;
579+
580+ if (!last)
581+ {
582+ for (i = 0; i < ctx->vcount; i++)
583+ if (ctx->hdrs[Context->v2r[i]]->tagged)
584+ changed |= link_threads (cur, ctx->hdrs[Context->v2r[i]], ctx);
585+ }
586+ else
587+ changed = link_threads (cur, last, ctx);
588+
589+ return changed;
590+}
591diff -pruN mutt-1.5.5.1-orig/PATCHES mutt-1.5.5.1/PATCHES
592--- mutt-1.5.5.1-orig/PATCHES Tue Apr 15 15:18:34 2003
593+++ mutt-1.5.5.1/PATCHES Tue Nov 11 02:52:33 2003
9de0e450 594@@ -1,0 +1 @@
d7ac7919 595+patch-1.5.5.1.cd.edit_threads.9.5
bcac18a8
JB
596--- mutt-1.5.9/po/pl.po.orig 2005-03-31 15:58:18.914964000 +0200
597+++ mutt-1.5.9/po/pl.po 2005-03-31 16:06:53.533730096 +0200
598@@ -1014,6 +1014,38 @@
599 msgid "Exit Mutt without saving?"
600