From 0692bed9b6d5d1485d48364513d6c437e1d157b9 Mon Sep 17 00:00:00 2001
From: Kevin McCarthy <kevin@8t8.us>
Date: Sun, 17 Jul 2016 19:31:13 -0700
Subject: [PATCH] Add purge-message patch.

This is based on the patch by Cedric Duval.
Modifications are:

* Use the exising M_PURGE flag from the trash folder patch, rather
  than adding a separate flag.

* Undelete operations are already handled by the trash folder patch.
---
 OPS         | 1 +
 curs_main.c | 3 +++
 functions.h | 2 ++
 pager.c     | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/OPS b/OPS
index 8414a8b33..02cea8e1e 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 8c291bdfd..ca7938886 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -1950,6 +1950,7 @@ int mutt_index_menu (void)
 	MAYBE_REDRAW (menu->redraw);
 	break;
 
+      case OP_PURGE_MESSAGE:
       case OP_DELETE:
 
 	CHECK_MSGCOUNT;
@@ -1961,6 +1962,7 @@ int mutt_index_menu (void)
 	if (tag)
 	{
 	  mutt_tag_set_flag (MUTT_DELETE, 1);
+          mutt_tag_set_flag (MUTT_PURGE, (op == OP_PURGE_MESSAGE));
 	  if (option (OPTDELETEUNTAG))
 	    mutt_tag_set_flag (MUTT_TAG, 0);
 	  menu->redraw = REDRAW_INDEX;
@@ -1968,6 +1970,7 @@ int mutt_index_menu (void)
 	else
 	{
 	  mutt_set_flag (Context, CURHDR, MUTT_DELETE, 1);
+	  mutt_set_flag (Context, CURHDR, MUTT_PURGE, (op == OP_PURGE_MESSAGE));
 	  if (option (OPTDELETEUNTAG))
 	    mutt_set_flag (Context, CURHDR, MUTT_TAG, 0);
 	  if (option (OPTRESOLVE))
diff --git a/functions.h b/functions.h
index 2af8827d7..abc06ca0d 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" },
@@ -223,6 +224,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/pager.c b/pager.c
index f8113aea5..c1bd8caf1 100644
--- a/pager.c
+++ b/pager.c
@@ -2406,6 +2406,7 @@ search_next:
 	MAYBE_REDRAW (redraw);
 	break;
 
+      case OP_PURGE_MESSAGE:
       case OP_DELETE:
 	CHECK_MODE(IsHeader (extra));
 	CHECK_READONLY;
@@ -2413,6 +2414,7 @@ search_next:
 	CHECK_ACL(MUTT_ACL_DELETE, _("Cannot delete message"));
 
 	mutt_set_flag (Context, extra->hdr, MUTT_DELETE, 1);
+	mutt_set_flag (Context, extra->hdr, MUTT_PURGE, (ch == OP_PURGE_MESSAGE));
         if (option (OPTDELETEUNTAG))
 	  mutt_set_flag (Context, extra->hdr, MUTT_TAG, 0);
 	redraw = REDRAW_STATUS | REDRAW_INDEX;
-- 
2.40.0