]> git.pld-linux.org Git - packages/mutt.git/blob - mutt-cd.trash_folder.patch
- new
[packages/mutt.git] / mutt-cd.trash_folder.patch
1 diff -pruN2 mutt-1.3.27.orig/commands.c mutt-1.3.27/commands.c
2 --- mutt-1.3.27.orig/commands.c Mon Dec  3 11:17:57 2001
3 +++ mutt-1.3.27/commands.c      Wed Jan 23 22:33:11 2002
4 @@ -616,9 +616,13 @@ void _mutt_save_message (HEADER *h, CONT
5      mutt_parse_mime_message (Context, h);
6  
7 -  if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0 && delete)
8 +  if (mutt_append_message (ctx, Context, h, cmflags, chflags) == 0)
9    {
10 -    mutt_set_flag (Context, h, M_DELETE, 1);
11 -    if (option (OPTDELETEUNTAG))
12 -      mutt_set_flag (Context, h, M_TAG, 0);
13 +    if (delete)
14 +    {
15 +      mutt_set_flag (Context, h, M_DELETE, 1);
16 +      if (option (OPTDELETEUNTAG))
17 +       mutt_set_flag (Context, h, M_TAG, 0);
18 +    }
19 +    mutt_set_flag (Context, h, M_APPENDED, 1);
20    }
21  }
22 diff -pruN2 mutt-1.3.27.orig/flags.c mutt-1.3.27/flags.c
23 --- mutt-1.3.27.orig/flags.c    Tue Jan 15 22:12:59 2002
24 +++ mutt-1.3.27/flags.c Wed Jan 23 22:33:11 2002
25 @@ -76,4 +76,15 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
26        break;
27  
28 +    case M_APPENDED:
29 +      if (bf)
30 +      {
31 +       if (!h->appended)
32 +       {
33 +         h->appended = 1;
34 +         if (upd_ctx) ctx->appended++;
35 +       }
36 +      }
37 +      break;
38 +
39      case M_NEW:
40        if (bf)
41 diff -pruN2 mutt-1.3.27.orig/globals.h mutt-1.3.27/globals.h
42 --- mutt-1.3.27.orig/globals.h  Thu Jan  3 21:56:46 2002
43 +++ mutt-1.3.27/globals.h       Wed Jan 23 22:33:11 2002
44 @@ -110,4 +110,5 @@ WHERE char *Status;
45  WHERE char *Tempdir;
46  WHERE char *Tochars;
47 +WHERE char *TrashPath;
48  WHERE char *Username;
49  WHERE char *Visual;
50 diff -pruN2 mutt-1.3.27.orig/init.h mutt-1.3.27/init.h
51 --- mutt-1.3.27.orig/init.h     Mon Dec 10 11:09:03 2001
52 +++ mutt-1.3.27/init.h  Wed Jan 23 22:33:11 2002
53 @@ -2236,4 +2236,11 @@ struct option_t MuttVars[] = {
54    ** was sent to a mailing-list you subscribe to (default: L).
55    */
56 +  { "trash",           DT_PATH, R_NONE, UL &TrashPath, 0 },
57 +  /*
58 +  ** .pp
59 +  ** If set, this variable specifies the path of the trash folder where the
60 +  ** mails marked for deletion will be moved, instead of being irremediably
61 +  ** purged.
62 +  */
63  #ifdef USE_SOCKET
64    { "tunnel",            DT_STR, R_NONE, UL &Tunnel, UL 0 },
65 diff -pruN2 mutt-1.3.27.orig/mutt.h mutt-1.3.27/mutt.h
66 --- mutt-1.3.27.orig/mutt.h     Tue Jan 15 22:00:32 2002
67 +++ mutt-1.3.27/mutt.h  Wed Jan 23 22:33:11 2002
68 @@ -185,4 +185,5 @@ enum
69    M_UNDELETE,
70    M_DELETED,
71 +  M_APPENDED,
72    M_FLAG,
73    M_TAG,
74 @@ -618,4 +619,5 @@ typedef struct header
75    unsigned int flagged : 1;            /* marked important? */
76    unsigned int tagged : 1;
77 +  unsigned int appended : 1; /* has been saved */
78    unsigned int deleted : 1;
79    unsigned int changed : 1;
80 @@ -740,4 +742,5 @@ typedef struct
81    int unread;                  /* how many unread messages? */
82    int deleted;                 /* how many deleted messages */
83 +  int appended;                 /* how many saved messages? */
84    int flagged;                 /* how many flagged messages */
85    int msgnotreadyet;           /* which msg "new" in pager, -1 if none */
86 diff -pruN2 mutt-1.3.27.orig/mx.c mutt-1.3.27/mx.c
87 --- mutt-1.3.27.orig/mx.c       Tue Jan 15 22:09:53 2002
88 +++ mutt-1.3.27/mx.c    Wed Jan 23 22:33:11 2002
89 @@ -816,4 +816,45 @@ static int sync_mailbox (CONTEXT *ctx, i
90  }
91  
92 +/* move deleted mails to the trash folder */
93 +static int trash_append (CONTEXT *ctx)
94 +{
95 +    CONTEXT *ctx_trash;
96 +    int i;
97 +    struct stat st, stc;
98 +
99 +    if (!TrashPath || !ctx->deleted)
100 +      return 0;
101 +
102 +    if (!mutt_save_confirm (TrashPath, &st))
103 +    {
104 +      mutt_error _("message(s) not deleted");
105 +      return -1;
106 +    }
107 +
108 +    if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino
109 +       && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
110 +      return 0;  /* we are in the trash folder: simple sync */
111 +
112 +    if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
113 +    {
114 +      for (i = 0 ; i < ctx->msgcount ; i++)
115 +       if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
116 +           && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1)
117 +         {
118 +           mx_close_mailbox (ctx_trash, NULL);
119 +           return -1;
120 +         }
121 +
122 +      mx_close_mailbox (ctx_trash, NULL);
123 +    }
124 +    else
125 +    {
126 +      mutt_error _("Can't open trash folder");
127 +      return -1;
128 +    }
129 +
130 +    return 0;
131 +}
132 +
133  /* save changes and close mailbox */
134  int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
135 @@ -999,9 +1040,17 @@ int mx_close_mailbox (CONTEXT *ctx, int 
136      if (ctx->changed || ctx->deleted)
137      {
138 -      if ((check = sync_mailbox (ctx, index_hint)) != 0)
139 +      int trsh = 0;
140 +
141 +      if ((!ctx->deleted || (trsh = trash_append (ctx)) == 0)
142 +       && (check = sync_mailbox (ctx, index_hint)) != 0)
143        {
144         ctx->closing = 0;
145         return check;
146        }
147 +      if (trsh != 0)
148 +      {
149 +       ctx->closing = 0;
150 +       return -1;
151 +      }
152      }
153    }
154 @@ -1174,6 +1223,10 @@ int mx_sync_mailbox (CONTEXT *ctx, int *
155      rc = imap_sync_mailbox (ctx, purge, index_hint);
156    else
157 -#endif
158 +#endif /* enter this block unconditionally if IMAP is not used */
159 +  {
160 +    if (trash_append (ctx) == -1)
161 +      return -1;
162      rc = sync_mailbox (ctx, index_hint);
163 +  }
164    if (rc == 0)
165    {
166 diff -pruN2 mutt-1.3.27.orig/postpone.c mutt-1.3.27/postpone.c
167 --- mutt-1.3.27.orig/postpone.c Mon Dec  3 11:17:57 2001
168 +++ mutt-1.3.27/postpone.c      Wed Jan 23 22:33:11 2002
169 @@ -271,4 +271,7 @@ int mutt_get_postponed (CONTEXT *ctx, HE
170    mutt_set_flag (PostContext, h, M_DELETE, 1);
171  
172 +  /* and consider it saved, so that it won't be moved to the trash folder */
173 +  mutt_set_flag (PostContext, h, M_APPENDED, 1);
174 +
175    /* update the count for the status display */
176    PostCount = PostContext->msgcount - PostContext->deleted;
177 diff -pruN mutt-1.3.27.orig/PATCHES mutt-1.3.27/PATCHES
178 --- mutt-1.3.27.orig/PATCHES    Mon Nov 26 20:16:52 2001
179 +++ mutt-1.3.27/PATCHES Thu Dec  6 16:27:55 2001
180 @@ -1,0 +1 @@
181 +patch-1.3.27.cd.trash_folder.1
This page took 0.041276 seconds and 3 git commands to generate.