# HG changeset patch # User Fabian Groffen # Date 1279824714 -7200 # Branch gentoo-1.5.21 # Node ID e1d34b94943e57dd5af2c05d2883615d3120fa30 # Parent 380bee062403d436676ce409cba0811428cab2ca collapse_flagged from http://debian.lpr.ch/Mutt/ diff -r 380bee062403 -r e1d34b94943e PATCHES --- a/PATCHES Fri Dec 07 19:06:11 2012 +0100 +++ b/PATCHES Thu Jul 22 20:51:54 2010 +0200 @@ -0,0 +1,1 @@ +patch-1.5.4.lpr.collapse_flagged Lukas P. Ruf diff -r 380bee062403 -r e1d34b94943e curs_main.c --- a/curs_main.c Fri Dec 07 19:06:11 2012 +0100 +++ b/curs_main.c Thu Jul 22 20:51:54 2010 +0200 @@ -107,6 +107,11 @@ static const char *No_visible = N_("No v #define CURHDR Context->hdrs[Context->v2r[menu->current]] #define OLDHDR Context->hdrs[Context->v2r[menu->oldcurrent]] #define UNREAD(h) mutt_thread_contains_unread (Context, h) +#define FLAGGED(h) mutt_thread_contains_flagged (Context, h) + +#define CHECK_IF_TO_COLLAPSE(header) \ + ((option (OPTCOLLAPSEUNREAD) || !UNREAD (header)) && \ + (option (OPTCOLLAPSEFLAGGED) || FLAGGED(header) == 0)) extern size_t UngetCount; @@ -1727,14 +1732,14 @@ int mutt_index_menu (void) if (option (OPTUNCOLLAPSEJUMP)) menu->current = mutt_thread_next_unread (Context, CURHDR); } - else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) + else if CHECK_IF_TO_COLLAPSE(CURHDR) { menu->current = mutt_collapse_thread (Context, CURHDR); mutt_set_virtual (Context); } else { - mutt_error _("Thread contains unread messages."); + mutt_error _("Thread contains unread or flagged messages."); break; } @@ -1759,8 +1764,10 @@ int mutt_index_menu (void) if (CURHDR->collapsed) final = mutt_uncollapse_thread (Context, CURHDR); - else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (CURHDR)) + else if CHECK_IF_TO_COLLAPSE(CURHDR) + { final = mutt_collapse_thread (Context, CURHDR); + } else final = CURHDR->virtual; @@ -1778,9 +1785,11 @@ int mutt_index_menu (void) { if (h->collapsed) mutt_uncollapse_thread (Context, h); - else if (option (OPTCOLLAPSEUNREAD) || !UNREAD (h)) + else if CHECK_IF_TO_COLLAPSE(h) + { mutt_collapse_thread (Context, h); } + } top = top->next; } diff -r 380bee062403 -r e1d34b94943e init.h --- a/init.h Fri Dec 07 19:06:11 2012 +0100 +++ b/init.h Thu Jul 22 20:51:54 2010 +0200 @@ -389,6 +389,12 @@ struct option_t MuttVars[] = { ** When \fIunset\fP, Mutt will not collapse a thread if it contains any ** unread messages. */ + { "collapse_flagged", DT_BOOL, R_NONE, OPTCOLLAPSEFLAGGED, 1 }, + /* + ** .pp + ** When \fIunset\fP, Mutt will not collapse a thread if it contains any + ** flagged messages. + */ { "compose_format", DT_STR, R_BOTH, UL &ComposeFormat, UL "-- Mutt: Compose [Approx. msg size: %l Atts: %a]%>-" }, /* ** .pp diff -r 380bee062403 -r e1d34b94943e mutt.h --- a/mutt.h Fri Dec 07 19:06:11 2012 +0100 +++ b/mutt.h Thu Jul 22 20:51:54 2010 +0200 @@ -168,6 +168,7 @@ typedef enum #define M_THREAD_GET_HIDDEN (1<<2) #define M_THREAD_UNREAD (1<<3) #define M_THREAD_NEXT_UNREAD (1<<4) +#define M_THREAD_FLAGGED (1<<5) enum { @@ -329,6 +330,7 @@ enum OPTCHECKMBOXSIZE, OPTCHECKNEW, OPTCOLLAPSEUNREAD, + OPTCOLLAPSEFLAGGED, OPTCONFIRMAPPEND, OPTCONFIRMCREATE, OPTDELETEUNTAG, diff -r 380bee062403 -r e1d34b94943e protos.h --- a/protos.h Fri Dec 07 19:06:11 2012 +0100 +++ b/protos.h Thu Jul 22 20:51:54 2010 +0200 @@ -62,6 +62,7 @@ int _mutt_aside_thread (HEADER *, short, #define mutt_uncollapse_thread(x,y) _mutt_traverse_thread (x,y,M_THREAD_UNCOLLAPSE) #define mutt_get_hidden(x,y)_mutt_traverse_thread (x,y,M_THREAD_GET_HIDDEN) #define mutt_thread_contains_unread(x,y) _mutt_traverse_thread (x,y,M_THREAD_UNREAD) +#define mutt_thread_contains_flagged(x,y) _mutt_traverse_thread (x,y,M_THREAD_FLAGGED) #define mutt_thread_next_unread(x,y) _mutt_traverse_thread(x,y,M_THREAD_NEXT_UNREAD) int _mutt_traverse_thread (CONTEXT *ctx, HEADER *hdr, int flag); diff -r 380bee062403 -r e1d34b94943e thread.c --- a/thread.c Fri Dec 07 19:06:11 2012 +0100 +++ b/thread.c Thu Jul 22 20:51:54 2010 +0200 @@ -1129,7 +1129,7 @@ int _mutt_traverse_thread (CONTEXT *ctx, THREAD *thread, *top; HEADER *roothdr = NULL; int final, reverse = (Sort & SORT_REVERSE), minmsgno; - int num_hidden = 0, new = 0, old = 0; + int num_hidden = 0, new = 0, old = 0, flagged = 0; int min_unread_msgno = INT_MAX, min_unread = cur->virtual; #define CHECK_LIMIT (!ctx->pattern || cur->limited) @@ -1162,6 +1162,11 @@ int _mutt_traverse_thread (CONTEXT *ctx, } } + if (cur->flagged && CHECK_LIMIT) + { + flagged = 1; + } + if (cur->virtual == -1 && CHECK_LIMIT) num_hidden++; @@ -1188,6 +1193,8 @@ int _mutt_traverse_thread (CONTEXT *ctx, return (num_hidden); else if (flag & M_THREAD_NEXT_UNREAD) return (min_unread); + else if (flag & M_THREAD_FLAGGED) + return (flagged); } FOREVER @@ -1239,6 +1246,11 @@ int _mutt_traverse_thread (CONTEXT *ctx, } } + if (cur->flagged && CHECK_LIMIT) + { + flagged = 1; + } + if (cur->virtual == -1 && CHECK_LIMIT) num_hidden++; } @@ -1274,6 +1286,8 @@ int _mutt_traverse_thread (CONTEXT *ctx, return (num_hidden+1); else if (flag & M_THREAD_NEXT_UNREAD) return (min_unread); + else if (flag & M_THREAD_FLAGGED) + return (flagged); return (0); #undef CHECK_LIMIT