<<< Date Index >>>     <<< Thread Index >>>

Re: Collapse all threads except the one you are on



* David Fishburn <fishburn@xxxxxxxxxxxxx> [2003-10-23 13:40 -0400]:
> 
> Seems this always fails to post when I send it from my Linux account.
> Anyway, sorry if this is duplicated.
> 
> Question 1:
> I have read through the manual (/collapse), but I dont really see what I
> 
> am looking for.
> 
> I would like to have all threads collapsed.
> But when I jump to the next unread (Tab) I want Mutt to automatically 
> uncollapse that thread.
> 
> If possible, when I finish reading that email and go to the next unread 
> (Tab) I want Mutt to collapse the current thread and uncollapse the one
> I just 
> moved to.
> 
> Is this possible?

set collapse_unread
set uncollapse_jump
set sort=threads
folder-hook . 'push <collapse-all><collapse-thread>'
macro index <tab> 
"<collapse-thread><previous-entry><next-unread><collapse-thread>"

> Question 2:
> I added a very simple colouring for index:
> color index brightwhite black '~N'
> color index brightwhite yellow '~U'
> 
> Which works out pretty well when the thread is uncollapsed.
> But what I was really trying to do (assuming question 1 setup) was when
> the thread is collapsed and there are unread messages, Mutt places an
> "n" after the # sign.  Based on that, I want to change the colour of the
> collapsed line to indicate that there are additional unread items
> within.
> 
> So I have:
> set collapse_unread=yes
> color index brightwhite yellow '~U ~v'
> 
> I tried adding ~v since the help indicates message is part of a
> collapsed thread, but it did not help.

The patch below adds the ~u pattern which maches against any messages in a
thread which contains any unread messages.

