]> granicus.if.org Git - mutt/commitdiff
patch.me.maildir_trash.1
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 21 Dec 2000 09:19:41 +0000 (09:19 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 21 Dec 2000 09:19:41 +0000 (09:19 +0000)
flags.c
init.h
mh.c
mutt.h

diff --git a/flags.c b/flags.c
index 879e739c44ec4c168ecfefc45657a399d416351b..60ae4c7e274fc6b0e4c6ed978c7e0cc5b956a162 100644 (file)
--- 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 a121748bbba236e9738a32b05e6c557e2f77ab5e..81e5e5ee999ad2491363726638ec7a018bd8c9c1 100644 (file)
--- 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 2d970d21287e505cadcb6e40c3b8a591ad081c9a..53463120c15b2e328237b9da9e70532050621d3d 100644 (file)
--- 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 e29e4a825b78ee89672937bcef27c87865e17fec..79451905f2ffbabeb883adba4092477aab467ca3 100644 (file)
--- 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 */