: Patch by Aaron Schrab : http://pug.schrab.com/aaron/mutt/ This patch turns the $mark_old variable into a quad option that controls only whether or not 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. diff -pur mutt-1.3.28/PATCHES mutt-ats/PATCHES --- mutt-1.3.28/PATCHES Mon Nov 26 13:16:52 2001 +++ mutt-ats/PATCHES Mon Mar 18 22:23:44 2002 @@ -1,0 +1 @@ +patch-1.3.28.ats.mark_old.1 diff -pur mutt-1.3.28/buffy.c mutt-ats/buffy.c --- mutt-1.3.28/buffy.c Wed Oct 10 05:34:11 2001 +++ mutt-ats/buffy.c Mon Mar 18 22:23:44 2002 @@ -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); diff -pur mutt-1.3.28/curs_main.c mutt-ats/curs_main.c --- mutt-1.3.28/curs_main.c Wed Jan 16 14:44:25 2002 +++ mutt-ats/curs_main.c Mon Mar 18 22:23:44 2002 @@ -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); diff -pur mutt-1.3.28/flags.c mutt-ats/flags.c --- mutt-1.3.28/flags.c Tue Jan 15 15:18:11 2002 +++ mutt-ats/flags.c Mon Mar 18 22:23:44 2002 @@ -78,7 +78,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++; @@ -304,6 +304,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 diff -pur mutt-1.3.28/hdrline.c mutt-ats/hdrline.c --- mutt-1.3.28/hdrline.c Mon Dec 17 04:05:33 2001 +++ mutt-ats/hdrline.c Mon Mar 18 22:23:44 2002 @@ -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 ? '!' : diff -pur mutt-1.3.28/imap/message.c mutt-ats/imap/message.c --- mutt-1.3.28/imap/message.c Thu Feb 28 01:58:47 2002 +++ mutt-ats/imap/message.c Mon Mar 18 22:23:44 2002 @@ -944,7 +944,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++; } diff -pur mutt-1.3.28/init.h mutt-ats/init.h --- mutt-1.3.28/init.h Thu Feb 28 02:24:13 2002 +++ mutt-ats/init.h Mon Mar 18 22:23:44 2002 @@ -955,16 +955,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 }, /* @@ -1876,6 +1877,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 }, /* diff -pur mutt-1.3.28/mh.c mutt-ats/mh.c --- mutt-1.3.28/mh.c Tue Jan 15 15:18:11 2002 +++ mutt-ats/mh.c Mon Mar 18 22:25:36 2002 @@ -648,7 +648,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)); diff -pur mutt-1.3.28/mutt.h mutt-ats/mutt.h --- mutt-1.3.28/mutt.h Thu Feb 28 02:24:13 2002 +++ mutt-ats/mutt.h Mon Mar 18 22:23:44 2002 @@ -265,6 +265,7 @@ enum OPT_PRINT, OPT_INCLUDE, OPT_DELETE, + OPT_MARKOLD, OPT_MFUPTO, OPT_MIMEFWD, OPT_MOVE, @@ -361,7 +362,6 @@ enum OPTMAILCAPSANITIZE, OPTMAILDIRTRASH, OPTMARKERS, - OPTMARKOLD, OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ OPTMETAKEY, /* interpret ALT-x as ESC-x */ OPTMETOO, @@ -388,6 +388,7 @@ enum OPTSAVEEMPTY, OPTSAVENAME, OPTSCORE, + OPTSEEOLD, OPTSIGDASHES, OPTSIGONTOP, OPTSORTRE, diff -pur mutt-1.3.28/mx.c mutt-ats/mx.c --- mutt-1.3.28/mx.c Thu Feb 28 01:58:47 2002 +++ mutt-ats/mx.c Mon Mar 18 22:23:44 2002 @@ -816,7 +816,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; @@ -849,6 +849,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) @@ -878,6 +880,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); + } + /* * There is no point in asking whether or not to purge if we are * just marking messages as "trash". @@ -898,7 +908,7 @@ 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++) { diff -pur mutt-1.3.28/pager.c mutt-ats/pager.c --- mutt-1.3.28/pager.c Sun Jan 13 02:52:15 2002 +++ mutt-ats/pager.c Mon Mar 18 22:23:44 2002 @@ -2446,7 +2446,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); diff -pur mutt-1.3.28/parse.c mutt-ats/parse.c --- mutt-1.3.28/parse.c Tue Jan 29 04:05:20 2002 +++ mutt-ats/parse.c Mon Mar 18 22:23:44 2002 @@ -1151,8 +1151,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; diff -pur mutt-1.3.28/pattern.c mutt-ats/pattern.c --- mutt-1.3.28/pattern.c Tue Jan 15 03:03:33 2002 +++ mutt-ats/pattern.c Mon Mar 18 22:23:44 2002 @@ -981,13 +981,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: diff -pur mutt-1.3.28/status.c mutt-ats/status.c --- mutt-1.3.28/status.c Fri Mar 3 04:10:14 2000 +++ mutt-ats/status.c Mon Mar 18 22:23:44 2002 @@ -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; diff -pur mutt-1.3.28/thread.c mutt-ats/thread.c --- mutt-1.3.28/thread.c Thu Feb 28 02:24:13 2002 +++ mutt-ats/thread.c Mon Mar 18 22:23:44 2002 @@ -1133,7 +1133,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; @@ -1210,7 +1210,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;