== END PATCH
--- a/commands.c
+++ b/commands.c
-@@ -688,6 +688,7 @@ int _mutt_save_message (HEADER *h, CONTE
+@@ -717,6 +717,7 @@
if (option (OPTDELETEUNTAG))
mutt_set_flag (Context, h, M_TAG, 0);
}
}
--- a/flags.c
+++ b/flags.c
-@@ -66,7 +66,13 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
- else if (h->deleted)
+@@ -65,7 +65,13 @@
{
h->deleted = 0;
+ update = 1;
- if (upd_ctx) ctx->deleted--;
+ if (upd_ctx)
+ {
#ifdef USE_IMAP
/* see my comment above */
if (ctx->magic == M_IMAP)
-@@ -88,6 +94,17 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
+@@ -87,6 +93,17 @@
}
break;
if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
--- a/globals.h
+++ b/globals.h
-@@ -142,6 +142,7 @@ WHERE char *StChars;
+@@ -139,6 +139,7 @@
WHERE char *Status;
WHERE char *Tempdir;
WHERE char *Tochars;
WHERE char *XtermTitle;
--- a/imap/message.c
+++ b/imap/message.c
-@@ -820,6 +820,7 @@ int imap_copy_messages (CONTEXT* ctx, HE
+@@ -876,6 +876,7 @@
if (ctx->hdrs[n]->tagged)
{
mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1);
if (option (OPTDELETEUNTAG))
mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0);
}
-@@ -827,6 +828,7 @@ int imap_copy_messages (CONTEXT* ctx, HE
+@@ -883,6 +884,7 @@
else
{
mutt_set_flag (ctx, h, M_DELETE, 1);
}
--- a/init.h
+++ b/init.h
-@@ -2862,6 +2862,16 @@ struct option_t MuttVars[] = {
+@@ -3195,6 +3195,16 @@
** by \fIyou\fP. The sixth character is used to indicate when a mail
- ** was sent to a mailing-list you subscribe to (default: L).
+ ** was sent to a mailing-list you subscribe to.
*/
+ { "trash", DT_PATH, R_NONE, UL &TrashPath, 0 },
+ /*
/*
--- a/mutt.h
+++ b/mutt.h
-@@ -201,6 +201,7 @@ enum
+@@ -187,6 +187,7 @@
M_DELETE,
M_UNDELETE,
M_DELETED,
M_FLAG,
M_TAG,
M_UNTAG,
-@@ -710,6 +711,7 @@ typedef struct header
+@@ -707,6 +708,7 @@
unsigned int mime : 1; /* has a MIME-Version header? */
unsigned int flagged : 1; /* marked important? */
unsigned int tagged : 1;
unsigned int deleted : 1;
unsigned int changed : 1;
unsigned int attach_del : 1; /* has an attachment marked for deletion */
-@@ -881,6 +883,7 @@ typedef struct _context
+@@ -879,6 +881,7 @@
int new; /* how many new messages? */
int unread; /* how many unread messages? */
int deleted; /* how many deleted messages */
--- a/muttlib.c
+++ b/muttlib.c
-@@ -1380,7 +1380,9 @@ int mutt_save_confirm (const char *s, st
+@@ -1515,7 +1515,9 @@
if (magic > 0 && !mx_access (s, W_OK))
{
if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
--- a/mx.c
+++ b/mx.c
-@@ -808,6 +808,53 @@ static int sync_mailbox (CONTEXT *ctx, i
+@@ -776,6 +776,53 @@
return rc;
}
/* save changes and close mailbox */
int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
{
-@@ -943,6 +990,7 @@ int mx_close_mailbox (CONTEXT *ctx, int
+@@ -912,6 +959,7 @@
if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0)
{
mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1);
}
else
{
-@@ -964,6 +1012,14 @@ int mx_close_mailbox (CONTEXT *ctx, int
+@@ -936,6 +984,14 @@
return 0;
}
+ /* copy mails to the trash before expunging */
-+ if (purge && ctx->deleted)
++ if (purge && ctx->deleted && mutt_strcmp(ctx->path, TrashPath))
+ if (trash_append (ctx) != 0)
+ {
+ ctx->closing = 0;
#ifdef USE_IMAP
/* allow IMAP to preserve the deleted flag across sessions */
if (ctx->magic == M_IMAP)
-@@ -1159,6 +1215,12 @@ int mx_sync_mailbox (CONTEXT *ctx, int *
+@@ -1133,6 +1189,12 @@
msgcount = ctx->msgcount;
deleted = ctx->deleted;
-+ if (purge && ctx->deleted)
++ if (purge && ctx->deleted && mutt_strcmp(ctx->path, TrashPath))
+ {
+ if (trash_append (ctx) == -1)
+ return -1;
-+ }
++ }
+
#ifdef USE_IMAP
if (ctx->magic == M_IMAP)
rc = imap_sync_mailbox (ctx, purge, index_hint);
--- a/postpone.c
+++ b/postpone.c
-@@ -279,6 +279,9 @@ int mutt_get_postponed (CONTEXT *ctx, HE
+@@ -277,6 +277,9 @@
/* finished with this message, so delete it. */
mutt_set_flag (PostContext, h, M_DELETE, 1);
/* update the count for the status display */
PostCount = PostContext->msgcount - PostContext->deleted;
---- a/PATCHES
-+++ b/PATCHES
-@@ -1,3 +1,4 @@
-+patch-1.5.13.cd.trash_folder.3.4
- patch-1.5.13.nt+ab.xtitles.4
- patch-1.5.6.dw.maildir-mtime.1
- patch-1.5.13.cd.ifdef.2