]> granicus.if.org Git - mutt/commitdiff
patch-1.3.25.tlr.maildir_trash.1
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 15 Jan 2002 21:18:11 +0000 (21:18 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 15 Jan 2002 21:18:11 +0000 (21:18 +0000)
flags.c
mh.c
mutt.h
mx.c

diff --git a/flags.c b/flags.c
index a231eca0eb833c2c38bd2f88b7c683ae68584014..9f51c6f45d7642dfb0953c2c44a843a4bbb433ec 100644 (file)
--- a/flags.c
+++ b/flags.c
@@ -38,17 +38,6 @@ 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
@@ -65,17 +54,6 @@ 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) 
@@ -84,6 +62,16 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
          if (upd_ctx) ctx->changed = 1;
        }
 #endif
+       /* 
+        * If the user undeletes a message which is marked as
+        * "trash" in the maildir folder on disk, the folder has
+        * been changed, and is marked accordingly.  However, we do
+        * _not_ mark the message itself changed, because trashing
+        * is checked in specific code in the maildir folder
+        * driver. 
+        */
+       if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
+         ctx->changed = 1;
       }
       break;
 
diff --git a/mh.c b/mh.c
index 7385f5d675508c4ef0937b6be31f529b28400caa..281b4c6113c5e1c15785424e521c0a8c8f60b11b 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -96,6 +96,10 @@ static short mhs_set (struct mh_sequences *mhs, int i, short f)
   return mhs->flags[i];
 }
 
+#if 0
+
+/* unused */
+
 static short mhs_unset (struct mh_sequences *mhs, int i, short f)
 {
   mhs_alloc (mhs, i);
@@ -103,6 +107,8 @@ static short mhs_unset (struct mh_sequences *mhs, int i, short f)
   return mhs->flags[i];
 }
 
+#endif
+
 static void mh_read_token (char *t, int *first, int *last)
 {
   char *p;
@@ -504,7 +510,7 @@ static void maildir_parse_flags(HEADER *h, const char *path)
        break;
 
        case 'T': /* trashed */
-
+       h->trash   = 1;
        h->deleted = 1;
        break;
       }
@@ -1137,6 +1143,9 @@ static int maildir_sync_message (CONTEXT *ctx, int msgno)
       /* message hasn't really changed */
       return 0;
     }
+
+    /* record that the message is possibly marked as trashed on disk */
+    h->trash = h->deleted;
     
     if (rename (oldpath, fullpath) != 0)
     {
@@ -1175,7 +1184,9 @@ int mh_sync_mailbox (CONTEXT * ctx, int *index_hint)
          
       }
     }
