<<< Date Index >>>     <<< Thread Index >>>

[PATCH] debian bug #275060 mutt: doesn't preserve a set flag (~F) when editing message



http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=275060
IMAP and mbox problems were reported to the debian BTS.
And I sent two patches. Attached.
I remember that I tested them for myself with 1.5.6.

-- 
tamo
--- imap/message.c.orig Sun Dec 19 19:35:57 2004
+++ imap/message.c      Sun Dec 19 20:07:30 2004
@@ -518,6 +518,8 @@
   char buf[LONG_STRING];
   char mbox[LONG_STRING];
   char mailbox[LONG_STRING]; 
+  char replied[11] = " \\Answered";
+  char flagged[10] = " \\Flagged";
   size_t len;
   int c, last;
   IMAP_MBOX mx;
@@ -552,7 +554,11 @@
   rewind (fp);
   
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
-  snprintf (buf, sizeof (buf), "APPEND %s (\\Seen) {%lu}", mbox, (unsigned 
long)len);
+  if (!msg->flags.replied)
+    replied[0] = '\0';
+  if (!msg->flags.flagged)
+    flagged[0] = '\0';
+  snprintf (buf, sizeof (buf), "APPEND %s (\\Seen%s%s) {%lu}", mbox, replied, 
flagged, (unsigned long)len);
 
   imap_cmd_start (idata, buf);
 
--- editmsg.c.nostatus  Sun Dec 19 21:23:45 2004
+++ editmsg.c   Sun Dec 19 22:37:23 2004
@@ -75,7 +75,10 @@
     return -1;
   }
 
-  rc = mutt_append_message (&tmpctx, ctx, cur, 0, CH_NOLEN | CH_NOSTATUS); 
oerrno = errno;
+  cf = CH_NOLEN | CH_NOSTATUS;
+  if (ctx->magic == M_MBOX || ctx->magic == M_MMDF)
+     cf ^= CH_NOSTATUS; /* needs X-Status for flags */
+  rc = mutt_append_message (&tmpctx, ctx, cur, 0, cf); oerrno = errno;
 
   mx_close_mailbox (&tmpctx, NULL);
 
@@ -133,7 +136,10 @@
       cf = CH_FROM | CH_FORCE_FROM;
   }
   else
+  {
     of = M_ADD_FROM;
+    cf = CH_NOSTATUS;
+  }
 
   /* 
    * XXX - we have to play games with the message flags to avoid
@@ -153,7 +159,7 @@
     goto bail;
   }
 
-  if ((rc = mutt_copy_hdr (fp, msg->fp, 0, sb.st_size, CH_NOSTATUS | CH_NOLEN 
| cf, NULL)) == 0)
+  if ((rc = mutt_copy_hdr (fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL)) 
== 0)
   {
     fputc ('\n', msg->fp);
     rc = mutt_copy_stream (fp, msg->fp);