]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-cd.edit_threads.patch
- updated to http://cedricduval.free.fr/mutt/patches/download/patch-1.5.5.1.cd.edit_t...
[packages/mutt.git] / mutt-cd.edit_threads.patch
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
23 @@ -36,3 +36,7 @@
24   * all return values other than (size_t)(-1) as equivalent. */
25  #undef ICONV_NONTRANS
26  
27 +/* Do you want to use the rethreading functions with IMAP
28 + * (--enable-imap-edit-threads) */
29 +#undef IMAP_EDIT_THREADS
30 +
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
34 @@ -531,3 +531,7 @@
35   * all return values other than (size_t)(-1) as equivalent. */
36  #undef ICONV_NONTRANS
37  
38 +/* Do you want to use the rethreading functions with IMAP
39 + * (--enable-imap-edit-threads) */
40 +#undef IMAP_EDIT_THREADS
41 +
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
46  ac_help="$ac_help
47      --with-gss[=PFX]         Compile in GSSAPI authentication for IMAP"
48  ac_help="$ac_help
49 +  --enable-imap-edit-threads Enable editing threads support for IMAP"
50 +ac_help="$ac_help
51    --with-ssl[=PFX]           Compile in SSL support for POP/IMAP"
52  ac_help="$ac_help
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
55  else
56    USE_GSS_TRUE='#'
57    USE_GSS_FALSE=
58 +fi
59 +
60 +
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"
64 +  
65 +  if test "$enableval" = "yes"; then
66 +    if test "$need_imap" = "yes"; then
67 +      cat >> confdefs.h <<\EOF
68 +#define IMAP_EDIT_THREADS 1
69 +EOF
70 +
71 +    else
72 +      echo "configure: warning: IMAP support for edit_threads is only useful with IMAP support" 1>&2
73 +    fi
74 +fi
75  fi
76  
77  
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 
82  
83  dnl -- end imap dependencies --
84  
85 +AC_ARG_ENABLE(imap-edit-threads, [  --enable-imap-edit-threads Enable editing threads support for IMAP],
86 +[
87 +  if test "$enableval" = "yes"; then
88 +    if test "$need_imap" = "yes"; then
89 +      AC_DEFINE(IMAP_EDIT_THREADS)
90 +    else
91 +      AC_MSG_WARN([IMAP support for edit_threads is only useful with IMAP support])
92 +    fi
93 +fi])
94 +
95  AC_ARG_WITH(ssl, [  --with-ssl[=PFX]           Compile in SSL support for POP/IMAP],
96  [       if test "$with_ssl" != "no"
97          then
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))
104           continue;
105 +       if ((flags & CH_UPDATE_REFS) &&
106 +           ascii_strncasecmp ("References:", buf, 11) == 0)
107 +         continue;
108 +       if ((flags & CH_UPDATE_IRT) &&
109 +           ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
110 +         continue;
111         ignore = 0;
112        }
113  
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))
117         continue;
118 +      if ((flags & CH_UPDATE_REFS) &&
119 +         ascii_strncasecmp ("References:", buf, 11) == 0)
120 +       continue;
121 +      if ((flags & CH_UPDATE_IRT) &&
122 +         ascii_strncasecmp ("In-Reply-To:", buf, 12) == 0)
123 +       continue;
124  
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
133  
134     prefix
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)
138  {
139    char buffer[SHORT_STRING];
140 +
141 +  flags |= (h->irt_changed ? CH_UPDATE_IRT : 0)
142 +         | (h->refs_changed ? CH_UPDATE_REFS : 0);
143    
144    if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1)
145      return (-1);
146 @@ -358,7 +375,56 @@ mutt_copy_header (FILE *in, HEADER *h, F
147    if (flags & CH_UPDATE)
148    {
149      if ((flags & CH_NOSTATUS) == 0)
150 +#ifdef IMAP_EDIT_THREADS
151 +#define NEW_ENV new_env
152 +#else
153 +#define NEW_ENV env
154 +#endif
155      {
156 +      if (h->irt_changed && h->NEW_ENV->in_reply_to)
157 +      {
158 +       LIST *listp = h->NEW_ENV->in_reply_to;
159 +
160 +       if (fputs ("In-Reply-To: ", out) == EOF)
161 +         return (-1);
162 +
163 +       for (; listp; listp = listp->next)
164 +         if ((fputs (listp->data, out) == EOF) || (fputc (' ', out) == EOF))
165 +           return (-1);
166 +
167 +       if (fputc ('\n', out) == EOF)
168 +         return (-1);
169 +      }
170 +
171 +      if (h->refs_changed && h->NEW_ENV->references)
172 +      {
173 +       LIST *listp = h->NEW_ENV->references, *refs = NULL, *t;
174 +
175 +       if (fputs ("References: ", out) == EOF)
176 +         return (-1);
177 +
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)
181 +       {
182 +         t = (LIST *)safe_malloc (sizeof (LIST));
183 +         t->data = listp->data;
184 +         t->next = refs;
185 +       }
186 +
187 +       for (; refs; refs = refs->next)
188 +         if ((fputs (refs->data, out) == EOF) || (fputc (' ', out) == EOF))
189 +           return (-1);
190 +
191 +       /* clearing refs from memory */
192 +       for (t = refs; refs; refs = t->next, t = refs)
193 +         safe_free ((void **)&refs);
194 +
195 +       if (fputc ('\n', out) == EOF)
196 +         return (-1);
197 +      }
198 +#undef NEW_ENV
199 +
200        if (h->old || h->read)
201        {
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);
207         else
208         {
209           mutt_set_flag (Context, CURHDR, M_TAG, !CURHDR->tagged);
210 +
211 +         Context->last_tag = CURHDR->tagged ? CURHDR :
212 +           ((Context->last_tag == CURHDR && !CURHDR->tagged)
213 +            ? NULL : Context->last_tag);
214 +
215           menu->redraw = REDRAW_STATUS;
216           if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
217           {
218 @@ -1162,6 +1167,89 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE);
219           }
220           done = 1;
221         }
222 +       break;
223 +
224 +      case OP_MAIN_BREAK_THREAD:
225 +
226 +       CHECK_MSGCOUNT;
227 +        CHECK_VISIBLE;
228 +       CHECK_READONLY;
229 +
230 +        if ((Sort & SORT_MASK) != SORT_THREADS)
231 +         mutt_error _("Threading is not enabled.");
232 +
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");
236 +#endif
237 +
238 +       else
239 +       {
240 +         {
241 +           HEADER *oldcur = CURHDR;
242 +
243 +           mutt_break_thread (CURHDR);
244 +           mutt_sort_headers (Context, 1);
245 +           menu->current = oldcur->virtual;
246 +         }
247 +
248 +         Context->changed = 1;
249 +         mutt_message _("Thread broken");
250 +
251 +         if (menu->menu == MENU_PAGER)
252 +         {
253 +           op = OP_DISPLAY_MESSAGE;
254 +           continue;
255 +         }
256 +         else
257 +           menu->redraw |= REDRAW_INDEX;
258 +       }
259 +
260 +         break;
261 +
262 +      case OP_MAIN_LINK_THREADS:
263 +
264 +       CHECK_MSGCOUNT;
265 +        CHECK_VISIBLE;
266 +       CHECK_READONLY;
267 +
268 +        if ((Sort & SORT_MASK) != SORT_THREADS)
269 +         mutt_error _("Threading is not enabled.");
270 +
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");
274 +#endif
275 +
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");
280 +       else 
281 +       {
282 +         HEADER *oldcur = CURHDR;
283 +
284 +         if (mutt_link_threads (CURHDR, tag ? NULL : Context->last_tag,
285 +                                Context))
286 +         {
287 +           mutt_sort_headers (Context, 1);
288 +           menu->current = oldcur->virtual;
289 +           
290 +           Context->changed = 1;
291 +           mutt_message _("Threads linked");
292 +         }
293 +         else
294 +           mutt_error _("No thread linked");
295 +       }
296 +
297 +       if (menu->menu == MENU_PAGER)
298 +       {
299 +         op = OP_DISPLAY_MESSAGE;
300 +         continue;
301 +       }
302 +       else
303 +         menu->redraw |= REDRAW_STATUS | REDRAW_INDEX;
304 +
305         break;
306  
307        case OP_EDIT_TYPE:
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.
314  
315 +<sect1>Editing threads
316 +<p>
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.
321 +
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.
324 +
325 +<sect2>Linking threads
326 +<p>
327 +
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
331 +threading.
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.
335 +
336 +You can also connect multiple childs at once, tagging them and using the
337 +tag-prefix command (';') or the auto_tag option.
338 +
339 +<sect2>Breaking threads
340 +<p>
341 +
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.
348 +
349  <sect1>Delivery Status Notification (DSN) Support
350  <p>
351 +
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[] = {
375  };
376  
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);
396  
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)
405        {
406         dprint (3, (debugfile, "imap_sync_mailbox: Attachments to be deleted, falling back to _mutt_save_message\n"));
407         if (!appendctx)
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)
412          "-USE_IMAP  "
413  #endif
414  
415 +#ifdef IMAP_EDIT_THREADS
416 +        "+IMAP_EDIT_THREADS  "
417 +#else
418 +        "-IMAP_EDIT_THREADS  "
419 +#endif
420 +
421  #ifdef USE_GSS
422         "+USE_GSS  "
423  #else
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
428  {
429    HEADER *h = ctx->hdrs[msgno];
430  
431 -  if (h->attach_del)
432 +  if (h->attach_del || h->refs_changed || h->irt_changed)
433      if (mh_rewrite_message (ctx, msgno) != 0)
434        return -1;
435  
436 @@ -1231,9 +1231,9 @@ static int maildir_sync_message (CONTEXT
437  {
438    HEADER *h = ctx->hdrs[msgno];
439  
440 -  if (h->attach_del)
441 +  if (h->attach_del || h->refs_changed || h->irt_changed)
442    {
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)
446        return (-1);
447    }
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
451 @@ -92,6 +92,8 @@
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: */
457  
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
461  
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 *);
466  
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;
480  
481 +#ifdef IMAP_EDIT_THREADS
482 +  ENVELOPE *new_env;   /* envelope information for rethreading */
483 +#endif
484 +
485  #ifdef MIXMASTER
486    LIST *chain;
487  #endif
488 @@ -752,6 +761,7 @@ typedef struct
489    char *pattern;                /* limit pattern string */
490    pattern_t *limit_pattern;     /* compiled limit pattern */
491    HEADER **hdrs;
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 *
500          ctx->deleted = 0;
501        }
502      }
503 +    else if (ctx->last_tag && ctx->last_tag->deleted)
504 +      ctx->last_tag = NULL; /* reset last tagged msg now useless */
505    }
506  
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);
512        case OP_TAG:
513         CHECK_MODE(IsHeader (extra));
514         mutt_set_flag (Context, extra->hdr, M_TAG, !extra->hdr->tagged);
515 +
516 +       Context->last_tag = extra->hdr->tagged ? extra->hdr :
517 +         ((Context->last_tag == extra->hdr && !extra->hdr->tagged)
518 +          ? NULL : Context->last_tag);
519 +
520         redraw = REDRAW_STATUS | REDRAW_INDEX;
521         if (option (OPTRESOLVE))
522         {
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)
546  
547    return hash;
548  }
549 +
550 +static void clean_references (THREAD *brk, THREAD *cur)
551 +{
552 +  THREAD *p;
553 +  LIST *ref = NULL;
554 +  int done = 0;
555 +
556 +  for (; cur; cur = cur->next, done = 0)
557 +  {
558 +    /* parse subthread recursively */
559 +    clean_references (brk, cur->child);
560 +
561 +    if (!cur->message)
562 +      break; /* skip pseudo-message */
563 +
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))
570 +       {
571 +         done = 1;
572 +         break;
573 +       }
574 +
575 +    if (done)
576 +    {
577 +      HEADER *h = cur->message;
578 +
579 +      /* clearing the References: header from obsolete Message-Id(s) */
580 +      mutt_free_list (&ref->next);
581 +
582 +#ifdef IMAP_EDIT_THREADS
583 +      if (h->new_env)
584 +       mutt_free_list (&h->new_env->references);
585 +      else
586 +       h->new_env = mutt_new_envelope ();
587 +
588 +      h->new_env->references = mutt_copy_list (h->env->references);
589 +#endif
590 +
591 +      h->refs_changed = h->changed = 1;
592 +    }
593 +  }
594 +}
595 +
596 +void mutt_break_thread (HEADER *hdr)
597 +{
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;
601 +
602 +#ifdef IMAP_EDIT_THREADS
603 +  if (hdr->new_env)
604 +  {
605 +    mutt_free_list (&hdr->new_env->in_reply_to);
606 +    mutt_free_list (&hdr->new_env->references);
607 +  }
608 +  else
609 +    hdr->new_env = mutt_new_envelope ();
610 +#endif
611 +
612 +  clean_references (hdr->thread, hdr->thread->child);
613 +}
614 +
615 +static int link_threads (HEADER *parent, HEADER *child, CONTEXT *ctx)
616 +{
617 +  if (child == parent)
618 +    return 0;
619 +
620 +  mutt_break_thread (child);
621 +
622 +  child->env->in_reply_to = mutt_new_list ();
623 +  child->env->in_reply_to->data = safe_strdup (parent->env->message_id);
624 +
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);
628 +#endif
629 +  
630 +  mutt_set_flag (ctx, child, M_TAG, 0);
631 +  
632 +  child->irt_changed = child->changed = 1;
633 +  return 1;
634 +}
635 +
636 +int mutt_link_threads (HEADER *cur, HEADER *last, CONTEXT *ctx)
637 +{
638 +  int i, changed = 0;
639 +
640 +  if (!last)
641 +  {
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);
645 +  }
646 +  else
647 +    changed = link_threads (cur, last, ctx);
648 +
649 +  return changed;
650 +}
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
654 @@ -1,0 +1 @@
655 +patch-1.5.5.1.cd.edit_threads.9.5
This page took 0.096241 seconds and 4 git commands to generate.