mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add imap-fast-trash patch.

This is based on the patch by Paul Miller.

Modifications are:

* Create a new flag, MUTT_TRASH for imap_make_msg_set(), rather than
use MUTT_EXPIRED.

* Change imap_make_msg_set(MUTT_TRASH) to only look at
hdrs[n]->deleted && !hdrs[n]->purge, behaving like MUTT_TAG, rather
than looking at the HEADER_DATA.

* Reimplement imap_fast_trash() based on imap_copy_message().
It looks the old version was too, but it lacked handling of TRYCREATE
and also queued the UID COPY but didn't exec it. (Presumably this
happened in the subsequent sync).

* Move the Context magic and mx_is_imap() checks outside of
imap_fast_trash()

+109
+99
imap/imap.c
··· 924 924 if (hdrs[n]->tagged) 925 925 match = 1; 926 926 break; 927 + case MUTT_TRASH: 928 + if (hdrs[n]->deleted && !hdrs[n]->purge) 929 + match = 1; 930 + break; 927 931 } 928 932 929 933 if (match && (!changed || hdrs[n]->changed)) ··· 2071 2075 } 2072 2076 2073 2077 return -1; 2078 + } 2079 + 2080 + /* imap_fast_trash: use server COPY command to copy deleted 2081 + * messages to the trash folder. 2082 + * Return codes: 2083 + * -1: error 2084 + * 0: success 2085 + * 1: non-fatal error - try fetch/append */ 2086 + int imap_fast_trash (CONTEXT* ctx, char* dest) 2087 + { 2088 + IMAP_DATA* idata; 2089 + char mbox[LONG_STRING]; 2090 + char mmbox[LONG_STRING]; 2091 + char prompt[LONG_STRING]; 2092 + int rc; 2093 + IMAP_MBOX mx; 2094 + int triedcreate = 0; 2095 + 2096 + idata = (IMAP_DATA*) ctx->data; 2097 + 2098 + if (imap_parse_path (dest, &mx)) 2099 + { 2100 + dprint (1, (debugfile, "imap_fast_trash: bad destination %s\n", dest)); 2101 + return -1; 2102 + } 2103 + 2104 + /* check that the save-to folder is in the same account */ 2105 + if (!mutt_account_match (&(CTX_DATA->conn->account), &(mx.account))) 2106 + { 2107 + dprint (3, (debugfile, "imap_fast_trash: %s not same server as %s\n", 2108 + dest, ctx->path)); 2109 + return 1; 2110 + } 2111 + 2112 + imap_fix_path (idata, mx.mbox, mbox, sizeof (mbox)); 2113 + if (!*mbox) 2114 + strfcpy (mbox, "INBOX", sizeof (mbox)); 2115 + imap_munge_mbox_name (idata, mmbox, sizeof (mmbox), mbox); 2116 + 2117 + /* loop in case of TRYCREATE */ 2118 + do 2119 + { 2120 + rc = imap_exec_msgset (idata, "UID COPY", mmbox, MUTT_TRASH, 0, 0); 2121 + if (!rc) 2122 + { 2123 + dprint (1, (debugfile, "imap_fast_trash: No messages to trash\n")); 2124 + rc = -1; 2125 + goto out; 2126 + } 2127 + else if (rc < 0) 2128 + { 2129 + dprint (1, (debugfile, "could not queue copy\n")); 2130 + goto out; 2131 + } 2132 + else 2133 + mutt_message (_("Copying %d messages to %s..."), rc, mbox); 2134 + 2135 + /* let's get it on */ 2136 + rc = imap_exec (idata, NULL, IMAP_CMD_FAIL_OK); 2137 + if (rc == -2) 2138 + { 2139 + if (triedcreate) 2140 + { 2141 + dprint (1, (debugfile, "Already tried to create mailbox %s\n", mbox)); 2142 + break; 2143 + } 2144 + /* bail out if command failed for reasons other than nonexistent target */ 2145 + if (ascii_strncasecmp (imap_get_qualifier (idata->buf), "[TRYCREATE]", 11)) 2146 + break; 2147 + dprint (3, (debugfile, "imap_fast_trash: server suggests TRYCREATE\n")); 2148 + snprintf (prompt, sizeof (prompt), _("Create %s?"), mbox); 2149 + if (option (OPTCONFIRMCREATE) && mutt_yesorno (prompt, 1) < 1) 2150 + { 2151 + mutt_clear_error (); 2152 + goto out; 2153 + } 2154 + if (imap_create_mailbox (idata, mbox) < 0) 2155 + break; 2156 + triedcreate = 1; 2157 + } 2158 + } 2159 + while (rc == -2); 2160 + 2161 + if (rc != 0) 2162 + { 2163 + imap_error ("imap_fast_trash", idata->buf); 2164 + goto out; 2165 + } 2166 + 2167 + rc = 0; 2168 + 2169 + out: 2170 + FREE (&mx.mbox); 2171 + 2172 + return rc < 0 ? -1 : rc; 2074 2173 } 2075 2174 2076 2175 struct mx_ops mx_imap_ops = {
+1
imap/imap.h
··· 43 43 int imap_search (CONTEXT* ctx, const pattern_t* pat); 44 44 int imap_subscribe (char *path, int subscribe); 45 45 int imap_complete (char* dest, size_t dlen, char* path); 46 + int imap_fast_trash (CONTEXT* ctx, char* dest); 46 47 47 48 void imap_allow_reopen (CONTEXT *ctx); 48 49 void imap_disallow_reopen (CONTEXT *ctx);
+1
mutt.h
··· 189 189 MUTT_LIMIT, 190 190 MUTT_EXPIRED, 191 191 MUTT_SUPERSEDED, 192 + MUTT_TRASH, 192 193 193 194 /* actions for mutt_pattern_comp/mutt_pattern_exec */ 194 195 MUTT_AND,
+8
mx.c
··· 832 832 && stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev) 833 833 return 0; /* we are in the trash folder: simple sync */ 834 834 835 + #ifdef USE_IMAP 836 + if (Context->magic == MUTT_IMAP && mx_is_imap (TrashPath)) 837 + { 838 + if (!imap_fast_trash (Context, TrashPath)) 839 + return 0; 840 + } 841 + #endif 842 + 835 843 if ((ctx_trash = mx_open_mailbox (TrashPath, MUTT_APPEND, NULL)) != NULL) 836 844 { 837 845 /* continue from initial scan above */