Discussion:
Collapse all threads except the one you are on
David Fishburn
2003-10-23 17:40:40 UTC
Permalink
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?


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.



TIA,
Dave
David Fishburn
2003-10-24 14:43:32 UTC
Permalink
Post by David Fishburn
Seems this always fails to post when I send it from my Linux
account. Anyway, sorry if this is duplicated.
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?
I think this is possible, but it would require creating a macro that
will issue multiple commands.
There are no examples in the Help (1.4.1) and I didn't find similar
examples in google.

So basically, I need to do something like this (can someone help me with
the syntax):
macro ,C collapse-thread | next-unread | collapse-thread

How do you issue multiple commands in a macro?

There does not appear to be a command to uncollapse a thread, only a
command to toggle whether the thread is collapsed or not. If my macro
above is going to work, I need to be able to close or open (don't
toggle).

Any ideas?
Post by David Fishburn
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.
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.
Any suggestions here?

Thanks,
Dave
Allister MacLeod
2003-10-24 15:03:21 UTC
Permalink
Post by David Fishburn
So basically, I need to do something like this (can someone help me with
macro ,C collapse-thread | next-unread | collapse-thread
How do you issue multiple commands in a macro?
You just run them together..
macro index ,C "<collapse-thread><next-unread><collapse-thread>"
As far as I know, this doesn't work with plain command names as you
used above. One caveat to using <foo> is that if "foo" isn't defined
in the current map, the macro ends up being "<" "f" "o" "o" ">" (which
might end up being a scroll up, some weird stuff, and a scroll down,
depending on your keybindings)
Post by David Fishburn
There does not appear to be a command to uncollapse a thread, only a
command to toggle whether the thread is collapsed or not. If my macro
above is going to work, I need to be able to close or open (don't
toggle).
This is one of the points on which I am disappointed with mutt's
macros (if you want a list, ask me, and I'll compile it and post
separately.) However, if you can assume that all your threads will be
collapsed except the one containing the current message, then your
macro should always work as expected.

Where you'll run into problems is if you use the ,C macro to jump into
a thread, then move off the thread with plain old "next-entry" or
something, and use ,C again. If you've moved to a collapsed thread
head, you could potentially end up with 3 threads uncollapsed.
Fortunately none of the commands in the ,C macro are destructive, so
you could always clean up your thread-collapsedness by hand.

Another option would be to use <collapse-all> in place of the first
<collapse-thread>. That way, unless you used ,C on a 100% collapsed
view, it would collapse everything before moving to the next unread
message.

Arrivederci,
Allister
--
Allister MacLeod <***@mv3d.com>
Elen síla lúmenn'omentielvo.
Allister MacLeod
2003-10-24 15:17:34 UTC
Permalink
... following David's laudable tradition of replying to oneself :-) ...
Post by Allister MacLeod
Another option would be to use <collapse-all> in place of the first
<collapse-thread>. That way, unless you used ,C on a 100% collapsed
view, it would collapse everything before moving to the next unread
message.
Er.. scratch that. Apparently I was mistaken about the behavior of
collapse-all. I had thought it would recollapse everything if one
thread had been uncollapsed.. but it actually seems to just toggle to
the opposite state of the previous collapse-all.

In the process of testing this, I discovered that
<next-unread><collapse-thread> might not have the desired behavior
either. When moving to a collapsed thread with an unread message, it
will remain at the head of the thread even when uncollapsing. Thus,
if the new message is a followup, it will not be the current message
after the operation.

With C=<collapse-thread> and N=<next-unread>, you could do "C N C N",
which would properly select followups within the thread.
Unfortunately, I think it would fail miserably if the new message is,
in fact, the head of the thread. Perhaps "C N C <previous-entry> N"
would work (unless the first N brings you to a thread-head at the very
beginning of the folder.)

Nanoo nanoo,
Allister
--
Allister MacLeod <***@mv3d.com>
Elen síla lúmenn'omentielvo.
Joshua Crawford
2003-10-24 15:50:40 UTC
Permalink
Post by David Fishburn
Seems this always fails to post when I send it from my Linux account.
Anyway, sorry if this is duplicated.
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>"
Post by David Fishburn
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.
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.
David Fishburn
2003-10-24 18:37:31 UTC
Permalink
Post by David Fishburn
Post by David Fishburn
I would like to have all threads collapsed.
But when I jump to the next unread (Tab) I want Mutt to
automatically
Post by David Fishburn
uncollapse that thread.
...
Post by David Fishburn
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>"
Joshua, Allister, thank you for your help.
This is working very well for me.

I used:
macro index <tab>
"<collapse-thread><next-unread><collapse-thread>"

The <previous-entry> doesn't work as expected.

Joshua, you also asked my follow on question about folder-hook.
Push was the answer.
Post by David Fishburn
Post by David Fishburn
color index brightwhite black '~N'
color index brightwhite yellow '~U'
I haven't tried this yet.
Do these patches make it into released code, or are they just add ons?

Thanks,
Dave
Joshua Crawford
2003-10-24 20:03:15 UTC
Permalink
Post by David Fishburn
Post by David Fishburn
Post by David Fishburn
I would like to have all threads collapsed.
But when I jump to the next unread (Tab) I want Mutt to
automatically
Post by David Fishburn
uncollapse that thread.
...
Post by David Fishburn
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>"
Joshua, Allister, thank you for your help.
No trouble.
Post by David Fishburn
This is working very well for me.
macro index <tab>
"<collapse-thread><next-unread><collapse-thread>"
The <previous-entry> doesn't work as expected.
It worked the way I expected, which is to stay in the same thread if there
are more new messages there, except if it's the first thread (since there is
no previous-entry there).
Post by David Fishburn
Joshua, you also asked my follow on question about folder-hook.
You can read my mind can you? I only posted an answer, not a question :)

Actually, you said "I would like to have all threads collapsed." and AFAIK
the only way to do that is with a folder-hook.
Post by David Fishburn
Push was the answer.
An answer. You could also use exec, but this way there's one push, where
there'd be two execs.
Post by David Fishburn
Post by David Fishburn
Post by David Fishburn
color index brightwhite black '~N'
color index brightwhite yellow '~U'
I haven't tried this yet.
Do these patches make it into released code, or are they just add ons?
If a patch is stable and used by enough people the developers might include
it.
--
Joshua 'bruce' Crawford ... http://www.geocities.com/mortarn

Have it OUR way. Yours is IRRELEVANT. At BORGerKing.
Loading...