summarylogtreecommitdiffstats
path: root/purge-message.patch
blob: a042dd03c678891275f71e541c9c0d08a53fb722 (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
From: Cedric Duval <cedricduval@free.fr>
Date: Thu, 27 Feb 2014 14:21:59 +0100
Subject: purge-message

(requires trash folder patch)

This patch adds the purge-message function, which, unlike delete-message,
will bypass the trash folder and really delete the mail.

You can bind this function to <esc>D, for instance, by adding the following
lines to your muttrc:

bind index \eD purge-message
bind pager \eD purge-message

Please be very careful with this function, and try to use it as less as
possible. The risk resides in getting into the habit of always using
purge-message instead of delete-message, which would really defeat the
purpose of having a trash folder feature.

* Patch last synced with upstream:
  - Date: 2007-02-15
  - File: http://cedricduval.free.fr/mutt/patches/download/patch-1.5.5.1.cd.purge_message.3.4

* Changes made:
  - Updated to 1.5.13
  - Fixed indentation of "purged" in mutt.h.

Signed-off-by: Matteo F. Vescovi <mfvescovi@gmail.com>

Gbp-Pq: Topic features
---
 OPS         |  1 +
 curs_main.c | 12 ++++++++++--
 flags.c     | 10 ++++++++++
 functions.h |  2 ++
 mutt.h      |  2 ++
 mx.c        |  1 +
 pager.c     |  8 +++++++-
 pattern.c   |  4 +++-
 8 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/OPS b/OPS
index 8414a8b..02cea8e 100644
--- a/OPS
+++ b/OPS
@@ -142,6 +142,7 @@ OP_PREV_ENTRY "move to the previous entry"
 OP_PREV_LINE "scroll up one line"
 OP_PREV_PAGE "move to the previous page"
 OP_PRINT "print the current entry"
+OP_PURGE_MESSAGE "really delete the current entry, bypassing the trash folder"
 OP_QUERY "query external program for addresses"
 OP_QUERY_APPEND "append new query results to current results"
 OP_QUIT "save changes to mailbox and quit"
diff --git a/curs_main.c b/curs_main.c
index 8553102..1de79f3 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -1908,6 +1908,7 @@ int mutt_index_menu (void)
 	MAYBE_REDRAW (menu->redraw);
 	break;
 
+      case OP_PURGE_MESSAGE:
       case OP_DELETE:
 
 	CHECK_MSGCOUNT;
@@ -1918,6 +1919,7 @@ int mutt_index_menu (void)
 	if (tag)
 	{
 	  mutt_tag_set_flag (M_DELETE, 1);
+	  mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
 	  if (option (OPTDELETEUNTAG))
 	    mutt_tag_set_flag (M_TAG, 0);
 	  menu->redraw = REDRAW_INDEX;
@@ -1925,6 +1927,8 @@ int mutt_index_menu (void)
 	else
 	{
 	  mutt_set_flag (Context, CURHDR, M_DELETE, 1);
+	  mutt_set_flag (Context, CURHDR, M_PURGED,
+			 (op != OP_PURGE_MESSAGE) ? 0 : 1);
 	  if (option (OPTDELETEUNTAG))
 	    mutt_set_flag (Context, CURHDR, M_TAG, 0);
 	  if (option (OPTRESOLVE))
@@ -2226,11 +2230,13 @@ int mutt_index_menu (void)
 	if (tag)
 	{
 	  mutt_tag_set_flag (M_DELETE, 0);
+	  mutt_tag_set_flag (M_PURGED, 0);
 	  menu->redraw = REDRAW_INDEX;
 	}
 	else
 	{
 	  mutt_set_flag (Context, CURHDR, M_DELETE, 0);
+	  mutt_set_flag (Context, CURHDR, M_PURGED, 0);
 	  if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
 	  {
 	    menu->current++;
@@ -2251,9 +2257,11 @@ int mutt_index_menu (void)
 	CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
 
 	rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
-				   op == OP_UNDELETE_THREAD ? 0 : 1);
+				   op == OP_UNDELETE_THREAD ? 0 : 1)
+	  + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
+				  op == OP_UNDELETE_THREAD ? 0 : 1);
 
-	if (rc != -1)
+	if (rc > -1)
 	{
 	  if (option (OPTRESOLVE))
 	  {
diff --git a/flags.c b/flags.c
index dfa6a50..5309bb7 100644
--- a/flags.c
+++ b/flags.c
@@ -104,6 +104,16 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
       }
       break;
 
+    case M_PURGED:
+      if (bf)
+      {
+	if (!h->purged)
+	  h->purged = 1;
+      }
+      else if (h->purged)
+	h->purged = 0;
+      break;
+
     case M_NEW:
 
       if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
diff --git a/functions.h b/functions.h
index 7a1c5a9..a29388c 100644
--- a/functions.h
+++ b/functions.h
@@ -121,6 +121,7 @@ const struct binding_t OpMain[] = { /* map: index */
   { "toggle-write",		OP_TOGGLE_WRITE,		"%" },
   { "next-thread",		OP_MAIN_NEXT_THREAD,		"\016" },
   { "next-subthread",		OP_MAIN_NEXT_SUBTHREAD,		"\033n" },
+  { "purge-message",		OP_PURGE_MESSAGE,		NULL },
   { "query",			OP_QUERY,			"Q" },
   { "quit",			OP_QUIT,			"q" },
   { "reply",			OP_REPLY,			"r" },
@@ -213,6 +214,7 @@ const struct binding_t OpPager[] = { /* map: pager */
   { "print-message",	OP_PRINT,			"p" },
   { "previous-thread",	OP_MAIN_PREV_THREAD,		"\020" },
   { "previous-subthread",OP_MAIN_PREV_SUBTHREAD,	"\033p" },
+  { "purge-message",	OP_PURGE_MESSAGE,		NULL },
   { "quit",		OP_QUIT,			"Q" },
   { "exit",		OP_EXIT,			"q" },
   { "reply",		OP_REPLY,			"r" },
diff --git a/mutt.h b/mutt.h
index 29bb6c2..ef41afd 100644
--- a/mutt.h
+++ b/mutt.h
@@ -186,6 +186,7 @@ enum
   M_UNDELETE,
   M_DELETED,
   M_APPENDED,
+  M_PURGED,
   M_FLAG,
   M_TAG,
   M_UNTAG,
@@ -715,6 +716,7 @@ typedef struct header
   unsigned int flagged : 1; 		/* marked important? */
   unsigned int tagged : 1;
   unsigned int appended : 1;		/* has been saved */
+  unsigned int purged : 1;		/* bypassing the trash folder */
   unsigned int deleted : 1;
   unsigned int changed : 1;
   unsigned int attach_del : 1; 		/* has an attachment marked for deletion */
diff --git a/mx.c b/mx.c
index c0a6d30..15c0a6b 100644
--- a/mx.c
+++ b/mx.c
@@ -806,6 +806,7 @@ static int trash_append (CONTEXT *ctx)
     {
       for (i = 0 ; i < ctx->msgcount ; i++)
 	if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
+	    && !ctx->hdrs[i]->purged
 	    && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1)
 	  {
 	    mx_close_mailbox (ctx_trash, NULL);
diff --git a/pager.c b/pager.c
index 4f7e7be..0994274 100644
--- a/pager.c
+++ b/pager.c
@@ -2350,12 +2350,15 @@ search_next:
 	MAYBE_REDRAW (redraw);
 	break;
 
+      case OP_PURGE_MESSAGE:
       case OP_DELETE:
 	CHECK_MODE(IsHeader (extra));
 	CHECK_READONLY;
 	CHECK_ACL(M_ACL_DELETE, _("delete message"));
 
 	mutt_set_flag (Context, extra->hdr, M_DELETE, 1);
+	mutt_set_flag (Context, extra->hdr, M_PURGED,
+		       ch != OP_PURGE_MESSAGE ? 0 : 1);
         if (option (OPTDELETEUNTAG))
 	  mutt_set_flag (Context, extra->hdr, M_TAG, 0);
 	redraw = REDRAW_STATUS | REDRAW_INDEX;
@@ -2682,6 +2685,7 @@ search_next:
 	CHECK_ACL(M_ACL_DELETE, _("undelete message"));
 
 	mutt_set_flag (Context, extra->hdr, M_DELETE, 0);
+	mutt_set_flag (Context, extra->hdr, M_PURGED, 0);
 	redraw = REDRAW_STATUS | REDRAW_INDEX;
 	if (option (OPTRESOLVE))
 	{
@@ -2697,9 +2701,11 @@ search_next:
 	CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
 
 	r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0,
+				  ch == OP_UNDELETE_THREAD ? 0 : 1)
+	  + mutt_thread_set_flag (extra->hdr, M_PURGED, 0,
 				  ch == OP_UNDELETE_THREAD ? 0 : 1);
 
-	if (r != -1)
+	if (r > -1)
 	{
 	  if (option (OPTRESOLVE))
 	  {
diff --git a/pattern.c b/pattern.c
index 7af1c38..4cdbd05 100644
--- a/pattern.c
+++ b/pattern.c
@@ -1358,8 +1358,10 @@ int mutt_pattern_func (int op, char *prompt)
       {
 	switch (op)
 	{
-	  case M_DELETE:
 	  case M_UNDELETE:
+	    mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED,
+			   0);
+	  case M_DELETE:
 	    mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE, 
 			  (op == M_DELETE));
 	    break;