: Patch by Aaron Schrab : http://pug.schrab.com/aaron/mutt/ With this patch, turns the $mark_old variable into a quad option that controls only whether mutt will automatically mark new messages when you leave a folder. The other part of this variable is moved to $see_old. Also, with this patch changing the value of $see_old takes effect immediately, not only when changing folders. --- PATCHES~ Tue Nov 6 19:59:33 2001 +++ PATCHES Tue Nov 6 19:59:42 2001 @@ -1,0 +1 @@ +patch-1.3.24.ats.mark_old.1 Index: buffy.c =================================================================== RCS file: /home/roessler/cvs/mutt/buffy.c,v retrieving revision 2.21 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.21 buffy.c --- buffy.c 2001/10/10 10:34:11 2.21 +++ buffy.c 2001/12/31 07:41:02 @@ -100,7 +100,7 @@ int test_last_status_new (FILE * f) hdr = mutt_new_header (); mutt_read_rfc822_header (f, hdr, 0, 0); - if (!(hdr->read || hdr->old)) + if (!(hdr->read || (option(OPTSEEOLD) && hdr->old))) result = 1; mutt_free_header (&hdr); Index: curs_main.c =================================================================== RCS file: /home/roessler/cvs/mutt/curs_main.c,v retrieving revision 2.72 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.72 curs_main.c --- curs_main.c 2001/11/08 08:56:48 2.72 +++ curs_main.c 2001/12/31 07:41:03 @@ -210,7 +210,7 @@ static int ci_first_message (void) if (! Context->hdrs[Context->v2r[i]]->read && ! Context->hdrs[Context->v2r[i]]->deleted) { - if (! Context->hdrs[Context->v2r[i]]->old) + if (! (option(OPTSEEOLD) && Context->hdrs[Context->v2r[i]]->old)) return (i); else if (old == -1) old = i; @@ -1295,7 +1295,8 @@ int mutt_index_menu (void) } else if ((!CURHDRi->deleted && !CURHDRi->read)) { - if (op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD || !CURHDRi->old) + if (op == OP_MAIN_NEXT_UNREAD || op == OP_MAIN_PREV_UNREAD || + !(option(OPTSEEOLD) && CURHDRi->old)) { menu->current = i; break; @@ -1375,7 +1376,7 @@ int mutt_index_menu (void) if (Context->hdrs[Context->v2r[j]]->tagged) { if (Context->hdrs[Context->v2r[j]]->read || - Context->hdrs[Context->v2r[j]]->old) + (option(OPTSEEOLD) && Context->hdrs[Context->v2r[j]]->old)) mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_NEW, 1); else mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], M_READ, 1); @@ -1385,7 +1386,7 @@ int mutt_index_menu (void) } else { - if (CURHDR->read || CURHDR->old) + if (CURHDR->read || (option(OPTSEEOLD) && CURHDR->old)) mutt_set_flag (Context, CURHDR, M_NEW, 1); else mutt_set_flag (Context, CURHDR, M_READ, 1); Index: flags.c =================================================================== RCS file: /home/roessler/cvs/mutt/flags.c,v retrieving revision 2.8 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.8 flags.c --- flags.c 2001/10/31 09:20:38 2.8 +++ flags.c 2001/12/31 07:41:03 @@ -90,7 +90,7 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE case M_NEW: if (bf) { - if (h->read || h->old) + if (h->read || (option(OPTSEEOLD) && h->old)) { h->old = 0; if (upd_ctx) ctx->new++; @@ -316,6 +316,11 @@ int mutt_change_flag (HEADER *h, int bf) case 'o': case 'O': + if (!option(OPTSEEOLD)) { + mutt_error _("Set $see_old first"); + return (-1); + } + if (h) mutt_set_flag (Context, h, M_READ, !bf); else Index: hdrline.c =================================================================== RCS file: /home/roessler/cvs/mutt/hdrline.c,v retrieving revision 2.27 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.27 hdrline.c --- hdrline.c 2001/12/17 10:05:33 2.27 +++ hdrline.c 2001/12/31 07:41:03 @@ -555,7 +555,7 @@ hdr_format_str (char *dest, ch = 'r'; else if (hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno)) ch = '-'; - else if (hdr->old) + else if (option(OPTSEEOLD) && hdr->old) ch = 'O'; else ch = 'N'; @@ -632,7 +632,8 @@ hdr_format_str (char *dest, snprintf (buf2, sizeof (buf2), "%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' : ((hdr->read && (ctx && ctx->msgnotreadyet != hdr->msgno)) - ? (hdr->replied ? 'r' : ' ') : (hdr->old ? 'O' : 'N')))), + ? (hdr->replied ? 'r' : ' ') : + ((option(OPTSEEOLD) && hdr->old) ? 'O' : 'N')))), hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch), hdr->tagged ? '*' : (hdr->flagged ? '!' : Index: init.h =================================================================== RCS file: /home/roessler/cvs/mutt/init.h,v retrieving revision 2.143 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.143 init.h --- init.h 2001/12/10 10:09:22 2.143 +++ init.h 2001/12/31 07:41:06 @@ -934,16 +934,17 @@ struct option_t MuttVars[] = { ** to maildir-style mailboxes. Setting it will have no effect on other ** mailbox types. */ - { "mark_old", DT_BOOL, R_BOTH, OPTMARKOLD, 1 }, + { "mark_old", DT_QUAD, R_NONE, OPT_MARKOLD, M_YES }, /* ** .pp - ** Controls whether or not Mutt makes the distinction between \fInew\fP - ** messages and \fIold\fP \fBunread\fP messages. By default, Mutt will - ** mark new messages as old if you exit a mailbox without reading them. - ** The next time you start Mutt, the messages will show up with an "O" - ** next to them in the index menu, indicating that they are old. In - ** order to make Mutt treat all unread messages as new only, you can - ** unset this variable. + ** When set, Mutt will mark new messages as old if you exit a mailbox + ** without reading them. If not set messages will remain new until they + ** are read or the \fInew\fP flag is explicitly removed. Set this variable + ** to ask-yes or ask-no to decide when leaving a folder. Also see the + ** ``$$see_old'' variable. + ** .pp + ** \fBThis variable does not apply to IMAP folders, these always act as if + ** this variable is set to yes. */ { "markers", DT_BOOL, R_PAGER, OPTMARKERS, 1 }, /* @@ -1855,6 +1856,13 @@ struct option_t MuttVars[] = { ** ``$$record'' mailbox. ** .pp ** Also see the ``$$force_name'' variable. + */ + { "see_old", DT_BOOL, R_BOTH, OPTSEEOLD, 1 }, + /* + ** .pp + ** Controls whether or not Mutt makes the distinction between \fInew\fP + ** messages and \fIold\fP \fBunread\fP messages. In order to make Mutt + ** treat all unread messages as new only, you can unset this variable. */ { "score", DT_BOOL, R_NONE, OPTSCORE, 1 }, /* Index: mh.c =================================================================== RCS file: /home/roessler/cvs/mutt/mh.c,v retrieving revision 2.41 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.41 mh.c --- mh.c 2001/11/09 09:28:55 2.41 +++ mh.c 2001/12/31 07:41:06 @@ -642,7 +642,7 @@ static int maildir_parse_dir(CONTEXT *ct if(subdir) { snprintf(buf, sizeof(buf), "%s/%s", ctx->path, subdir); - is_old = (mutt_strcmp("cur", subdir) == 0) && option(OPTMARKOLD); + is_old = (mutt_strcmp("cur", subdir) == 0); } else strfcpy(buf, ctx->path, sizeof(buf)); Index: mutt.h =================================================================== RCS file: /home/roessler/cvs/mutt/mutt.h,v retrieving revision 2.109 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.109 mutt.h --- mutt.h 2001/12/13 12:10:59 2.109 +++ mutt.h 2001/12/31 07:41:07 @@ -264,6 +264,7 @@ enum OPT_PRINT, OPT_INCLUDE, OPT_DELETE, + OPT_MARKOLD, OPT_MFUPTO, OPT_MIMEFWD, OPT_MOVE, @@ -357,7 +358,6 @@ enum OPTMAILCAPSANITIZE, OPTMAILDIRTRASH, OPTMARKERS, - OPTMARKOLD, OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ OPTMETAKEY, /* interpret ALT-x as ESC-x */ OPTMETOO, @@ -384,6 +384,7 @@ enum OPTSAVEEMPTY, OPTSAVENAME, OPTSCORE, + OPTSEEOLD, OPTSIGDASHES, OPTSIGONTOP, OPTSORTRE, Index: mx.c =================================================================== RCS file: /home/roessler/cvs/mutt/mx.c,v retrieving revision 2.61 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.61 mx.c --- mx.c 2001/12/03 13:31:02 2.61 +++ mx.c 2001/12/31 07:41:08 @@ -818,7 +818,7 @@ static int sync_mailbox (CONTEXT *ctx, i /* save changes and close mailbox */ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) { - int i, move_messages = 0, purge = 1, read_msgs = 0; + int i, move_messages = 0, purge = 1, mark_old = 1, read_msgs = 0, new_msgs = 0; int check; int isSpool = 0; CONTEXT f; @@ -851,6 +851,8 @@ int mx_close_mailbox (CONTEXT *ctx, int if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read && !(ctx->hdrs[i]->flagged && option (OPTKEEPFLAGGED))) read_msgs++; + if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old) + new_msgs++; } if (read_msgs && quadoption (OPT_MOVE) != M_NO) @@ -880,6 +882,14 @@ int mx_close_mailbox (CONTEXT *ctx, int } } + if (new_msgs) + { + snprintf (buf, sizeof (buf), new_msgs == 1 + ? _("Mark new message as old?") : _("Mark new messages as old?")); + if ((mark_old = query_quadoption (OPT_MARKOLD, buf)) < 0) + return (-1); + } + if (ctx->deleted) { snprintf (buf, sizeof (buf), ctx->deleted == 1 @@ -896,7 +906,8 @@ int mx_close_mailbox (CONTEXT *ctx, int /* IMAP servers manage the OLD flag themselves */ if (ctx->magic != M_IMAP) #endif - if (option (OPTMARKOLD)) + + if (mark_old) { for (i = 0; i < ctx->msgcount; i++) { Index: pager.c =================================================================== RCS file: /home/roessler/cvs/mutt/pager.c,v retrieving revision 2.45 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.45 pager.c --- pager.c 2001/12/21 00:22:12 2.45 +++ pager.c 2001/12/31 07:41:09 @@ -2441,7 +2441,7 @@ mutt_pager (const char *banner, const ch case OP_TOGGLE_NEW: CHECK_MODE(IsHeader (extra)); CHECK_READONLY; - if (extra->hdr->read || extra->hdr->old) + if (extra->hdr->read || (option(OPTSEEOLD) && extra->hdr->old)) mutt_set_flag (Context, extra->hdr, M_NEW, 1); else if (!first) mutt_set_flag (Context, extra->hdr, M_READ, 1); Index: parse.c =================================================================== RCS file: /home/roessler/cvs/mutt/parse.c,v retrieving revision 2.39 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.39 parse.c --- parse.c 2001/10/31 09:20:38 2.39 +++ parse.c 2001/12/31 07:41:10 @@ -1149,8 +1149,7 @@ int mutt_parse_rfc822_line (ENVELOPE *e, hdr->replied = 1; break; case 'O': - if (option (OPTMARKOLD)) - hdr->old = 1; + hdr->old = 1; break; case 'R': hdr->read = 1; Index: pattern.c =================================================================== RCS file: /home/roessler/cvs/mutt/pattern.c,v retrieving revision 2.21 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.21 pattern.c --- pattern.c 2001/04/26 13:36:34 2.21 +++ pattern.c 2001/12/31 07:41:11 @@ -980,13 +980,14 @@ mutt_pattern_exec (struct pattern_t *pat case M_TAG: return (pat->not ^ h->tagged); case M_NEW: - return (pat->not ? h->old || h->read : !(h->old || h->read)); + return (pat->not ^ !((option(OPTSEEOLD) && h->old) || h->read)); case M_UNREAD: return (pat->not ? h->read : !h->read); case M_REPLIED: return (pat->not ^ h->replied); case M_OLD: - return (pat->not ? (!h->old || h->read) : (h->old && !h->read)); + return (pat->not ? (!(option(OPTSEEOLD) && h->old) || h->read) : + ((option(OPTSEEOLD) && h->old) && !h->read)); case M_READ: return (pat->not ^ h->read); case M_DELETED: Index: status.c =================================================================== RCS file: /home/roessler/cvs/mutt/status.c,v retrieving revision 2.6 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.6 status.c --- status.c 2000/03/03 10:10:14 2.6 +++ status.c 2001/12/31 07:41:11 @@ -159,9 +159,11 @@ status_format_str (char *buf, size_t buf if (!optional) { snprintf (fmt, sizeof (fmt), "%%%sd", prefix); - snprintf (buf, buflen, fmt, Context ? Context->new : 0); + snprintf (buf, buflen, fmt, Context ? + (option(OPTSEEOLD) ? Context->new : Context->unread) : 0); } - else if (!Context || !Context->new) + else if (!Context || + !(option(OPTSEEOLD) ? Context->new : Context->unread)) optional = 0; break; @@ -169,9 +171,11 @@ status_format_str (char *buf, size_t buf if (!optional) { snprintf (fmt, sizeof (fmt), "%%%sd", prefix); - snprintf (buf, buflen, fmt, Context ? Context->unread - Context->new : 0); + snprintf (buf, buflen, fmt, (Context && option(OPTSEEOLD)) ? + Context->unread - Context->new : 0); } - else if (!Context || !(Context->unread - Context->new)) + else if (!Context || !option(OPTSEEOLD) || + !(Context->unread - Context->new)) optional = 0; break; Index: thread.c =================================================================== RCS file: /home/roessler/cvs/mutt/thread.c,v retrieving revision 2.26 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r2.26 thread.c --- thread.c 2001/12/17 10:05:35 2.26 +++ thread.c 2001/12/31 07:41:11 @@ -1058,7 +1058,7 @@ int _mutt_traverse_thread (CONTEXT *ctx, if (!cur->read && CHECK_LIMIT) { - if (cur->old) + if (option(OPTSEEOLD) && cur->old) old = 2; else new = 1; @@ -1135,7 +1135,7 @@ int _mutt_traverse_thread (CONTEXT *ctx, if (!cur->read && CHECK_LIMIT) { - if (cur->old) + if (option(OPTSEEOLD) && cur->old) old = 2; else new = 1; Index: imap/message.c =================================================================== RCS file: /home/roessler/cvs/mutt/imap/message.c,v retrieving revision 1.59 diff -p -u -I$\(Author\|Date\|Header\|Id\|Locker\|Log\|Name\|RCSfile\|Revision\|Source\|State\)[:$] -r1.59 message.c --- imap/message.c 2001/10/31 09:20:40 1.59 +++ imap/message.c 2001/12/31 07:41:12 @@ -949,7 +949,7 @@ static char* msg_parse_flags (IMAP_HEADE if (*s == ')') { /* if a message is neither seen nor recent, it is OLD. */ - if (option (OPTMARKOLD) && !recent && !(h->read)) + if (!recent && !(h->read)) h->old = 1; s++; }