-    else if (ctx->hdrs[i]->changed || ctx->hdrs[i]->attach_del)
+    else if (ctx->hdrs[i]->changed || ctx->hdrs[i]->attach_del ||
+            (ctx->magic == M_MAILDIR  && (option (OPTMAILDIRTRASH) || ctx->hdrs[i]->trash) 
+             && (ctx->hdrs[i]->deleted != ctx->hdrs[i]->trash)))
     {
       if (ctx->magic == M_MAILDIR)
       {
diff --git a/mutt.h b/mutt.h
index 9e48aca7083e9db6a7d51a2adb6a334f76653fe7..6c2eb4ffa5646764831ba54c95d322db96aebfa7 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -614,22 +614,26 @@ typedef struct header
   unsigned int pgp : 4;
 #endif
 
-  unsigned int mime : 1;    /* has a Mime-Version header? */
-  unsigned int flagged : 1; /* marked important? */
+  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 */
+  unsigned int attach_del : 1;                 /* has an attachment marked for deletion */
   unsigned int old : 1;
   unsigned int read : 1;
-  unsigned int expired : 1; /* already expired? */
-  unsigned int superseded : 1; /* got superseded? */
+  unsigned int expired : 1;            /* already expired? */
+  unsigned int superseded : 1;                 /* got superseded? */
   unsigned int replied : 1;
-  unsigned int subject_changed : 1; /* used for threading */
-  unsigned int threaded : 1;       /* used for threading */
-  unsigned int display_subject : 1; /* used for threading */
-  unsigned int recip_valid : 1;  /* is_recipient is valid */
-  unsigned int active : 1;         /* message is not to be removed */
+  unsigned int subject_changed : 1;    /* used for threading */
+  unsigned int threaded : 1;           /* used for threading */
+  unsigned int display_subject : 1;    /* used for threading */
+  unsigned int recip_valid : 1;        /* is_recipient is valid */
+  unsigned int active : 1;             /* message is not to be removed */
+  unsigned int trash : 1;              /* message is marked as trashed on disk.
+                                        * This flag is used by the maildir_trash
+                                        * option.
+                                        */
   
   /* timezone of the sender of this message */
   unsigned int zhours : 5;
@@ -641,27 +645,27 @@ typedef struct header
   unsigned int matched : 1;
 
   /* the following are used to support collapsing threads  */
-  unsigned int collapsed : 1; /* is this message part of a collapsed thread? */
-  unsigned int limited : 1;   /* is this message in a limited view?  */
-  size_t num_hidden;          /* number of hidden messages in this view */
+  unsigned int collapsed : 1;  /* is this message part of a collapsed thread? */
+  unsigned int limited : 1;    /* is this message in a limited view?  */
+  size_t num_hidden;           /* number of hidden messages in this view */
 
-  short recipient;     /* user_is_recipient()'s return value, cached */
+  short recipient;             /* user_is_recipient()'s return value, cached */
   
-  int pair; /* color-pair to use when displaying in the index */
-
-  time_t date_sent;     /* time when the message was sent (UTC) */
-  time_t received;      /* time when the message was placed in the mailbox */
-  long offset;          /* where in the stream does this message begin? */
-  int lines;           /* how many lines in the body of this message? */
-  int index;           /* the absolute (unsorted) message number */
-  int msgno;           /* number displayed to the user */
-  int virtual;         /* virtual message number */
+  int pair;                    /* color-pair to use when displaying in the index */
+
+  time_t date_sent;            /* time when the message was sent (UTC) */
+  time_t received;             /* time when the message was placed in the mailbox */
+  long offset;                 /* where in the stream does this message begin? */
+  int lines;                   /* how many lines in the body of this message? */
+  int index;                   /* the absolute (unsorted) message number */
+  int msgno;                   /* number displayed to the user */
+  int virtual;                 /* virtual message number */
   int score;
-  ENVELOPE *env;       /* envelope information */
-  BODY *content;       /* list of MIME parts */
+  ENVELOPE *env;               /* envelope information */
+  BODY *content;               /* list of MIME parts */
   char *path;
   
-  char *tree;            /* character string to print thread tree */
+  char *tree;                  /* character string to print thread tree */
   struct thread *thread;
 
 #ifdef MIXMASTER
@@ -669,11 +673,11 @@ typedef struct header
 #endif
 
 #ifdef USE_POP
-  int refno;           /* message number on server */
+  int refno;                   /* message number on server */
 #endif
 
 #if defined USE_POP || defined USE_IMAP
-  void *data;            /* driver-specific data */
+  void *data;                  /* driver-specific data */
 #endif
 } HEADER;
 
diff --git a/mx.c b/mx.c
index f0631f48832acf1dd6bad7101b82b7a53d9a70e4..ce2147da1a7a19788cecabc2f8e340d69ecdae72 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -880,7 +880,11 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     }
   }
 
-  if (ctx->deleted)
+  /* 
+   * There is no point in asking whether or not to purge if we are
+   * just marking messages as "trash".
+   */
+  if (ctx->deleted && !(ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH)))
   {
     snprintf (buf, sizeof (buf), ctx->deleted == 1
             ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"),