summarylogtreecommitdiffstats
path: root/collapse-flagged.patch
blob: 1527a085897a30d4bced7756f52aa4fc0a5d5707 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# HG changeset patch
# User Fabian Groffen <grobian@gentoo.org>
# 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 <lukas.ruf@lpr.ch>
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