From: Thomas Roessler Date: Thu, 21 Dec 2000 09:19:41 +0000 (+0000) Subject: patch.me.maildir_trash.1 X-Git-Tag: mutt-1-3-13-rel~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=99c394e8cd4d2079b5b8d6ca001336dd9974ac75;p=mutt patch.me.maildir_trash.1 --- diff --git a/flags.c b/flags.c index 879e739c..60ae4c7e 100644 --- a/flags.c +++ b/flags.c @@ -38,6 +38,17 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) if (!h->deleted) { h->deleted = 1; + if (ctx->magic == M_MAILDIR && option(OPTMAILDIRTRASH)) + { + /* As with the IMAP comment below, we need to mark the + * message and mailbox as changed, because deleting a message + * just changes its status on disk without actually deleting + * it. Without this, the 'T' flag would never get set when + * the maildir box is synched. + */ + h->changed = 1; + if (upd_ctx) ctx->changed = 1; + } if (upd_ctx) ctx->deleted++; #ifdef USE_IMAP /* deleted messages aren't treated as changed elsewhere so that the @@ -54,6 +65,17 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx) { h->deleted = 0; if (upd_ctx) ctx->deleted--; + if (ctx->magic == M_MAILDIR && option(OPTMAILDIRTRASH)) + { + /* As with the IMAP comment below, we need to mark the + * message and mailbox as changed, because deleting a message + * just changes its status on disk without actually deleting + * it. Without this, the 'T' flag would never get set when + * the maildir box is synched. + */ + h->changed = 1; + if (upd_ctx) ctx->changed = 1; + } #ifdef USE_IMAP /* see my comment above */ if (ctx->magic == M_IMAP) diff --git a/init.h b/init.h index a121748b..81e5e5ee 100644 --- a/init.h +++ b/init.h @@ -859,6 +859,14 @@ struct option_t MuttVars[] = { ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE ** DOING!\fP */ + { "maildir_trash", DT_BOOL, R_NONE, OPTMAILDIRTRASH, 0 }, + /* + ** .pp + ** If set, messages marked as deleted will be saved with the maildir + ** (T)rashed flag instead of unlinked. \fBNOTE:\fP this only applies + ** to maildir-style mailboxes. Setting it will have no effect on other + ** mailbox types. + */ { "mark_old", DT_BOOL, R_BOTH, OPTMARKOLD, 1 }, /* ** .pp diff --git a/mh.c b/mh.c index 2d970d21..53463120 100644 --- a/mh.c +++ b/mh.c @@ -105,6 +105,11 @@ static void maildir_parse_flags(HEADER *h, const char *path) h->replied = 1; break; + + case 'T': /* trashed */ + + h->deleted = 1; + break; } p++; } @@ -377,13 +382,14 @@ static void maildir_flags (char *dest, size_t destlen, HEADER *hdr) { *dest = '\0'; - if (hdr && (hdr->flagged || hdr->replied || hdr->read)) + if (hdr && (hdr->flagged || hdr->replied || hdr->read || hdr->deleted)) { snprintf (dest, destlen, - ":2,%s%s%s", + ":2,%s%s%s%s", hdr->flagged ? "F" : "", hdr->replied ? "R" : "", - hdr->read ? "S" : ""); + hdr->read ? "S" : "", + hdr->deleted ? "T" : ""); } } @@ -736,7 +742,7 @@ int mh_sync_mailbox (CONTEXT * ctx, int *index_hint) for (i = 0; i < ctx->msgcount; i++) { - if (ctx->hdrs[i]->deleted) + if (ctx->hdrs[i]->deleted && (ctx->magic != M_MAILDIR || !option(OPTMAILDIRTRASH))) { snprintf (path, sizeof (path), "%s/%s", ctx->path, ctx->hdrs[i]->path); if (ctx->magic == M_MAILDIR || (option (OPTMHPURGE) && ctx->magic == M_MH)) diff --git a/mutt.h b/mutt.h index e29e4a82..79451905 100644 --- a/mutt.h +++ b/mutt.h @@ -331,6 +331,7 @@ enum #endif OPTIMPLICITAUTOVIEW, OPTMAILCAPSANITIZE, + OPTMAILDIRTRASH, OPTMARKERS, OPTMARKOLD, OPTMENUSCROLL, /* scroll menu instead of implicit next-page */