I'd be interested to hear if the attached patch would be suitable for inclusion. It adds a new option 'mark_read' that marks all messages as read when exiting a mailbox. If 'move' is enabled, they will then be moved out of the mailbox as well.
I used to do this via a combination of macros but that gets cumbersome when enabling it selectively only for a subset of folders, so I finally turned it into an option. Robin -- Robin Sommer * ICSI/LBNL * ro...@icir.org * www.icir.org/robin
diff -ur mutt-1.7.0/PATCHES mutt-1.7.0-patched/PATCHES --- mutt-1.7.0/PATCHES 2016-08-10 18:47:00.000000000 -0700 +++ mutt-1.7.0-patched/PATCHES 2016-09-10 14:52:24.000000000 -0700 @@ -0,0 +1 @@ +patch-1.7.0.rs.mark_read.1 diff -ur mutt-1.7.0/init.h mutt-1.7.0-patched/init.h --- mutt-1.7.0/init.h 2016-08-10 18:47:00.000000000 -0700 +++ mutt-1.7.0-patched/init.h 2016-09-10 13:49:25.000000000 -0700 @@ -1487,6 +1487,14 @@ ** will show up with an ``O'' next to them in the index menu, ** indicating that they are old. */ + { "mark_read", DT_BOOL, R_BOTH, OPTMARKREAD, 0 }, + /* + ** .pp + ** Controls whether or not mutt marks \fIunread\fP + ** messages as \fIread\fP if you exit a mailbox without reading them. + ** With this option \fIset\fP, the affected mails will then + ** be moved out of your spool mailbox if $$move is enabled. + */ { "markers", DT_BOOL, R_PAGER, OPTMARKERS, 1 }, /* ** .pp diff -ur mutt-1.7.0/mutt.h mutt-1.7.0-patched/mutt.h --- mutt-1.7.0/mutt.h 2016-08-10 18:47:00.000000000 -0700 +++ mutt-1.7.0-patched/mutt.h 2016-09-10 13:45:55.000000000 -0700 @@ -395,6 +395,7 @@ OPTMAILDIRCHECKCUR, OPTMARKERS, OPTMARKOLD, + OPTMARKREAD, OPTMENUSCROLL, /* scroll menu instead of implicit next-page */ OPTMENUMOVEOFF, /* allow menu to scroll past last entry */ #if defined(USE_IMAP) || defined(USE_POP) diff -ur mutt-1.7.0/mx.c mutt-1.7.0-patched/mx.c --- mutt-1.7.0/mx.c 2016-08-10 18:47:00.000000000 -0700 +++ mutt-1.7.0-patched/mx.c 2016-09-10 15:15:30.000000000 -0700 @@ -810,6 +810,15 @@ return 0; } + if (option (OPTMARKREAD)) + { + for (i = 0; i < ctx->msgcount; i++) + { + if (!ctx->hdrs[i]->read) + mutt_set_flag (ctx, ctx->hdrs[i], MUTT_READ, 1); + } + } + for (i = 0; i < ctx->msgcount; i++) { if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->read