diff -urp ../MUTT/mutt/OPS mutt/OPS --- ../MUTT/mutt/OPS 2005-08-09 16:59:17.000000000 +0200 +++ mutt/OPS 2005-11-01 14:52:12.883851184 +0100 @@ -140,6 +140,7 @@ OP_PREV_ENTRY "move to the previous entr OP_PREV_LINE "scroll up one line" OP_PREV_PAGE "move to the previous page" OP_PRINT "print the current entry" +OP_PURGE_MESSAGE "really delete the current entry, bypassing the trash folder" OP_QUERY "query external program for addresses" OP_QUERY_APPEND "append new query results to current results" OP_QUIT "save changes to mailbox and quit" diff -urp ../MUTT/mutt/PATCHES mutt/PATCHES --- ../MUTT/mutt/PATCHES 2002-12-09 18:44:54.000000000 +0100 +++ mutt/PATCHES 2005-11-01 15:00:18.524022656 +0100 @@ -0,0 +1,3 @@ +patch-1.5.4.cd.trash_folder.3.3 +patch-1.5.4.cd.purge_message.3.3 +patch-1.5.11+CVS.cd+cb.trash_purge.3.3+cb diff -urp ../MUTT/mutt/commands.c mutt/commands.c --- ../MUTT/mutt/commands.c 2005-09-18 13:16:40.000000000 +0200 +++ mutt/commands.c 2005-11-01 14:52:47.721555048 +0100 @@ -690,6 +690,7 @@ int _mutt_save_message (HEADER *h, CONTE if (option (OPTDELETEUNTAG)) mutt_set_flag (Context, h, M_TAG, 0); } + mutt_set_flag (Context, h, M_APPENDED, 1); return 0; } diff -urp ../MUTT/mutt/curs_main.c mutt/curs_main.c --- ../MUTT/mutt/curs_main.c 2005-09-18 13:16:40.000000000 +0200 +++ mutt/curs_main.c 2005-11-01 14:52:12.885850880 +0100 @@ -1796,6 +1796,7 @@ CHECK_IMAP_ACL(IMAP_ACL_WRITE); MAYBE_REDRAW (menu->redraw); break; + case OP_PURGE_MESSAGE: case OP_DELETE: CHECK_MSGCOUNT; @@ -1809,6 +1810,7 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); if (tag) { mutt_tag_set_flag (M_DELETE, 1); + mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1); if (option (OPTDELETEUNTAG)) mutt_tag_set_flag (M_TAG, 0); menu->redraw = REDRAW_INDEX; @@ -1816,6 +1818,8 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); else { mutt_set_flag (Context, CURHDR, M_DELETE, 1); + mutt_set_flag (Context, CURHDR, M_PURGED, + (op != OP_PURGE_MESSAGE) ? 0 : 1); if (option (OPTDELETEUNTAG)) mutt_set_flag (Context, CURHDR, M_TAG, 0); if (option (OPTRESOLVE)) @@ -2108,11 +2112,13 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); if (tag) { mutt_tag_set_flag (M_DELETE, 0); + mutt_tag_set_flag (M_PURGED, 0); menu->redraw = REDRAW_INDEX; } else { mutt_set_flag (Context, CURHDR, M_DELETE, 0); + mutt_set_flag (Context, CURHDR, M_PURGED, 0); if (option (OPTRESOLVE) && menu->current < Context->vcount - 1) { menu->current++; @@ -2136,9 +2142,11 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); #endif rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0, - op == OP_UNDELETE_THREAD ? 0 : 1); + op == OP_UNDELETE_THREAD ? 0 : 1) + + mutt_thread_set_flag (CURHDR, M_PURGED, 0, + op == OP_UNDELETE_THREAD ? 0 : 1); - if (rc != -1) + if (rc > -1) { if (option (OPTRESOLVE)) { diff -urp ../MUTT/mutt/doc/manual.xml.head mutt/doc/manual.xml.head --- ../MUTT/mutt/doc/manual.xml.head 2005-09-17 22:46:11.000000000 +0200 +++ mutt/doc/manual.xml.head 2005-11-01 14:56:48.640929736 +0100 @@ -353,6 +353,22 @@ message is deleted (is marked for deleti +E + + +message will be purged (bypassing the trash folder) + + + + +$ + + +message is already saved (and will not move to the trash folder) + + + + d diff -urp ../MUTT/mutt/flags.c mutt/flags.c --- ../MUTT/mutt/flags.c 2005-09-18 13:16:40.000000000 +0200 +++ mutt/flags.c 2005-11-01 14:52:12.902848296 +0100 @@ -69,7 +69,13 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE else if (h->deleted) { h->deleted = 0; - if (upd_ctx) ctx->deleted--; + if (upd_ctx) + { + ctx->deleted--; + if (h->appended) + ctx->appended--; + } + h->appended = 0; /* when undeleting, also reset the appended flag */ #ifdef USE_IMAP /* see my comment above */ if (ctx->magic == M_IMAP) @@ -91,6 +97,27 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE } break; + case M_APPENDED: + if (bf) + { + if (!h->appended) + { + h->appended = 1; + if (upd_ctx) ctx->appended++; + } + } + break; + + case M_PURGED: + if (bf) + { + if (!h->purged) + h->purged = 1; + } + else if (h->purged) + h->purged = 0; + break; + case M_NEW: #ifdef USE_IMAP diff -urp ../MUTT/mutt/functions.h mutt/functions.h --- ../MUTT/mutt/functions.h 2005-09-18 13:16:40.000000000 +0200 +++ mutt/functions.h 2005-11-01 14:52:12.908847384 +0100 @@ -103,6 +103,7 @@ struct binding_t OpMain[] = { { "toggle-write", OP_TOGGLE_WRITE, "%" }, { "next-thread", OP_MAIN_NEXT_THREAD, "\016" }, { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" }, + { "purge-message", OP_PURGE_MESSAGE, NULL }, { "query", OP_QUERY, "Q" }, { "quit", OP_QUIT, "q" }, { "reply", OP_REPLY, "r" }, @@ -189,6 +190,7 @@ struct binding_t OpPager[] = { { "print-message", OP_PRINT, "p" }, { "previous-thread", OP_MAIN_PREV_THREAD, "\020" }, { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" }, + { "purge-message", OP_PURGE_MESSAGE, NULL }, { "quit", OP_QUIT, "Q" }, { "exit", OP_EXIT, "q" }, { "reply", OP_REPLY, "r" }, diff -urp ../MUTT/mutt/globals.h mutt/globals.h --- ../MUTT/mutt/globals.h 2005-09-18 13:16:40.000000000 +0200 +++ mutt/globals.h 2005-11-01 14:52:12.911846928 +0100 @@ -130,6 +130,7 @@ WHERE char *StChars; WHERE char *Status; WHERE char *Tempdir; WHERE char *Tochars; +WHERE char *TrashPath; WHERE char *Username; WHERE char *Visual; diff -urp ../MUTT/mutt/hdrline.c mutt/hdrline.c --- ../MUTT/mutt/hdrline.c 2005-09-18 13:16:40.000000000 +0200 +++ mutt/hdrline.c 2005-11-01 14:52:12.917846016 +0100 @@ -559,7 +559,9 @@ hdr_format_str (char *dest, break; case 'S': - if (hdr->deleted) + if (hdr->purged) + ch = 'E'; /* P is already used for PGP in %Z */ + else if (hdr->deleted) ch = 'D'; else if (hdr->attach_del) ch = 'd'; @@ -647,7 +649,11 @@ hdr_format_str (char *dest, "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' : ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno)) ? (hdr->replied ? 'r' : ' ') : (hdr->old ? 'O' : 'N')))), - hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch), + hdr->deleted ? /* deleted */ + (hdr->appended ? '$' : /* has been saved */ + hdr->purged ? 'E' : /* will be purged ('P' is used for PGP) */ + 'D') : /* will be moved to trash folder */ + hdr->attach_del ? 'd' : ch, hdr->tagged ? '*' : (hdr->flagged ? '!' : (Tochars && ((i = mutt_user_is_recipient (hdr)) < mutt_strlen (Tochars)) ? Tochars[i] : ' '))); diff -urp ../MUTT/mutt/imap/message.c mutt/imap/message.c --- ../MUTT/mutt/imap/message.c 2005-09-18 13:16:41.000000000 +0200 +++ mutt/imap/message.c 2005-11-01 14:52:12.923845104 +0100 @@ -766,6 +766,7 @@ int imap_copy_messages (CONTEXT* ctx, HE if (ctx->hdrs[n]->tagged) { mutt_set_flag (ctx, ctx->hdrs[n], M_DELETE, 1); + mutt_set_flag (ctx, ctx->hdrs[n], M_APPENDED, 1); if (option (OPTDELETEUNTAG)) mutt_set_flag (ctx, ctx->hdrs[n], M_TAG, 0); } @@ -773,6 +774,7 @@ int imap_copy_messages (CONTEXT* ctx, HE else { mutt_set_flag (ctx, h, M_DELETE, 1); + mutt_set_flag (ctx, h, M_APPENDED, 1); if (option (OPTDELETEUNTAG)) mutt_set_flag (ctx, h, M_TAG, 0); } diff -urp ../MUTT/mutt/init.h mutt/init.h --- ../MUTT/mutt/init.h 2005-09-18 13:16:40.000000000 +0200 +++ mutt/init.h 2005-11-01 14:52:12.930844040 +0100 @@ -985,7 +985,7 @@ struct option_t MuttVars[] = { ** .dt %O .dd (_O_riginal save folder) Where mutt would formerly have ** stashed the message: list name or recipient name if no list ** .dt %s .dd subject of the message - ** .dt %S .dd status of the message (N/D/d/!/r/\(as) + ** .dt %S .dd status of the message (N/D/E/$$$/d/!/r/\(as) ** .dt %t .dd `to:' field (recipients) ** .dt %T .dd the appropriate character from the $$to_chars string ** .dt %u .dd user (login) name of the author @@ -2757,6 +2757,16 @@ struct option_t MuttVars[] = { ** by \fIyou\fP. The sixth character is used to indicate when a mail ** was sent to a mailing-list you subscribe to (default: L). */ + { "trash", DT_PATH, R_NONE, UL &TrashPath, 0 }, + /* + ** .pp + ** If set, this variable specifies the path of the trash folder where the + ** mails marked for deletion will be moved, instead of being irremediably + ** purged. + ** .pp + ** NOTE: When you delete a message in the trash folder, it is really + ** deleted, so that you have a way to clean the trash. + */ #ifdef USE_SOCKET { "tunnel", DT_STR, R_NONE, UL &Tunnel, UL 0 }, /* diff -urp ../MUTT/mutt/mutt.h mutt/mutt.h --- ../MUTT/mutt/mutt.h 2005-09-18 13:16:40.000000000 +0200 +++ mutt/mutt.h 2005-11-01 14:52:12.938842824 +0100 @@ -198,6 +198,8 @@ enum M_DELETE, M_UNDELETE, M_DELETED, + M_APPENDED, /* was moved to trash folder */ + M_PURGED, /* bypass trash folder */ M_FLAG, M_TAG, M_UNTAG, @@ -692,6 +694,8 @@ typedef struct header unsigned int mime : 1; /* has a Mime-Version header? */ unsigned int flagged : 1; /* marked important? */ unsigned int tagged : 1; + unsigned int appended : 1; /* has been saved */ + unsigned int purged : 1; /* bypassing the trash folder */ unsigned int deleted : 1; unsigned int changed : 1; unsigned int attach_del : 1; /* has an attachment marked for deletion */ @@ -822,6 +826,7 @@ typedef struct int new; /* how many new messages? */ int unread; /* how many unread messages? */ int deleted; /* how many deleted messages */ + int appended; /* how many saved messages? */ int flagged; /* how many flagged messages */ int msgnotreadyet; /* which msg "new" in pager, -1 if none */ #if defined USE_POP || defined USE_IMAP diff -urp ../MUTT/mutt/muttlib.c mutt/muttlib.c --- ../MUTT/mutt/muttlib.c 2005-09-18 13:16:41.000000000 +0200 +++ mutt/muttlib.c 2005-11-01 14:55:18.629613536 +0100 @@ -1267,7 +1267,9 @@ int mutt_save_confirm (const char *s, st if (magic > 0 && !mx_access (s, W_OK)) { - if (option (OPTCONFIRMAPPEND)) + if (option (OPTCONFIRMAPPEND) && + (!TrashPath || (mutt_strcmp (s, TrashPath) != 0))) + /* if we're appending to the trash, there's no point in asking */ { snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s); if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO) diff -urp ../MUTT/mutt/mx.c mutt/mx.c --- ../MUTT/mutt/mx.c 2005-09-18 13:16:41.000000000 +0200 +++ mutt/mx.c 2005-11-01 14:52:12.954840392 +0100 @@ -819,6 +819,54 @@ static int sync_mailbox (CONTEXT *ctx, i return rc; } +/* move deleted mails to the trash folder */ +static int trash_append (CONTEXT *ctx) +{ + CONTEXT *ctx_trash; + int i = 0; + struct stat st, stc; + + if (!TrashPath || !ctx->deleted || + (ctx->magic == M_MAILDIR && option (OPTMAILDIRTRASH))) + return 0; + + for (;i < ctx->msgcount && (!ctx->hdrs[i]->deleted || + ctx->hdrs[i]->appended); i++); + if (i == ctx->msgcount) + return 0; /* nothing to be done */ + + if (mutt_save_confirm (TrashPath, &st) != 0) + { + mutt_error _("Could not move messages to trash folder."); + return -1; + } + + if (lstat (ctx->path, &stc) == 0 && stc.st_ino == st.st_ino + && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev) + return 0; /* we are in the trash folder: simple sync */ + + if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL) + { + for (i = 0 ; i < ctx->msgcount ; i++) + if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended + && !ctx->hdrs[i]->purged + && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1) + { + mx_close_mailbox (ctx_trash, NULL); + return -1; + } + + mx_close_mailbox (ctx_trash, NULL); + } + else + { + mutt_error _("Can't open trash folder"); + return -1; + } + + return 0; +} + /* save changes and close mailbox */ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) { @@ -958,6 +1006,7 @@ int mx_close_mailbox (CONTEXT *ctx, int if (mutt_append_message (&f, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN) == 0) { mutt_set_flag (ctx, ctx->hdrs[i], M_DELETE, 1); + mutt_set_flag (ctx, ctx->hdrs[i], M_APPENDED, 1); } else { @@ -979,6 +1028,14 @@ int mx_close_mailbox (CONTEXT *ctx, int return 0; } + /* copy mails to the trash before expunging */ + if (purge && ctx->deleted) + if (trash_append (ctx) != 0) + { + ctx->closing = 0; + return -1; + } + #ifdef USE_IMAP /* allow IMAP to preserve the deleted flag across sessions */ if (ctx->magic == M_IMAP) @@ -1174,6 +1231,12 @@ int mx_sync_mailbox (CONTEXT *ctx, int * msgcount = ctx->msgcount; deleted = ctx->deleted; + if (purge && ctx->deleted) + { + if (trash_append (ctx) == -1) + return -1; + } + #ifdef USE_IMAP if (ctx->magic == M_IMAP) rc = imap_sync_mailbox (ctx, purge, index_hint); diff -urp ../MUTT/mutt/pager.c mutt/pager.c --- ../MUTT/mutt/pager.c 2005-09-18 13:16:41.000000000 +0200 +++ mutt/pager.c 2005-11-01 14:52:12.965838720 +0100 @@ -2249,6 +2249,7 @@ search_next: MAYBE_REDRAW (redraw); break; + case OP_PURGE_MESSAGE: case OP_DELETE: CHECK_MODE(IsHeader (extra)); CHECK_READONLY; @@ -2258,6 +2259,8 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); #endif mutt_set_flag (Context, extra->hdr, M_DELETE, 1); + mutt_set_flag (Context, extra->hdr, M_PURGED, + ch != OP_PURGE_MESSAGE ? 0 : 1); if (option (OPTDELETEUNTAG)) mutt_set_flag (Context, extra->hdr, M_TAG, 0); redraw = REDRAW_STATUS | REDRAW_INDEX; @@ -2591,6 +2594,7 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); #endif mutt_set_flag (Context, extra->hdr, M_DELETE, 0); + mutt_set_flag (Context, extra->hdr, M_PURGED, 0); redraw = REDRAW_STATUS | REDRAW_INDEX; if (option (OPTRESOLVE)) { @@ -2609,9 +2613,11 @@ CHECK_IMAP_ACL(IMAP_ACL_DELETE); #endif r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0, + ch == OP_UNDELETE_THREAD ? 0 : 1) + + mutt_thread_set_flag (extra->hdr, M_PURGED, 0, ch == OP_UNDELETE_THREAD ? 0 : 1); - if (r != -1) + if (r > -1) { if (option (OPTRESOLVE)) { diff -urp ../MUTT/mutt/pattern.c mutt/pattern.c --- ../MUTT/mutt/pattern.c 2005-09-18 13:16:41.000000000 +0200 +++ mutt/pattern.c 2005-11-01 14:52:12.969838112 +0100 @@ -1245,8 +1245,10 @@ int mutt_pattern_func (int op, char *pro { switch (op) { - case M_DELETE: case M_UNDELETE: + mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED, + 0); + case M_DELETE: mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, (op == M_DELETE)); break; diff -urp ../MUTT/mutt/postpone.c mutt/postpone.c --- ../MUTT/mutt/postpone.c 2005-09-18 13:16:41.000000000 +0200 +++ mutt/postpone.c 2005-11-01 14:52:12.973837504 +0100 @@ -279,6 +279,9 @@ int mutt_get_postponed (CONTEXT *ctx, HE /* finished with this message, so delete it. */ mutt_set_flag (PostContext, h, M_DELETE, 1); + /* and consider it saved, so that it won't be moved to the trash folder */ + mutt_set_flag (PostContext, h, M_APPENDED, 1); + /* update the count for the status display */ PostCount = PostContext->msgcount - PostContext->deleted;