Rocco Rutte:
authorpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 9 Oct 2005 15:12:42 +0000 (15:12 +0000)
committerpdmef <pdmef@e385b8ad-14ed-0310-8656-cc95a2468c6d>
Sun, 9 Oct 2005 15:12:42 +0000 (15:12 +0000)
- 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
VERSION.svn
doc/manual.xml.head
hdrline.c
init.h
mutt.h
parse.c

index 9cd2ce9..1af4ff7 100644 (file)
--- 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.
index 849baee..4970e69 100644 (file)
@@ -1 +1 @@
-543
+544
index 671402a..2c06da4 100644 (file)
@@ -9363,6 +9363,14 @@ attachments -I message/external-body
 that it can be pasted elsewhere.
 </para>
 
+<para>
+  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 <muttng-doc:varref
+    name="count-attachments"/> variable may be used.
+</para>
+
 </sect1>
 
     <sect1>
index d120175..bd83a43 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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 (file)
--- 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;