From d2facf5ade8ae6d0831a2b8496b2c1017a935172 Mon Sep 17 00:00:00 2001 From: pdmef Date: Sun, 9 Oct 2005 15:12:42 +0000 Subject: [PATCH] Rocco Rutte: - fix attachment counting stuff to not always re-count everything - add $count_attachments (similar to scoring works) - add note about speed issues for counting to manual git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@544 e385b8ad-14ed-0310-8656-cc95a2468c6d --- UPGRADING | 4 +++- VERSION.svn | 2 +- doc/manual.xml.head | 8 ++++++++ hdrline.c | 14 ++++++-------- init.h | 12 ++++++++++++ mutt.h | 1 + parse.c | 2 ++ 7 files changed, 33 insertions(+), 10 deletions(-) diff --git a/UPGRADING b/UPGRADING index 9cd2ce9..1af4ff7 100644 --- a/UPGRADING +++ b/UPGRADING @@ -14,7 +14,9 @@ sources of information. The "attachments" and "unattachments" commands were added. The %X expando has been added to $index_format. The ~X pattern has been - added. The %Q and %X expandos have been added to $attach_format. + added. The %Q and %X expandos have been added to $attach_format. For + better control purpose, the $count_attachments variable has been + added, too. As part of the above addition(s), the 'A' message status flag has been removed again. diff --git a/VERSION.svn b/VERSION.svn index 849baee..4970e69 100644 --- a/VERSION.svn +++ b/VERSION.svn @@ -1 +1 @@ -543 +544 diff --git a/doc/manual.xml.head b/doc/manual.xml.head index 671402a..2c06da4 100644 --- a/doc/manual.xml.head +++ b/doc/manual.xml.head @@ -9363,6 +9363,14 @@ attachments -I message/external-body that it can be pasted elsewhere. + + Please note that counting attachments may require lots of data be + loaded. This may cause noticeable slowdowns over network links + depending on the connection speed and message sizes. To fine-tune the + behavior on a per-folder or other basis, the variable may be used. + + diff --git a/hdrline.c b/hdrline.c index d120175..bd83a43 100644 --- a/hdrline.c +++ b/hdrline.c @@ -633,14 +633,12 @@ static const char *hdr_format_str (char *dest, case 'X': { - int count, flags = 0; - - if (hdr->content->parts) - count = mutt_count_body_parts(hdr, flags); - else { - mutt_parse_mime_message(ctx, hdr); - count = mutt_count_body_parts(hdr, flags); - mutt_free_body(&hdr->content->parts); + int count = 0; + + if (option (OPTCOUNTATTACH)) { + if (!hdr->content->parts) + mutt_parse_mime_message(ctx, hdr); + count = mutt_count_body_parts(hdr, 0); } /* The recursion allows messages without depth to return 0. */ diff --git a/init.h b/init.h index 3b37369..24dec7d 100644 --- a/init.h +++ b/init.h @@ -409,6 +409,18 @@ struct option_t MuttVars[] = { ** When \fIunset\fP, Mutt-ng will not collapse a thread if it contains any ** unread messages. */ + {"count_attachments", DT_BOOL, R_NONE, OPTCOUNTATTACH, "yes"}, + /* + ** .pp + ** This variable controls whether attachments should be counted for $$$index_format + ** and its \fT%X\fP expando or not. As for scoring, this variable can be used to + ** selectively turn counting on or off instead of removing and re-adding rules as + ** prefered because counting requires full loading of messages. + ** .pp + ** If it is \fIset\fP and rules were defined via the \fTattachments\fP and/or + ** \fTunattachments\fP commands, counting will be done. If it is \fIunset\fP no + ** counting will be done regardless whether rules were defined or not. + */ {"uncollapse_jump", DT_BOOL, R_NONE, OPTUNCOLLAPSEJUMP, "no" }, /* ** .pp diff --git a/mutt.h b/mutt.h index 13c916b..44dcd9b 100644 --- a/mutt.h +++ b/mutt.h @@ -318,6 +318,7 @@ enum { OPTCOLLAPSEUNREAD, OPTCONFIRMAPPEND, OPTCONFIRMCREATE, + OPTCOUNTATTACH, OPTDELETEUNTAG, OPTDELSP, OPTDIGESTCOLLAPSE, diff --git a/parse.c b/parse.c index bf7d76d..036a183 100644 --- a/parse.c +++ b/parse.c @@ -1551,6 +1551,8 @@ int count_body_parts (BODY *body, int flags) { } int mutt_count_body_parts (HEADER *hdr, int flags) { + if (!option (OPTCOUNTATTACH)) + return (0); if (hdr->attach_valid && !(flags & M_PARTS_RECOUNT)) return hdr->attach_total; -- 2.20.1