Warning: This is a work in progress; I haven't thouroughly tested it (as you
can see from the file dates, I've just been working on it today). Also, if
new mail arrives while a mailbox is limited with this pattern, and that mail
belongs to a thread which is hidden, the rest of the thread will not be
unhidden. I'd be much obliged if someone with more experience with the code
could change that (I've been tearing my hair out over it for days).

diff -Npru mutt-1.4.1-orig/doc/manual.sgml mutt-1.4.1/doc/manual.sgml
--- mutt-1.4.1-orig/doc/manual.sgml     2003-03-20 09:11:46.000000000 +1100
+++ mutt-1.4.1/doc/manual.sgml  2003-10-24 19:38:41.000000000 +1000
@@ -1714,6 +1714,7 @@ messages:
 ~T              tagged messages
 ~t USER         messages addressed to USER
 ~U              unread messages
+~u              messages in threads which contain any unread messages
 ~v             message is part of a collapsed thread.
 ~x EXPR         messages which contain EXPR in the `References' field
 ~y EXPR         messages which contain EXPR in the `X-Label' field
diff -Npru mutt-1.4.1-orig/doc/manual.sgml.head mutt-1.4.1/doc/manual.sgml.head
--- mutt-1.4.1-orig/doc/manual.sgml.head        2002-10-10 19:43:11.000000000 
+1000
+++ mutt-1.4.1/doc/manual.sgml.head     2003-10-24 19:38:41.000000000 +1000
@@ -1714,6 +1714,7 @@ messages:
 ~T              tagged messages
 ~t USER         messages addressed to USER
 ~U              unread messages
+~u              messages in threads which contain any unread messages
 ~v             message is part of a collapsed thread.
 ~x EXPR         messages which contain EXPR in the `References' field
 ~y EXPR         messages which contain EXPR in the `X-Label' field
diff -Npru mutt-1.4.1-orig/doc/manual.txt mutt-1.4.1/doc/manual.txt
--- mutt-1.4.1-orig/doc/manual.txt      2003-03-20 09:11:51.000000000 +1100
+++ mutt-1.4.1/doc/manual.txt   2003-10-24 19:38:41.000000000 +1000
@@ -2003,6 +2003,7 @@
        ~T              tagged messages
        ~t USER         messages addressed to USER
        ~U              unread messages
+       ~u              messages in threads which contain any unread messages
        ~v              message is part of a collapsed thread.
        ~x EXPR         messages which contain EXPR in the `References' field
        ~y EXPR         messages which contain EXPR in the `X-Label' field
diff -Npru mutt-1.4.1-orig/doc/muttrc.man mutt-1.4.1/doc/muttrc.man
--- mutt-1.4.1-orig/doc/muttrc.man      2003-03-20 08:41:34.000000000 +1100
+++ mutt-1.4.1/doc/muttrc.man   2003-10-24 19:38:41.000000000 +1000
@@ -365,6 +365,7 @@ l l.
 ~T     tagged messages
 ~t \fIEXPR\fP  messages addressed to \fIEXPR\fP
 ~U     unread messages
+~u     messages in threads which contain any unread messages
 ~v     message is part of a collapsed thread.
 ~x \fIEXPR\fP  messages which contain \fIEXPR\fP in the \(lqReferences\(rq 
field
 ~z \fIMIN\fP-\fIMAX\fP messages with a size in the range \fIMIN\fP to \fIMAX\fP
diff -Npru mutt-1.4.1-orig/doc/muttrc.man.head mutt-1.4.1/doc/muttrc.man.head
--- mutt-1.4.1-orig/doc/muttrc.man.head 2002-05-09 19:51:46.000000000 +1000
+++ mutt-1.4.1/doc/muttrc.man.head      2003-10-24 19:38:41.000000000 +1000
@@ -365,6 +365,7 @@ l l.
 ~T     tagged messages
 ~t \fIEXPR\fP  messages addressed to \fIEXPR\fP
 ~U     unread messages
+~u     messages in threads which contain any unread messages
 ~v     message is part of a collapsed thread.
 ~x \fIEXPR\fP  messages which contain \fIEXPR\fP in the \(lqReferences\(rq 
field
 ~z \fIMIN\fP-\fIMAX\fP messages with a size in the range \fIMIN\fP to \fIMAX\fP
diff -Npru mutt-1.4.1-orig/mutt.h mutt-1.4.1/mutt.h
--- mutt-1.4.1-orig/mutt.h      2002-07-24 19:46:58.000000000 +1000
+++ mutt-1.4.1/mutt.h   2003-10-24 19:38:41.000000000 +1000
@@ -229,6 +229,7 @@ enum
   M_PGP_KEY,
 #endif
   M_XLABEL,
+  M_UNREAD_THREAD,
   
   /* Options for Mailcap lookup */
   M_EDIT,
diff -Npru mutt-1.4.1-orig/PATCHES mutt-1.4.1/PATCHES
--- mutt-1.4.1-orig/PATCHES     2001-11-27 06:16:52.000000000 +1100
+++ mutt-1.4.1/PATCHES  2003-10-24 19:38:41.000000000 +1000
@@ -1,0 +1 @@
+patch-1.4.1.jgc.pattern-thread-unread.2
diff -Npru mutt-1.4.1-orig/pattern.c mutt-1.4.1/pattern.c
--- mutt-1.4.1-orig/pattern.c   2002-05-18 15:39:55.000000000 +1000
+++ mutt-1.4.1/pattern.c        2003-10-24 19:38:41.000000000 +1000
@@ -21,6 +21,7 @@
 #include "keymap.h"
 #include "mailbox.h"
 #include "copy.h"
+#include "sort.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -86,6 +87,7 @@ Flags[] =
   { 'T', M_TAG,                        0,              NULL },
   { 't', M_TO,                 0,              eat_regexp },
   { 'U', M_UNREAD,             0,              NULL },
+  { 'u', M_UNREAD_THREAD,      0,              NULL },
   { 'v', M_COLLAPSED,          0,              NULL },
   { 'x', M_REFERENCE,          0,              eat_regexp },
   { 'y', M_XLABEL,             0,              eat_regexp },
@@ -984,6 +986,8 @@ mutt_pattern_exec (struct pattern_t *pat
       return (pat->not ? h->old || h->read : !(h->old || h->read));
     case M_UNREAD:
       return (pat->not ? h->read : !h->read);
+    case M_UNREAD_THREAD:
+      return (pat->not ^ !h->read || ((Sort & SORT_MASK) == SORT_THREADS && 
h->thread && mutt_thread_contains_unread (ctx, h)));
     case M_REPLIED:
       return (pat->not ^ h->replied);
     case M_OLD:
-- 
Joshua 'bruce' Crawford ... http://www.geocities.com/mortarn

Radioactive cats have 18 half-lives.

Attachment: pgpjwSgQfp0mj.pgp
Description: PGP signature