Here is the patch. I wrote this back in 2006 and haven't looked at it since then. I am sure if fixes the problem for the mbox format (that is what I use) and some other mailboxes, but I am not 100% sure I attempted to change the code for Maildir formats.
Since it is so old the patch only patches sucessfully against the stable version. Maybe I will look at how to bring it up todate if people think it will be a nice feature to have. Yours, Nick On Thu, Feb 18, 2010 at 11:17:57PM -0500, Jean-Luc Wasmer wrote: > I'm using the Maildir format... > > Do you know why it happens: > - everytime when I set the deletion flag with Mutt > - once in a while when the deletion flag was set before opening the folder > with Mutt? > > Can you send me the patch? Thanks! > > Jean-Luc > > On Thu, Feb 18, 2010 at 05:55:00PM -0600, Nicholas Longo wrote: > > Hi this is "expected" behavior for certain mailboxes. So a possible > > work around is to switch the mailbox type you use. At some point I > > submitted a patch for this behavior which created an option > > "save_dflag" for which could be set to save deletion flags on mbox > > style mailboxes. > > > > Maybe we could try again to get this patch (or something like it) into the > > source. > > > > Yours, > > Nick > > > > PS Sorry if your getting this twice Jean-Luc, I wanted to send one > > copy to mutt-users. > > > > > > On Thu, Feb 18, 2010 at 06:02:28PM -0500, Jean-Luc Wasmer wrote: > > > > > Hi, > > > > > > If I set one or more messages with the deletion flag, and answer "no" to > > > the purge confirmation, Mutt undeletes the messages when leaving the > > > folder. > > > > > > Is this an expected behavior? > > > > > > Once in a while, Mutt will undelete messages that already had the > > > deletion flag set (before entering the folder). This also happens when > > > leaving the folder and answering "no" to the purge confirmation. This is > > > really annoying since I have the deletion flag set by procmail based on > > > spam rules and Mutt clears them (I usually have over a hundred deleted > > > email in some folders, I only purge after some time). > > > > > > Thanks for your help! > > > Jean-Luc
Index: PATCHES =================================================================== RCS file: /home/roessler/cvs/mutt/PATCHES,v retrieving revision 3.6 diff -u -r3.6 PATCHES --- PATCHES 9 Dec 2002 17:44:54 -0000 3.6 +++ PATCHES 14 Mar 2006 16:10:15 -0000 @@ -0,0 +1 @@ +patch-cvs.nl.save_dflag.1 \ No newline at end of file Index: copy.c =================================================================== RCS file: /home/roessler/cvs/mutt/copy.c,v retrieving revision 3.27 diff -u -r3.27 copy.c --- copy.c 21 Oct 2005 04:35:37 -0000 3.27 +++ copy.c 14 Mar 2006 16:10:15 -0000 @@ -444,7 +444,7 @@ return (-1); } - if (h->flagged || h->replied) + if (h->flagged || h->replied || h->deleted) { if (fputs ("X-Status: ", out) == EOF) return (-1); @@ -460,6 +460,12 @@ if (fputc ('F', out) == EOF) return (-1); } + + if (h->deleted && option (OPTSAVEDFLAG)) + { + if (fputc ('D', out) == EOF) + return (-1); + } if (fputc ('\n', out) == EOF) return (-1); Index: init.h =================================================================== RCS file: /home/roessler/cvs/mutt/init.h,v retrieving revision 3.95 diff -u -r3.95 init.h --- init.h 9 Jan 2006 19:43:58 -0000 3.95 +++ init.h 14 Mar 2006 16:10:15 -0000 @@ -2921,6 +2921,14 @@ ** messages to be sent. Exim users may wish to unset this. */ /*--*/ + { "save_dflag", DT_BOOL, R_NONE, OPTSAVEDFLAG, 0}, + /* + ** .pp + ** Controls whether mutt writes out a D in the X-Status when + ** synchronizing mbox mailboxes. + */ + /*--*/ + { NULL } }; Index: mbox.c =================================================================== RCS file: /home/roessler/cvs/mutt/mbox.c,v retrieving revision 3.11 diff -u -r3.11 mbox.c --- mbox.c 21 Oct 2005 04:35:37 -0000 3.11 +++ mbox.c 14 Mar 2006 16:10:15 -0000 @@ -667,7 +667,7 @@ * 0 success * -1 failure */ -int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) +int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint, int purge) { char tempfile[_POSIX_PATH_MAX]; char buf[32]; @@ -785,7 +785,7 @@ oldOffset[i-first].lines = ctx->hdrs[i]->lines; oldOffset[i-first].length = ctx->hdrs[i]->content->length; - if (! ctx->hdrs[i]->deleted) + if (! (ctx->hdrs[i]->deleted && purge) ) { j++; if (!ctx->quiet && WriteInc && ((i % WriteInc) == 0 || j == 1)) Index: mutt.h =================================================================== RCS file: /home/roessler/cvs/mutt/mutt.h,v retrieving revision 3.63 diff -u -r3.63 mutt.h --- mutt.h 9 Jan 2006 19:43:59 -0000 3.63 +++ mutt.h 14 Mar 2006 16:10:15 -0000 @@ -508,7 +508,8 @@ OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */ OPTUNBUFFEREDINPUT, /* (pseudo) don't use key buffer */ - OPTMAX + OPTMAX, + OPTSAVEDFLAG }; #define mutt_bit_alloc(n) calloc ((n + 7) / 8, sizeof (char)) Index: mx.c =================================================================== RCS file: /home/roessler/cvs/mutt/mx.c,v retrieving revision 3.25 diff -u -r3.25 mx.c --- mx.c 19 Dec 2005 17:22:46 -0000 3.25 +++ mx.c 14 Mar 2006 16:10:16 -0000 @@ -768,7 +768,7 @@ } /* save changes to disk */ -static int sync_mailbox (CONTEXT *ctx, int *index_hint) +static int sync_mailbox (CONTEXT *ctx, int *index_hint, int purge) { #ifdef BUFFY_SIZE BUFFY *tmp = NULL; @@ -782,7 +782,7 @@ { case M_MBOX: case M_MMDF: - rc = mbox_sync_mailbox (ctx, index_hint); + rc = mbox_sync_mailbox (ctx, index_hint, purge); #ifdef BUFFY_SIZE tmp = mutt_find_mailbox (ctx->path); #endif @@ -988,7 +988,7 @@ else #endif { - if (!purge) + if (!purge && !option (OPTSAVEDFLAG)) { for (i = 0; i < ctx->msgcount; i++) ctx->hdrs[i]->deleted = 0; @@ -997,7 +997,7 @@ if (ctx->changed || ctx->deleted) { - if ((check = sync_mailbox (ctx, index_hint)) != 0) + if ((check = sync_mailbox (ctx, index_hint, purge)) != 0) { ctx->closing = 0; return check; @@ -1006,12 +1006,19 @@ } if (move_messages) - mutt_message (_("%d kept, %d moved, %d deleted."), - ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted); + if (purge) + mutt_message (_("%d kept, %d moved, %d deleted."), + ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted); + else + mutt_message (_("%d kept, %d moved, %d deleted."), + ctx->msgcount, read_msgs, 0); else - mutt_message (_("%d kept, %d deleted."), - ctx->msgcount - ctx->deleted, ctx->deleted); - + if (purge) + mutt_message (_("%d kept, %d deleted."), + ctx->msgcount - ctx->deleted, ctx->deleted); + else + mutt_message (_("%d kept, %d deleted."), + ctx->msgcount, 0); if (ctx->msgcount == ctx->deleted && (ctx->magic == M_MMDF || ctx->magic == M_MBOX) && !mutt_is_spool(ctx->path) && !option (OPTSAVEEMPTY)) @@ -1175,7 +1182,7 @@ rc = imap_sync_mailbox (ctx, purge, index_hint); else #endif - rc = sync_mailbox (ctx, index_hint); + rc = sync_mailbox (ctx, index_hint, purge); if (rc == 0) { #ifdef USE_IMAP Index: mx.h =================================================================== RCS file: /home/roessler/cvs/mutt/mx.h,v retrieving revision 3.7 diff -u -r3.7 mx.h --- mx.h 17 Sep 2005 20:46:10 -0000 3.7 +++ mx.h 14 Mar 2006 16:10:16 -0000 @@ -47,7 +47,7 @@ #define MMDF_SEP "\001\001\001\001\n" #define MAXLOCKATTEMPT 5 -int mbox_sync_mailbox (CONTEXT *, int *); +int mbox_sync_mailbox (CONTEXT *, int *, int); int mbox_open_mailbox (CONTEXT *); int mbox_check_mailbox (CONTEXT *, int *); int mbox_close_mailbox (CONTEXT *);