<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[143459] trunk/dports/mail/mutt-devel</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/143459">143459</a></dd>
<dt>Author</dt> <dd>cal@macports.org</dd>
<dt>Date</dt> <dd>2015-12-12 11:31:44 -0800 (Sat, 12 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>mutt-devel: Fix +sidebar regression and +trash

Fix a regression in the +sidebar patch that would cause folders with dots in
their name to be displayed in unexpected fashion. Additionally, support longer
folder names in the sidebar.

Additionally, port the +trash variant (that is actually the trash folder
&amp; purge message patch merged) to 1.5.24.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportsmailmuttdevelPortfile">trunk/dports/mail/mutt-devel/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkdportsmailmuttdevelfiles1Make_hierarchy_separator_for_folder_indentation_configurablepatch">trunk/dports/mail/mutt-devel/files/1-Make_hierarchy_separator_for_folder_indentation_configurable.patch</a></li>
<li><a href="#trunkdportsmailmuttdevelfiles2Support_long_er__folder_names_in_sidebarpatch">trunk/dports/mail/mutt-devel/files/2-Support_long_er__folder_names_in_sidebar.patch</a></li>
<li><a href="#trunkdportsmailmuttdevelfilespatch1524trash_folderpurge_messagediff">trunk/dports/mail/mutt-devel/files/patch-1.5.24-trash_folder-purge_message.diff</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkdportsmailmuttdevelfilespatch1520bktrash_folderpurge_message1">trunk/dports/mail/mutt-devel/files/patch-1.5.20.bk.trash_folder-purge_message.1</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportsmailmuttdevelPortfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/mail/mutt-devel/Portfile (143458 => 143459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/mail/mutt-devel/Portfile        2015-12-12 19:16:08 UTC (rev 143458)
+++ trunk/dports/mail/mutt-devel/Portfile        2015-12-12 19:31:44 UTC (rev 143459)
</span><span class="lines">@@ -6,6 +6,7 @@
</span><span class="cx"> name                mutt-devel
</span><span class="cx"> conflicts           mutt
</span><span class="cx"> version             1.5.24
</span><ins>+revision            1
</ins><span class="cx"> categories          mail
</span><span class="cx"> platforms           darwin
</span><span class="cx"> license             GPL-2
</span><span class="lines">@@ -180,7 +181,9 @@
</span><span class="cx"> variant sidebar conflicts nntp trash description {Add a sidebar with a list of folders} {
</span><span class="cx">     # http://www.lunar-linux.org/mutt-sidebar/
</span><span class="cx">     patch_sites-append      http://lunar-linux.org/~tchan/mutt:sidebar-patch
</span><del>-    patchfiles-append       patch-1.5.24.sidebar.20151111.txt:sidebar-patch
</del><ins>+    patchfiles-append       patch-1.5.24.sidebar.20151111.txt:sidebar-patch \
+                            1-Make_hierarchy_separator_for_folder_indentation_configurable.patch \
+                            2-Support_long_er__folder_names_in_sidebar.patch
</ins><span class="cx">     checksums-append        patch-1.5.24.sidebar.20151111.txt \
</span><span class="cx">                             rmd160  521938ab47440e93f73bc5ae358e867ab3d3212c \
</span><span class="cx">                             sha256  66441edf056032119f854fc5ee86c73eece8b95dc998c0cfae5ed05b0b035070
</span><span class="lines">@@ -188,7 +191,7 @@
</span><span class="cx"> 
</span><span class="cx"> # Trash patch from https://trac.macports.org/ticket/20412 conflicts with sidebar patch on global.h
</span><span class="cx"> variant trash conflicts sidebar description {Add a Trash folder} {
</span><del>-    patchfiles-append       patch-1.5.20.bk.trash_folder-purge_message.1
</del><ins>+    patchfiles-append       patch-1.5.24-trash_folder-purge_message.diff
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> variant gpgme description {Enable GPGME crypto support} {
</span></span></pre></div>
<a id="trunkdportsmailmuttdevelfiles1Make_hierarchy_separator_for_folder_indentation_configurablepatch"></a>
<div class="addfile"><h4>Added: trunk/dports/mail/mutt-devel/files/1-Make_hierarchy_separator_for_folder_indentation_configurable.patch (0 => 143459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/mail/mutt-devel/files/1-Make_hierarchy_separator_for_folder_indentation_configurable.patch                                (rev 0)
+++ trunk/dports/mail/mutt-devel/files/1-Make_hierarchy_separator_for_folder_indentation_configurable.patch        2015-12-12 19:31:44 UTC (rev 143459)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+# HG changeset patch
+# User Clemens Lang &lt;cal@macports.org&gt;
+# Date 1449516441 -3600
+#      Mon Dec 07 20:27:21 2015 +0100
+# Node ID 30679b45eeadb1ece557963cbd5915ab933fa747
+# Parent  7b9454058beba85a1878f6fd835fe1edf8b48279
+Make hierarchy separator for folder indentation configurable
+
+The sidebar-dotted patch from
+  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523774
+supports folders from IMAP servers that use dots as hierarchy separator.
+However, in its implementation, it breaks the sidebar for users that use
+a slash as hierarchy separators and have dots in their folder names.
+
+Support both use cases by adding a new option sidebar_folder_delim_chars
+to configure the characters that separate hierarchies, similar to what
+imap_delim_chars does. Using imap_delim_chars directly is not a good
+idea because there might be users who do not use IMAP support in mutt.
+
+Signed-off-by: Clemens Lang &lt;cal@macports.org&gt;
+License: GPL-2.0+
+Upstream-Status: Submitted [private email 2015-12-07]
+
+diff --git a/globals.h b/globals.h
+--- a/globals.h
++++ b/globals.h
+@@ -119,6 +119,7 @@
+ WHERE char *Sendmail;
+ WHERE char *Shell;
+ WHERE char *SidebarDelim;
++WHERE char *SidebarFolderDelimChars;
+ WHERE char *SidebarFormat;
+ WHERE char *SidebarIndentStr;
+ WHERE char *Signature;
+diff --git a/init.h b/init.h
+--- a/init.h
++++ b/init.h
+@@ -2066,6 +2066,12 @@
+   ** .pp
+   ** Should the sidebar shorten the path showed.
+   */
++  { &quot;sidebar_folder_delim_chars&quot;, DT_STR, R_BOTH, UL &amp;SidebarFolderDelimChars, UL &quot;/.&quot; },
++  /*
++  ** .pp
++  ** This contains the list of characters which you would like to treat
++  ** as folder separators for displaying folders hierarchically in the sidebar.
++  */
+   {&quot;sidebar_format&quot;, DT_STR, R_NONE, UL &amp;SidebarFormat, UL &quot;%B%?F? [%F]?%* %?N?%N/?%4S&quot;},
+   /*
+   ** .pp
+diff --git a/sidebar.c b/sidebar.c
+--- a/sidebar.c
++++ b/sidebar.c
+@@ -318,21 +318,20 @@
+                 sidebar_folder_name = option(OPTSIDEBARSHORTPATH) ? mutt_basename(tmp-&gt;path) : tmp-&gt;path + maildir_is_prefix*(strlen(Maildir) + 1);
+                 if ( maildir_is_prefix &amp;&amp; option(OPTSIDEBARFOLDERINDENT) ) {
+                         char *tmp_folder_name;
++                        char *last_folder_name_part;
+                         int i;
+                         tmp_folder_name = tmp-&gt;path + strlen(Maildir) + 1;
+-                        for (i = 0; i &lt; strlen(tmp-&gt;path) - strlen(Maildir); i++) {
+-                                 if (tmp_folder_name[i] == '/'  || tmp_folder_name[i] == '.') sidebar_folder_depth++;
+-                        }   
++                        last_folder_name_part = tmp_folder_name;
++                        for (i = 0; i &lt; strlen(tmp_folder_name); i++) {
++                                if (strchr(NONULL(SidebarFolderDelimChars), tmp_folder_name[i])) {
++                                        last_folder_name_part = tmp_folder_name + (i + 1);
++                                        sidebar_folder_depth++;
++                                }
++                        }
+                         if (sidebar_folder_depth &gt; 0) {
+                                  if (option(OPTSIDEBARSHORTPATH)) {
+-                                         tmp_folder_name = strrchr(tmp-&gt;path, '.');
+-                                         if (tmp_folder_name == NULL)
+-                                                 tmp_folder_name = mutt_basename(tmp-&gt;path);
+-                                         else
+-                                                tmp_folder_name++;
++                                         tmp_folder_name = last_folder_name_part;
+                                  }
+-                                 else
+-                                         tmp_folder_name = tmp-&gt;path + strlen(Maildir) + 1;
+                                  sidebar_folder_name = malloc(strlen(tmp_folder_name) + sidebar_folder_depth*strlen(NONULL(SidebarIndentStr)) + 1);
+                                 sidebar_folder_name[0]=0;
+                                 for (i=0; i &lt; sidebar_folder_depth; i++)
</ins></span></pre></div>
<a id="trunkdportsmailmuttdevelfiles2Support_long_er__folder_names_in_sidebarpatch"></a>
<div class="addfile"><h4>Added: trunk/dports/mail/mutt-devel/files/2-Support_long_er__folder_names_in_sidebar.patch (0 => 143459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/mail/mutt-devel/files/2-Support_long_er__folder_names_in_sidebar.patch                                (rev 0)
+++ trunk/dports/mail/mutt-devel/files/2-Support_long_er__folder_names_in_sidebar.patch        2015-12-12 19:31:44 UTC (rev 143459)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+# HG changeset patch
+# User Clemens Lang &lt;cal@macports.org&gt;
+# Date 1449516538 -3600
+#      Mon Dec 07 20:28:58 2015 +0100
+# Node ID c5694b7d4b8f5acd857ad4681a29ca79c76d1e59
+# Parent  30679b45eeadb1ece557963cbd5915ab933fa747
+Support long(er) folder names in sidebar
+
+Folder names longer than 31 characters were previously cut off in the
+sidebar, even though the field provided space for 128 in the current
+implementation. Change to a generic sizeof() expression that will grow
+with the size of the declaration.
+
+Signed-off-by: Clemens Lang &lt;cal@macports.org&gt;
+License: GPL-2.0+
+Upstream-Status: Submitted [private email 2015-12-07]
+
+diff --git a/sidebar.c b/sidebar.c
+--- a/sidebar.c
++++ b/sidebar.c
+@@ -157,7 +157,7 @@
+     sbe.new = new;
+     sbe.flagged = flagged;
+     sbe.size = size;
+-    strncpy(sbe.box, box, 31);
++    strncpy(sbe.box, box, sizeof(sbe.box) - 1);

+     safe_realloc(&amp;entry, SBvisual + 2);
+     entry[SBvisual + 1] = '\0';
</ins></span></pre></div>
<a id="trunkdportsmailmuttdevelfilespatch1520bktrash_folderpurge_message1"></a>
<div class="delfile"><h4>Deleted: trunk/dports/mail/mutt-devel/files/patch-1.5.20.bk.trash_folder-purge_message.1 (143458 => 143459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/mail/mutt-devel/files/patch-1.5.20.bk.trash_folder-purge_message.1        2015-12-12 19:16:08 UTC (rev 143458)
+++ trunk/dports/mail/mutt-devel/files/patch-1.5.20.bk.trash_folder-purge_message.1        2015-12-12 19:31:44 UTC (rev 143459)
</span><span class="lines">@@ -1,403 +0,0 @@
</span><del>-diff -pruN -x'*.orig' mutt-1.5.20/OPS mutt-1.5.20-trash/OPS
---- mutt-1.5.20/OPS        2009-05-13 01:01:13.000000000 -0400
-+++ mutt-1.5.20-trash/OPS        2009-07-23 09:44:40.000000000 -0400
-@@ -141,6 +141,7 @@ OP_PREV_ENTRY &quot;move to the previous entr
- OP_PREV_LINE &quot;scroll up one line&quot;
- OP_PREV_PAGE &quot;move to the previous page&quot;
- OP_PRINT &quot;print the current entry&quot;
-+OP_PURGE_MESSAGE &quot;really delete the current entry, bypassing the trash folder&quot;
- OP_QUERY &quot;query external program for addresses&quot;
- OP_QUERY_APPEND &quot;append new query results to current results&quot;
- OP_QUIT &quot;save changes to mailbox and quit&quot;
-diff -pruN -x'*.orig' mutt-1.5.20/PATCHES mutt-1.5.20-trash/PATCHES
---- mutt-1.5.20/PATCHES        2008-11-11 14:55:46.000000000 -0500
-+++ mutt-1.5.20-trash/PATCHES        2009-07-23 09:53:20.000000000 -0400
-@@ -0,0 +1 @@
-+patch-1.5.20.bk.trash_folder-purge_message.1
-diff -pruN -x'*.orig' mutt-1.5.20/commands.c mutt-1.5.20-trash/commands.c
---- mutt-1.5.20/commands.c        2009-06-12 19:38:52.000000000 -0400
-+++ mutt-1.5.20-trash/commands.c        2009-07-23 09:44:40.000000000 -0400
-@@ -716,6 +716,7 @@ int _mutt_save_message (HEADER *h, CONTE
-     if (option (OPTDELETEUNTAG))
-       mutt_set_flag (Context, h, M_TAG, 0);
-   }
-+  mutt_set_flag (Context, h, M_APPENDED, 1);
-   
-   return 0;
- }
-diff -pruN -x'*.orig' mutt-1.5.20/curs_main.c mutt-1.5.20-trash/curs_main.c
---- mutt-1.5.20/curs_main.c        2009-06-13 22:48:36.000000000 -0400
-+++ mutt-1.5.20-trash/curs_main.c        2009-07-23 09:44:40.000000000 -0400
-@@ -1803,6 +1803,7 @@ int mutt_index_menu (void)
-         MAYBE_REDRAW (menu-&gt;redraw);
-         break;

-+      case OP_PURGE_MESSAGE:
-       case OP_DELETE:

-         CHECK_MSGCOUNT;
-@@ -1813,6 +1814,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-&gt;redraw = REDRAW_INDEX;
-@@ -1820,6 +1822,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))
-@@ -2116,11 +2120,13 @@ int mutt_index_menu (void)
-         if (tag)
-         {
-           mutt_tag_set_flag (M_DELETE, 0);
-+          mutt_tag_set_flag (M_PURGED, 0);
-           menu-&gt;redraw = REDRAW_INDEX;
-         }
-         else
-         {
-           mutt_set_flag (Context, CURHDR, M_DELETE, 0);
-+          mutt_set_flag (Context, CURHDR, M_PURGED, 0);
-           if (option (OPTRESOLVE) &amp;&amp; menu-&gt;current &lt; Context-&gt;vcount - 1)
-           {
-             menu-&gt;current++;
-@@ -2141,9 +2147,11 @@ int mutt_index_menu (void)
-         CHECK_ACL(M_ACL_DELETE, _(&quot;undelete message(s)&quot;));

-         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 &gt; -1)
-         {
-           if (option (OPTRESOLVE))
-           {
-diff -pruN -x'*.orig' mutt-1.5.20/flags.c mutt-1.5.20-trash/flags.c
---- mutt-1.5.20/flags.c        2008-12-16 22:50:09.000000000 -0500
-+++ mutt-1.5.20-trash/flags.c        2009-07-23 09:44:40.000000000 -0400
-@@ -65,7 +65,13 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
-       {
-         h-&gt;deleted = 0;
-         update = 1;
--        if (upd_ctx) ctx-&gt;deleted--;
-+        if (upd_ctx)
-+        {
-+          ctx-&gt;deleted--;
-+          if (h-&gt;appended)
-+            ctx-&gt;appended--;
-+        }
-+        h-&gt;appended = 0; /* when undeleting, also reset the appended flag */
- #ifdef USE_IMAP
-         /* see my comment above */
-         if (ctx-&gt;magic == M_IMAP) 
-@@ -87,6 +93,27 @@ void _mutt_set_flag (CONTEXT *ctx, HEADE
-       }
-       break;

-+    case M_APPENDED:
-+      if (bf)
-+      {
-+       if (!h-&gt;appended)
-+       {
-+         h-&gt;appended = 1;
-+         if (upd_ctx) ctx-&gt;appended++;
-+       }
-+      }
-+      break;
-+
-+    case M_PURGED:
-+      if (bf)
-+      {
-+        if (!h-&gt;purged)
-+          h-&gt;purged = 1;
-+      }
-+      else if (h-&gt;purged)
-+        h-&gt;purged = 0;
-+      break;
-+
-     case M_NEW:

-       if (!mutt_bit_isset(ctx-&gt;rights,M_ACL_SEEN))
-diff -pruN -x'*.orig' mutt-1.5.20/functions.h mutt-1.5.20-trash/functions.h
---- mutt-1.5.20/functions.h        2009-04-30 01:36:17.000000000 -0400
-+++ mutt-1.5.20-trash/functions.h        2009-07-23 09:44:40.000000000 -0400
-@@ -120,6 +120,7 @@ struct binding_t OpMain[] = { /* map: in
-   { &quot;toggle-write&quot;,                OP_TOGGLE_WRITE,                &quot;%&quot; },
-   { &quot;next-thread&quot;,                OP_MAIN_NEXT_THREAD,                &quot;\016&quot; },
-   { &quot;next-subthread&quot;,                OP_MAIN_NEXT_SUBTHREAD,                &quot;\033n&quot; },
-+  { &quot;purge-message&quot;,                OP_PURGE_MESSAGE,                NULL },
-   { &quot;query&quot;,                        OP_QUERY,                        &quot;Q&quot; },
-   { &quot;quit&quot;,                        OP_QUIT,                        &quot;q&quot; },
-   { &quot;reply&quot;,                        OP_REPLY,                        &quot;r&quot; },
-@@ -209,6 +210,7 @@ struct binding_t OpPager[] = { /* map: p
-   { &quot;print-message&quot;,        OP_PRINT,                        &quot;p&quot; },
-   { &quot;previous-thread&quot;,        OP_MAIN_PREV_THREAD,                &quot;\020&quot; },
-   { &quot;previous-subthread&quot;,OP_MAIN_PREV_SUBTHREAD,        &quot;\033p&quot; },
-+  { &quot;purge-message&quot;,        OP_PURGE_MESSAGE,                NULL },
-   { &quot;quit&quot;,                OP_QUIT,                        &quot;Q&quot; },
-   { &quot;exit&quot;,                OP_EXIT,                        &quot;q&quot; },
-   { &quot;reply&quot;,                OP_REPLY,                        &quot;r&quot; },
-diff -pruN -x'*.orig' mutt-1.5.20/globals.h mutt-1.5.20-trash/globals.h
---- mutt-1.5.20/globals.h        2009-06-03 16:48:31.000000000 -0400
-+++ mutt-1.5.20-trash/globals.h        2009-07-23 09:44:40.000000000 -0400
-@@ -139,6 +139,7 @@ WHERE char *StChars;
- WHERE char *Status;
- WHERE char *Tempdir;
- WHERE char *Tochars;
-+WHERE char *TrashPath;
- WHERE char *Username;
- WHERE char *Visual;

-diff -pruN -x'*.orig' mutt-1.5.20/imap/message.c mutt-1.5.20-trash/imap/message.c
---- mutt-1.5.20/imap/message.c        2009-06-07 13:52:57.000000000 -0400
-+++ mutt-1.5.20-trash/imap/message.c        2009-07-23 09:44:40.000000000 -0400
-@@ -867,6 +867,7 @@ int imap_copy_messages (CONTEXT* ctx, HE
-         if (ctx-&gt;hdrs[n]-&gt;tagged)
-         {
-           mutt_set_flag (ctx, ctx-&gt;hdrs[n], M_DELETE, 1);
-+         mutt_set_flag (ctx, ctx-&gt;hdrs[n], M_APPENDED, 1);
-           if (option (OPTDELETEUNTAG))
-             mutt_set_flag (ctx, ctx-&gt;hdrs[n], M_TAG, 0);
-         }
-@@ -874,6 +875,7 @@ int imap_copy_messages (CONTEXT* ctx, HE
-     else
-     {
-       mutt_set_flag (ctx, h, M_DELETE, 1);
-+      mutt_set_flag (ctx, h, M_APPENDED, 1);
-       if (option (OPTDELETEUNTAG))
-         mutt_set_flag (ctx, h, M_TAG, 0);
-     }
-diff -pruN -x'*.orig' mutt-1.5.20/init.h mutt-1.5.20-trash/init.h
---- mutt-1.5.20/init.h        2009-06-13 17:35:21.000000000 -0400
-+++ mutt-1.5.20-trash/init.h        2009-07-23 09:44:40.000000000 -0400
-@@ -3180,6 +3180,16 @@ struct option_t MuttVars[] = {
-   ** by \fIyou\fP.  The sixth character is used to indicate when a mail
-   ** was sent to a mailing-list you subscribe to.
-   */
-+  { &quot;trash&quot;,           DT_PATH, R_NONE, UL &amp;TrashPath, 0 },
-+  /*
-+  ** .pp
-+  ** If set, this variable specifies the path of the trash folder where the
-+  ** mails marked for deletion will be moved, instead of being irremediably
-+  ** purged.
-+  ** .pp
-+  ** NOTE: When you delete a message in the trash folder, it is really
-+  ** deleted, so that you have a way to clean the trash.
-+  */
- #ifdef USE_SOCKET
-   { &quot;tunnel&quot;,            DT_STR, R_NONE, UL &amp;Tunnel, UL 0 },
-   /*
-diff -pruN -x'*.orig' mutt-1.5.20/mutt.h mutt-1.5.20-trash/mutt.h
---- mutt-1.5.20/mutt.h        2009-06-12 18:15:42.000000000 -0400
-+++ mutt-1.5.20-trash/mutt.h        2009-07-23 09:44:40.000000000 -0400
-@@ -187,6 +187,8 @@ enum
-   M_DELETE,
-   M_UNDELETE,
-   M_DELETED,
-+  M_APPENDED,
-+  M_PURGED,
-   M_FLAG,
-   M_TAG,
-   M_UNTAG,
-@@ -701,6 +703,8 @@ typedef struct header
-   unsigned int mime : 1;                    /* has a MIME-Version 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 */
-@@ -873,6 +877,7 @@ typedef struct _context
-   int new;                        /* how many new messages? */
-   int unread;                        /* how many unread messages? */
-   int deleted;                        /* how many deleted messages */
-+  int appended;                 /* how many saved messages? */
-   int flagged;                        /* how many flagged messages */
-   int msgnotreadyet;                /* which msg &quot;new&quot; in pager, -1 if none */

-diff -pruN -x'*.orig' mutt-1.5.20/muttlib.c mutt-1.5.20-trash/muttlib.c
---- mutt-1.5.20/muttlib.c        2009-05-18 20:11:35.000000000 -0400
-+++ mutt-1.5.20-trash/muttlib.c        2009-07-23 09:44:40.000000000 -0400
-@@ -1460,7 +1460,9 @@ int mutt_save_confirm (const char *s, st

-   if (magic &gt; 0 &amp;&amp; !mx_access (s, W_OK))
-   {
--    if (option (OPTCONFIRMAPPEND))
-+    if (option (OPTCONFIRMAPPEND) &amp;&amp;
-+       (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
-+      /* if we're appending to the trash, there's no point in asking */
-     {
-       snprintf (tmp, sizeof (tmp), _(&quot;Append messages to %s?&quot;), s);
-       if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
-diff -pruN -x'*.orig' mutt-1.5.20/mx.c mutt-1.5.20-trash/mx.c
---- mutt-1.5.20/mx.c        2009-06-11 00:29:41.000000000 -0400
-+++ mutt-1.5.20-trash/mx.c        2009-07-23 09:44:40.000000000 -0400
-@@ -773,6 +773,54 @@ static int sync_mailbox (CONTEXT *ctx, i
-   return rc;
- }

-+/* move deleted mails to the trash folder */
-+static int trash_append (CONTEXT *ctx)
-+{
-+    CONTEXT *ctx_trash;
-+    int i = 0;
-+    struct stat st, stc;
-+
-+    if (!TrashPath || !ctx-&gt;deleted ||
-+       (ctx-&gt;magic == M_MAILDIR &amp;&amp; option (OPTMAILDIRTRASH)))
-+      return 0;
-+
-+    for (;i &lt; ctx-&gt;msgcount &amp;&amp; (!ctx-&gt;hdrs[i]-&gt;deleted ||
-+                               ctx-&gt;hdrs[i]-&gt;appended); i++);
-+    if (i == ctx-&gt;msgcount)
-+      return 0; /* nothing to be done */
-+
-+    if (mutt_save_confirm (TrashPath, &amp;st) != 0)
-+    {
-+      mutt_error _(&quot;message(s) not deleted&quot;);
-+      return -1;
-+    }
-+
-+    if (lstat (ctx-&gt;path, &amp;stc) == 0 &amp;&amp; stc.st_ino == st.st_ino
-+       &amp;&amp; stc.st_dev == st.st_dev &amp;&amp; stc.st_rdev == st.st_rdev)
-+      return 0;  /* we are in the trash folder: simple sync */
-+
-+    if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
-+    {
-+      for (i = 0 ; i &lt; ctx-&gt;msgcount ; i++)
-+       if (ctx-&gt;hdrs[i]-&gt;deleted &amp;&amp; !ctx-&gt;hdrs[i]-&gt;appended
-+           &amp;&amp; !ctx-&gt;hdrs[i]-&gt;purged
-+           &amp;&amp; mutt_append_message (ctx_trash, ctx, ctx-&gt;hdrs[i], 0, 0) == -1)
-+         {
-+           mx_close_mailbox (ctx_trash, NULL);
-+           return -1;
-+         }
-+
-+      mx_close_mailbox (ctx_trash, NULL);
-+    }
-+    else
-+    {
-+      mutt_error _(&quot;Can't open trash folder&quot;);
-+      return -1;
-+    }
-+
-+    return 0;
-+}
-+
- /* save changes and close mailbox */
- int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
- {
-@@ -909,6 +957,7 @@ int mx_close_mailbox (CONTEXT *ctx, int 
-           if (mutt_append_message (&amp;f, ctx, ctx-&gt;hdrs[i], 0, CH_UPDATE_LEN) == 0)
-           {
-             mutt_set_flag (ctx, ctx-&gt;hdrs[i], M_DELETE, 1);
-+            mutt_set_flag (ctx, ctx-&gt;hdrs[i], M_APPENDED, 1);
-           }
-           else
-           {
-@@ -931,6 +980,14 @@ int mx_close_mailbox (CONTEXT *ctx, int 
-     return 0;
-   }
-   
-+  /* copy mails to the trash before expunging */
-+  if (purge &amp;&amp; ctx-&gt;deleted)
-+    if (trash_append (ctx) != 0)
-+    {
-+      ctx-&gt;closing = 0;
-+      return -1;
-+    }
-+
- #ifdef USE_IMAP
-   /* allow IMAP to preserve the deleted flag across sessions */
-   if (ctx-&gt;magic == M_IMAP)
-@@ -1130,6 +1187,12 @@ int mx_sync_mailbox (CONTEXT *ctx, int *
-   msgcount = ctx-&gt;msgcount;
-   deleted = ctx-&gt;deleted;

-+  if (purge &amp;&amp; ctx-&gt;deleted)
-+  {
-+    if (trash_append (ctx) == -1)
-+      return -1;
-+  } 
-+
- #ifdef USE_IMAP
-   if (ctx-&gt;magic == M_IMAP)
-     rc = imap_sync_mailbox (ctx, purge, index_hint);
-diff -pruN -x'*.orig' mutt-1.5.20/pager.c mutt-1.5.20-trash/pager.c
---- mutt-1.5.20/pager.c        2009-06-03 16:48:31.000000000 -0400
-+++ mutt-1.5.20-trash/pager.c        2009-07-23 09:44:40.000000000 -0400
-@@ -2309,12 +2309,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, _(&quot;delete message&quot;));

-         mutt_set_flag (Context, extra-&gt;hdr, M_DELETE, 1);
-+        mutt_set_flag (Context, extra-&gt;hdr, M_PURGED,
-+                       ch != OP_PURGE_MESSAGE ? 0 : 1);
-         if (option (OPTDELETEUNTAG))
-           mutt_set_flag (Context, extra-&gt;hdr, M_TAG, 0);
-         redraw = REDRAW_STATUS | REDRAW_INDEX;
-@@ -2641,6 +2644,7 @@ search_next:
-         CHECK_ACL(M_ACL_DELETE, _(&quot;undelete message&quot;));

-         mutt_set_flag (Context, extra-&gt;hdr, M_DELETE, 0);
-+        mutt_set_flag (Context, extra-&gt;hdr, M_PURGED, 0);
-         redraw = REDRAW_STATUS | REDRAW_INDEX;
-         if (option (OPTRESOLVE))
-         {
-@@ -2656,9 +2660,11 @@ search_next:
-         CHECK_ACL(M_ACL_DELETE, _(&quot;undelete message(s)&quot;));

-         r = mutt_thread_set_flag (extra-&gt;hdr, M_DELETE, 0,
-+                                  ch == OP_UNDELETE_THREAD ? 0 : 1)
-+          + mutt_thread_set_flag (extra-&gt;hdr, M_PURGED, 0,
-                                   ch == OP_UNDELETE_THREAD ? 0 : 1);

--        if (r != -1)
-+        if (r &gt; -1)
-         {
-           if (option (OPTRESOLVE))
-           {
-diff -pruN -x'*.orig' mutt-1.5.20/pattern.c mutt-1.5.20-trash/pattern.c
---- mutt-1.5.20/pattern.c        2009-06-03 16:48:31.000000000 -0400
-+++ mutt-1.5.20-trash/pattern.c        2009-07-23 09:44:40.000000000 -0400
-@@ -1347,8 +1347,10 @@ int mutt_pattern_func (int op, char *pro
-       {
-         switch (op)
-         {
--          case M_DELETE:
-           case M_UNDELETE:
-+            mutt_set_flag (Context, Context-&gt;hdrs[Context-&gt;v2r[i]], M_PURGED,
-+                           0);
-+          case M_DELETE:
-             mutt_set_flag (Context, Context-&gt;hdrs[Context-&gt;v2r[i]], M_DELETE, 
-                           (op == M_DELETE));
-             break;
-diff -pruN -x'*.orig' mutt-1.5.20/postpone.c mutt-1.5.20-trash/postpone.c
---- mutt-1.5.20/postpone.c        2009-06-13 17:28:37.000000000 -0400
-+++ mutt-1.5.20-trash/postpone.c        2009-07-23 09:44:40.000000000 -0400
-@@ -276,6 +276,9 @@ int mutt_get_postponed (CONTEXT *ctx, HE
-   /* finished with this message, so delete it. */
-   mutt_set_flag (PostContext, h, M_DELETE, 1);

-+  /* and consider it saved, so that it won't be moved to the trash folder */
-+  mutt_set_flag (PostContext, h, M_APPENDED, 1);
-+
-   /* update the count for the status display */
-   PostCount = PostContext-&gt;msgcount - PostContext-&gt;deleted;

</del></span></pre></div>
<a id="trunkdportsmailmuttdevelfilespatch1524trash_folderpurge_messagediff"></a>
<div class="addfile"><h4>Added: trunk/dports/mail/mutt-devel/files/patch-1.5.24-trash_folder-purge_message.diff (0 => 143459)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/mail/mutt-devel/files/patch-1.5.24-trash_folder-purge_message.diff                                (rev 0)
+++ trunk/dports/mail/mutt-devel/files/patch-1.5.24-trash_folder-purge_message.diff        2015-12-12 19:31:44 UTC (rev 143459)
</span><span class="lines">@@ -0,0 +1,412 @@
</span><ins>+# HG changeset patch
+# User Clemens Lang &lt;cal@macports.org&gt;
+# Date 1449948138 -3600
+#      Sat Dec 12 20:22:18 2015 +0100
+# Node ID 462bed648335a13643a39b7e5ee09bc396593a4a
+# Parent  72fbf15cd9a166881500dbcb43cb5747213077e9
+Update trash folder &amp; purge patch for mutt 1.5.24
+
+diff --git a/OPS b/OPS
+--- a/OPS
++++ b/OPS
+@@ -142,6 +142,7 @@
+ OP_PREV_LINE &quot;scroll up one line&quot;
+ OP_PREV_PAGE &quot;move to the previous page&quot;
+ OP_PRINT &quot;print the current entry&quot;
++OP_PURGE_MESSAGE &quot;really delete the current entry, bypassing the trash folder&quot;
+ OP_QUERY &quot;query external program for addresses&quot;
+ OP_QUERY_APPEND &quot;append new query results to current results&quot;
+ OP_QUIT &quot;save changes to mailbox and quit&quot;
+diff --git a/PATCHES b/PATCHES
+--- a/PATCHES
++++ b/PATCHES
+@@ -0,0 +1,1 @@
++patch-1.5.24.trash_folder-purge_message
+diff --git a/commands.c b/commands.c
+--- a/commands.c
++++ b/commands.c
+@@ -720,6 +720,7 @@
+     if (option (OPTDELETEUNTAG))
+       mutt_set_flag (Context, h, M_TAG, 0);
+   }
++  mutt_set_flag (Context, h, M_APPENDED, 1);
+   
+   return 0;
+ }
+diff --git a/curs_main.c b/curs_main.c
+--- a/curs_main.c
++++ b/curs_main.c
+@@ -1919,6 +1919,7 @@
+         MAYBE_REDRAW (menu-&gt;redraw);
+         break;

++      case OP_PURGE_MESSAGE:
+       case OP_DELETE:

+         CHECK_MSGCOUNT;
+@@ -1930,6 +1931,7 @@
+         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-&gt;redraw = REDRAW_INDEX;
+@@ -1937,6 +1939,8 @@
+         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))
+@@ -2242,11 +2246,13 @@
+         if (tag)
+         {
+           mutt_tag_set_flag (M_DELETE, 0);
++          mutt_tag_set_flag (M_PURGED, 0);
+           menu-&gt;redraw = REDRAW_INDEX;
+         }
+         else
+         {
+           mutt_set_flag (Context, CURHDR, M_DELETE, 0);
++          mutt_set_flag (Context, CURHDR, M_PURGED, 0);
+           if (option (OPTRESOLVE) &amp;&amp; menu-&gt;current &lt; Context-&gt;vcount - 1)
+           {
+             menu-&gt;current++;
+@@ -2268,9 +2274,11 @@
+         CHECK_ACL(M_ACL_DELETE, _(&quot;Cannot undelete message(s)&quot;));

+         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 &gt; -1)
+         {
+           if (option (OPTRESOLVE))
+           {
+diff --git a/flags.c b/flags.c
+--- a/flags.c
++++ b/flags.c
+@@ -65,7 +65,13 @@
+       {
+         h-&gt;deleted = 0;
+         update = 1;
+-        if (upd_ctx) ctx-&gt;deleted--;
++        if (upd_ctx)
++        {
++          ctx-&gt;deleted--;
++          if (h-&gt;appended)
++            ctx-&gt;appended--;
++        }
++        h-&gt;appended = 0; /* when undeleting, also reset the appended flag */
+ #ifdef USE_IMAP
+         /* see my comment above */
+         if (ctx-&gt;magic == M_IMAP) 
+@@ -87,6 +93,27 @@
+       }
+       break;

++    case M_APPENDED:
++      if (bf)
++      {
++       if (!h-&gt;appended)
++       {
++         h-&gt;appended = 1;
++         if (upd_ctx) ctx-&gt;appended++;
++       }
++      }
++      break;
++
++    case M_PURGED:
++      if (bf)
++      {
++        if (!h-&gt;purged)
++          h-&gt;purged = 1;
++      }
++      else if (h-&gt;purged)
++        h-&gt;purged = 0;
++      break;
++
+     case M_NEW:

+       if (!mutt_bit_isset(ctx-&gt;rights,M_ACL_SEEN))
+diff --git a/functions.h b/functions.h
+--- a/functions.h
++++ b/functions.h
+@@ -121,6 +121,7 @@
+   { &quot;toggle-write&quot;,                OP_TOGGLE_WRITE,                &quot;%&quot; },
+   { &quot;next-thread&quot;,                OP_MAIN_NEXT_THREAD,                &quot;\016&quot; },
+   { &quot;next-subthread&quot;,                OP_MAIN_NEXT_SUBTHREAD,                &quot;\033n&quot; },
++  { &quot;purge-message&quot;,                OP_PURGE_MESSAGE,                NULL },
+   { &quot;query&quot;,                        OP_QUERY,                        &quot;Q&quot; },
+   { &quot;quit&quot;,                        OP_QUIT,                        &quot;q&quot; },
+   { &quot;reply&quot;,                        OP_REPLY,                        &quot;r&quot; },
+@@ -213,6 +214,7 @@
+   { &quot;print-message&quot;,        OP_PRINT,                        &quot;p&quot; },
+   { &quot;previous-thread&quot;,        OP_MAIN_PREV_THREAD,                &quot;\020&quot; },
+   { &quot;previous-subthread&quot;,OP_MAIN_PREV_SUBTHREAD,        &quot;\033p&quot; },
++  { &quot;purge-message&quot;,        OP_PURGE_MESSAGE,                NULL },
+   { &quot;quit&quot;,                OP_QUIT,                        &quot;Q&quot; },
+   { &quot;exit&quot;,                OP_EXIT,                        &quot;q&quot; },
+   { &quot;reply&quot;,                OP_REPLY,                        &quot;r&quot; },
+diff --git a/globals.h b/globals.h
+--- a/globals.h
++++ b/globals.h
+@@ -141,6 +141,7 @@
+ WHERE char *Status;
+ WHERE char *Tempdir;
+ WHERE char *Tochars;
++WHERE char *TrashPath;
+ WHERE char *TSStatusFormat;
+ WHERE char *TSIconFormat;
+ WHERE short TSSupported;
+diff --git a/imap/message.c b/imap/message.c
+--- a/imap/message.c
++++ b/imap/message.c
+@@ -886,6 +886,7 @@
+         if (ctx-&gt;hdrs[n]-&gt;tagged)
+         {
+           mutt_set_flag (ctx, ctx-&gt;hdrs[n], M_DELETE, 1);
++         mutt_set_flag (ctx, ctx-&gt;hdrs[n], M_APPENDED, 1);
+           if (option (OPTDELETEUNTAG))
+             mutt_set_flag (ctx, ctx-&gt;hdrs[n], M_TAG, 0);
+         }
+@@ -893,6 +894,7 @@
+     else
+     {
+       mutt_set_flag (ctx, h, M_DELETE, 1);
++      mutt_set_flag (ctx, h, M_APPENDED, 1);
+       if (option (OPTDELETEUNTAG))
+         mutt_set_flag (ctx, h, M_TAG, 0);
+     }
+diff --git a/init.h b/init.h
+--- a/init.h
++++ b/init.h
+@@ -3367,6 +3367,16 @@
+   ** provided that ``$$ts_enabled'' has been set. This string is identical in
+   ** formatting to the one used by ``$$status_format''.
+   */
++  { &quot;trash&quot;,           DT_PATH, R_NONE, UL &amp;TrashPath, 0 },
++  /*
++  ** .pp
++  ** If set, this variable specifies the path of the trash folder where the
++  ** mails marked for deletion will be moved, instead of being irremediably
++  ** purged.
++  ** .pp
++  ** NOTE: When you delete a message in the trash folder, it is really
++  ** deleted, so that you have a way to clean the trash.
++  */
+ #ifdef USE_SOCKET
+   { &quot;tunnel&quot;,            DT_STR, R_NONE, UL &amp;Tunnel, UL 0 },
+   /*
+diff --git a/mutt.h b/mutt.h
+--- a/mutt.h
++++ b/mutt.h
+@@ -182,6 +182,8 @@
+   M_DELETE,
+   M_UNDELETE,
+   M_DELETED,
++  M_APPENDED,
++  M_PURGED,
+   M_FLAG,
+   M_TAG,
+   M_UNTAG,
+@@ -711,6 +713,8 @@
+   unsigned int mime : 1;                    /* has a MIME-Version 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 */
+@@ -883,6 +887,7 @@
+   int new;                        /* how many new messages? */
+   int unread;                        /* how many unread messages? */
+   int deleted;                        /* how many deleted messages */
++  int appended;                 /* how many saved messages? */
+   int flagged;                        /* how many flagged messages */
+   int msgnotreadyet;                /* which msg &quot;new&quot; in pager, -1 if none */

+diff --git a/muttlib.c b/muttlib.c
+--- a/muttlib.c
++++ b/muttlib.c
+@@ -1511,7 +1511,9 @@

+   if (magic &gt; 0 &amp;&amp; !mx_access (s, W_OK))
+   {
+-    if (option (OPTCONFIRMAPPEND))
++    if (option (OPTCONFIRMAPPEND) &amp;&amp;
++       (!TrashPath || (mutt_strcmp (s, TrashPath) != 0)))
++      /* if we're appending to the trash, there's no point in asking */
+     {
+       snprintf (tmp, sizeof (tmp), _(&quot;Append messages to %s?&quot;), s);
+       if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
+diff --git a/mx.c b/mx.c
+--- a/mx.c
++++ b/mx.c
+@@ -776,6 +776,54 @@
+   return rc;
+ }

++/* move deleted mails to the trash folder */
++static int trash_append (CONTEXT *ctx)
++{
++    CONTEXT *ctx_trash;
++    int i = 0;
++    struct stat st, stc;
++
++    if (!TrashPath || !ctx-&gt;deleted ||
++       (ctx-&gt;magic == M_MAILDIR &amp;&amp; option (OPTMAILDIRTRASH)))
++      return 0;
++
++    for (;i &lt; ctx-&gt;msgcount &amp;&amp; (!ctx-&gt;hdrs[i]-&gt;deleted ||
++                               ctx-&gt;hdrs[i]-&gt;appended); i++);
++    if (i == ctx-&gt;msgcount)
++      return 0; /* nothing to be done */
++
++    if (mutt_save_confirm (TrashPath, &amp;st) != 0)
++    {
++      mutt_error _(&quot;message(s) not deleted&quot;);
++      return -1;
++    }
++
++    if (lstat (ctx-&gt;path, &amp;stc) == 0 &amp;&amp; stc.st_ino == st.st_ino
++       &amp;&amp; stc.st_dev == st.st_dev &amp;&amp; stc.st_rdev == st.st_rdev)
++      return 0;  /* we are in the trash folder: simple sync */
++
++    if ((ctx_trash = mx_open_mailbox (TrashPath, M_APPEND, NULL)) != NULL)
++    {
++      for (i = 0 ; i &lt; ctx-&gt;msgcount ; i++)
++       if (ctx-&gt;hdrs[i]-&gt;deleted &amp;&amp; !ctx-&gt;hdrs[i]-&gt;appended
++           &amp;&amp; !ctx-&gt;hdrs[i]-&gt;purged
++           &amp;&amp; mutt_append_message (ctx_trash, ctx, ctx-&gt;hdrs[i], 0, 0) == -1)
++         {
++           mx_close_mailbox (ctx_trash, NULL);
++           return -1;
++         }
++
++      mx_close_mailbox (ctx_trash, NULL);
++    }
++    else
++    {
++      mutt_error _(&quot;Can't open trash folder&quot;);
++      return -1;
++    }
++
++    return 0;
++}
++
+ /* save changes and close mailbox */
+ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
+ {
+@@ -912,6 +960,7 @@
+           if (mutt_append_message (&amp;f, ctx, ctx-&gt;hdrs[i], 0, CH_UPDATE_LEN) == 0)
+           {
+             mutt_set_flag (ctx, ctx-&gt;hdrs[i], M_DELETE, 1);
++            mutt_set_flag (ctx, ctx-&gt;hdrs[i], M_APPENDED, 1);
+           }
+           else
+           {
+@@ -936,6 +985,14 @@
+     return 0;
+   }
+   
++  /* copy mails to the trash before expunging */
++  if (purge &amp;&amp; ctx-&gt;deleted)
++    if (trash_append (ctx) != 0)
++    {
++      ctx-&gt;closing = 0;
++      return -1;
++    }
++
+ #ifdef USE_IMAP
+   /* allow IMAP to preserve the deleted flag across sessions */
+   if (ctx-&gt;magic == M_IMAP)
+@@ -1140,6 +1197,12 @@
+   msgcount = ctx-&gt;msgcount;
+   deleted = ctx-&gt;deleted;

++  if (purge &amp;&amp; ctx-&gt;deleted)
++  {
++    if (trash_append (ctx) == -1)
++      return -1;
++  } 
++
+ #ifdef USE_IMAP
+   if (ctx-&gt;magic == M_IMAP)
+     rc = imap_sync_mailbox (ctx, purge, index_hint);
+diff --git a/pager.c b/pager.c
+--- a/pager.c
++++ b/pager.c
+@@ -2351,6 +2351,7 @@
+         MAYBE_REDRAW (redraw);
+         break;

++      case OP_PURGE_MESSAGE:
+       case OP_DELETE:
+         CHECK_MODE(IsHeader (extra));
+         CHECK_READONLY;
+@@ -2358,6 +2359,8 @@
+         CHECK_ACL(M_ACL_DELETE, _(&quot;Cannot delete message&quot;));

+         mutt_set_flag (Context, extra-&gt;hdr, M_DELETE, 1);
++        mutt_set_flag (Context, extra-&gt;hdr, M_PURGED,
++                       ch != OP_PURGE_MESSAGE ? 0 : 1);
+         if (option (OPTDELETEUNTAG))
+           mutt_set_flag (Context, extra-&gt;hdr, M_TAG, 0);
+         redraw = REDRAW_STATUS | REDRAW_INDEX;
+@@ -2688,6 +2691,7 @@
+         CHECK_ACL(M_ACL_DELETE, _(&quot;Cannot undelete message&quot;));

+         mutt_set_flag (Context, extra-&gt;hdr, M_DELETE, 0);
++        mutt_set_flag (Context, extra-&gt;hdr, M_PURGED, 0);
+         redraw = REDRAW_STATUS | REDRAW_INDEX;
+         if (option (OPTRESOLVE))
+         {
+@@ -2704,9 +2708,11 @@
+         CHECK_ACL(M_ACL_DELETE, _(&quot;Cannot undelete message(s)&quot;));

+         r = mutt_thread_set_flag (extra-&gt;hdr, M_DELETE, 0,
++                                  ch == OP_UNDELETE_THREAD ? 0 : 1)
++          + mutt_thread_set_flag (extra-&gt;hdr, M_PURGED, 0,
+                                   ch == OP_UNDELETE_THREAD ? 0 : 1);

+-        if (r != -1)
++        if (r &gt; -1)
+         {
+           if (option (OPTRESOLVE))
+           {
+diff --git a/pattern.c b/pattern.c
+--- a/pattern.c
++++ b/pattern.c
+@@ -1367,8 +1367,10 @@
+       {
+         switch (op)
+         {
++          case M_UNDELETE:
++            mutt_set_flag (Context, Context-&gt;hdrs[Context-&gt;v2r[i]], M_PURGED,
++                           0);
+           case M_DELETE:
+-          case M_UNDELETE:
+             mutt_set_flag (Context, Context-&gt;hdrs[Context-&gt;v2r[i]], M_DELETE, 
+                           (op == M_DELETE));
+             break;
+diff --git a/postpone.c b/postpone.c
+--- a/postpone.c
++++ b/postpone.c
+@@ -277,6 +277,9 @@
+   /* finished with this message, so delete it. */
+   mutt_set_flag (PostContext, h, M_DELETE, 1);

++  /* and consider it saved, so that it won't be moved to the trash folder */
++  mutt_set_flag (PostContext, h, M_APPENDED, 1);
++
+   /* update the count for the status display */
+   PostCount = PostContext-&gt;msgcount - PostContext-&gt;deleted;

</ins></span></pre>
</div>
</div>

</body>
</html>