You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

purge-message.patch 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. From: Cedric Duval <cedricduval@free.fr>
  2. Date: Thu, 27 Feb 2014 14:21:59 +0100
  3. Subject: purge-message
  4. (requires trash folder patch)
  5. This patch adds the purge-message function, which, unlike delete-message,
  6. will bypass the trash folder and really delete the mail.
  7. You can bind this function to <esc>D, for instance, by adding the following
  8. lines to your muttrc:
  9. bind index \eD purge-message
  10. bind pager \eD purge-message
  11. Please be very careful with this function, and try to use it as less as
  12. possible. The risk resides in getting into the habit of always using
  13. purge-message instead of delete-message, which would really defeat the
  14. purpose of having a trash folder feature.
  15. * Patch last synced with upstream:
  16. - Date: 2007-02-15
  17. - File: http://cedricduval.free.fr/mutt/patches/download/patch-1.5.5.1.cd.purge_message.3.4
  18. * Changes made:
  19. - Updated to 1.5.13
  20. - Fixed indentation of "purged" in mutt.h.
  21. Signed-off-by: Matteo F. Vescovi <mfvescovi@gmail.com>
  22. Gbp-Pq: Topic features
  23. ---
  24. OPS | 1 +
  25. curs_main.c | 12 ++++++++++--
  26. flags.c | 10 ++++++++++
  27. functions.h | 2 ++
  28. mutt.h | 2 ++
  29. mx.c | 1 +
  30. pager.c | 8 +++++++-
  31. pattern.c | 4 +++-
  32. 8 files changed, 36 insertions(+), 4 deletions(-)
  33. diff --git a/OPS b/OPS
  34. index 8414a8b..02cea8e 100644
  35. --- a/OPS
  36. +++ b/OPS
  37. @@ -142,6 +142,7 @@ OP_PREV_ENTRY "move to the previous entry"
  38. OP_PREV_LINE "scroll up one line"
  39. OP_PREV_PAGE "move to the previous page"
  40. OP_PRINT "print the current entry"
  41. +OP_PURGE_MESSAGE "really delete the current entry, bypassing the trash folder"
  42. OP_QUERY "query external program for addresses"
  43. OP_QUERY_APPEND "append new query results to current results"
  44. OP_QUIT "save changes to mailbox and quit"
  45. diff --git a/curs_main.c b/curs_main.c
  46. index 16ddbc9..d266708 100644
  47. --- a/curs_main.c
  48. +++ b/curs_main.c
  49. @@ -1844,6 +1844,7 @@ int mutt_index_menu (void)
  50. MAYBE_REDRAW (menu->redraw);
  51. break;
  52. + case OP_PURGE_MESSAGE:
  53. case OP_DELETE:
  54. CHECK_MSGCOUNT;
  55. @@ -1854,6 +1855,7 @@ int mutt_index_menu (void)
  56. if (tag)
  57. {
  58. mutt_tag_set_flag (M_DELETE, 1);
  59. + mutt_tag_set_flag (M_PURGED, (op != OP_PURGE_MESSAGE) ? 0 : 1);
  60. if (option (OPTDELETEUNTAG))
  61. mutt_tag_set_flag (M_TAG, 0);
  62. menu->redraw = REDRAW_INDEX;
  63. @@ -1861,6 +1863,8 @@ int mutt_index_menu (void)
  64. else
  65. {
  66. mutt_set_flag (Context, CURHDR, M_DELETE, 1);
  67. + mutt_set_flag (Context, CURHDR, M_PURGED,
  68. + (op != OP_PURGE_MESSAGE) ? 0 : 1);
  69. if (option (OPTDELETEUNTAG))
  70. mutt_set_flag (Context, CURHDR, M_TAG, 0);
  71. if (option (OPTRESOLVE))
  72. @@ -2162,11 +2166,13 @@ int mutt_index_menu (void)
  73. if (tag)
  74. {
  75. mutt_tag_set_flag (M_DELETE, 0);
  76. + mutt_tag_set_flag (M_PURGED, 0);
  77. menu->redraw = REDRAW_INDEX;
  78. }
  79. else
  80. {
  81. mutt_set_flag (Context, CURHDR, M_DELETE, 0);
  82. + mutt_set_flag (Context, CURHDR, M_PURGED, 0);
  83. if (option (OPTRESOLVE) && menu->current < Context->vcount - 1)
  84. {
  85. menu->current++;
  86. @@ -2187,9 +2193,11 @@ int mutt_index_menu (void)
  87. CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
  88. rc = mutt_thread_set_flag (CURHDR, M_DELETE, 0,
  89. - op == OP_UNDELETE_THREAD ? 0 : 1);
  90. + op == OP_UNDELETE_THREAD ? 0 : 1)
  91. + + mutt_thread_set_flag (CURHDR, M_PURGED, 0,
  92. + op == OP_UNDELETE_THREAD ? 0 : 1);
  93. - if (rc != -1)
  94. + if (rc > -1)
  95. {
  96. if (option (OPTRESOLVE))
  97. {
  98. diff --git a/flags.c b/flags.c
  99. index dfa6a50..5309bb7 100644
  100. --- a/flags.c
  101. +++ b/flags.c
  102. @@ -104,6 +104,16 @@ void _mutt_set_flag (CONTEXT *ctx, HEADER *h, int flag, int bf, int upd_ctx)
  103. }
  104. break;
  105. + case M_PURGED:
  106. + if (bf)
  107. + {
  108. + if (!h->purged)
  109. + h->purged = 1;
  110. + }
  111. + else if (h->purged)
  112. + h->purged = 0;
  113. + break;
  114. +
  115. case M_NEW:
  116. if (!mutt_bit_isset(ctx->rights,M_ACL_SEEN))
  117. diff --git a/functions.h b/functions.h
  118. index 7a1c5a9..a29388c 100644
  119. --- a/functions.h
  120. +++ b/functions.h
  121. @@ -121,6 +121,7 @@ const struct binding_t OpMain[] = { /* map: index */
  122. { "toggle-write", OP_TOGGLE_WRITE, "%" },
  123. { "next-thread", OP_MAIN_NEXT_THREAD, "\016" },
  124. { "next-subthread", OP_MAIN_NEXT_SUBTHREAD, "\033n" },
  125. + { "purge-message", OP_PURGE_MESSAGE, NULL },
  126. { "query", OP_QUERY, "Q" },
  127. { "quit", OP_QUIT, "q" },
  128. { "reply", OP_REPLY, "r" },
  129. @@ -213,6 +214,7 @@ const struct binding_t OpPager[] = { /* map: pager */
  130. { "print-message", OP_PRINT, "p" },
  131. { "previous-thread", OP_MAIN_PREV_THREAD, "\020" },
  132. { "previous-subthread",OP_MAIN_PREV_SUBTHREAD, "\033p" },
  133. + { "purge-message", OP_PURGE_MESSAGE, NULL },
  134. { "quit", OP_QUIT, "Q" },
  135. { "exit", OP_EXIT, "q" },
  136. { "reply", OP_REPLY, "r" },
  137. diff --git a/mutt.h b/mutt.h
  138. index 0b879b9..8cee3d2 100644
  139. --- a/mutt.h
  140. +++ b/mutt.h
  141. @@ -186,6 +186,7 @@ enum
  142. M_UNDELETE,
  143. M_DELETED,
  144. M_APPENDED,
  145. + M_PURGED,
  146. M_FLAG,
  147. M_TAG,
  148. M_UNTAG,
  149. @@ -711,6 +712,7 @@ typedef struct header
  150. unsigned int flagged : 1; /* marked important? */
  151. unsigned int tagged : 1;
  152. unsigned int appended : 1; /* has been saved */
  153. + unsigned int purged : 1; /* bypassing the trash folder */
  154. unsigned int deleted : 1;
  155. unsigned int changed : 1;
  156. unsigned int attach_del : 1; /* has an attachment marked for deletion */
  157. diff --git a/mx.c b/mx.c
  158. index f7fd01f..89b9431 100644
  159. --- a/mx.c
  160. +++ b/mx.c
  161. @@ -806,6 +806,7 @@ static int trash_append (CONTEXT *ctx)
  162. {
  163. for (i = 0 ; i < ctx->msgcount ; i++)
  164. if (ctx->hdrs[i]->deleted && !ctx->hdrs[i]->appended
  165. + && !ctx->hdrs[i]->purged
  166. && mutt_append_message (ctx_trash, ctx, ctx->hdrs[i], 0, 0) == -1)
  167. {
  168. mx_close_mailbox (ctx_trash, NULL);
  169. diff --git a/pager.c b/pager.c
  170. index 23eb8ca..b17afb4 100644
  171. --- a/pager.c
  172. +++ b/pager.c
  173. @@ -2350,12 +2350,15 @@ search_next:
  174. MAYBE_REDRAW (redraw);
  175. break;
  176. + case OP_PURGE_MESSAGE:
  177. case OP_DELETE:
  178. CHECK_MODE(IsHeader (extra));
  179. CHECK_READONLY;
  180. CHECK_ACL(M_ACL_DELETE, _("delete message"));
  181. mutt_set_flag (Context, extra->hdr, M_DELETE, 1);
  182. + mutt_set_flag (Context, extra->hdr, M_PURGED,
  183. + ch != OP_PURGE_MESSAGE ? 0 : 1);
  184. if (option (OPTDELETEUNTAG))
  185. mutt_set_flag (Context, extra->hdr, M_TAG, 0);
  186. redraw = REDRAW_STATUS | REDRAW_INDEX;
  187. @@ -2682,6 +2685,7 @@ search_next:
  188. CHECK_ACL(M_ACL_DELETE, _("undelete message"));
  189. mutt_set_flag (Context, extra->hdr, M_DELETE, 0);
  190. + mutt_set_flag (Context, extra->hdr, M_PURGED, 0);
  191. redraw = REDRAW_STATUS | REDRAW_INDEX;
  192. if (option (OPTRESOLVE))
  193. {
  194. @@ -2697,9 +2701,11 @@ search_next:
  195. CHECK_ACL(M_ACL_DELETE, _("undelete message(s)"));
  196. r = mutt_thread_set_flag (extra->hdr, M_DELETE, 0,
  197. + ch == OP_UNDELETE_THREAD ? 0 : 1)
  198. + + mutt_thread_set_flag (extra->hdr, M_PURGED, 0,
  199. ch == OP_UNDELETE_THREAD ? 0 : 1);
  200. - if (r != -1)
  201. + if (r > -1)
  202. {
  203. if (option (OPTRESOLVE))
  204. {
  205. diff --git a/pattern.c b/pattern.c
  206. index 7af1c38..4cdbd05 100644
  207. --- a/pattern.c
  208. +++ b/pattern.c
  209. @@ -1358,8 +1358,10 @@ int mutt_pattern_func (int op, char *prompt)
  210. {
  211. switch (op)
  212. {
  213. - case M_DELETE:
  214. case M_UNDELETE:
  215. + mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_PURGED,
  216. + 0);
  217. + case M_DELETE:
  218. mutt_set_flag (Context, Context->hdrs[Context->v2r[i]], M_DELETE,
  219. (op == M_DELETE));
  220. break;