Colorizing index lines that match two patterns
Akkana Peck
akkana at shallowsky.com
Thu Mar 25 21:09:56 UTC 2021
The recent discussion on counting attachments was a revelation --
what a fantastic feature, which I hadn't realized mutt could do!
I set up an attachments definition:
attachments +A */.*
attachments -A text/.*
attachments -I */.*
and then set up a color for index lines with one or more non-text
attachments:
color index red white "~X 1-"
That was great, but I found I had a problem with, for instance,
messages that were new (which I'd normally show with blue text) AND
had attachments (I want the white background). I couldn't find any
documentation on how to combine two patterns;
http://www.mutt.org/doc/manual/#patterns
has an excellent list of patterns, while
http://www.mutt.org/doc/manual/#complex-patterns
tells how to match a message that has pattern1 OR pattern2 ...
but it doesn't give a way to match a message that has both pattern1
AND pattern2. I tried:
"~N ~X 1-"
~N ~X 1-
"~N && ~X 1-"
"~N" "~X 1-"
but they all gave syntax errors.
But along the way, I accidentally made a typo that I never would
have thought to try, but it gave me something that actually works:
"~N ~X 1-
Note the double quote at the beginning but no matching close quote.
It even works multiple times:
color index brightmagenta white "~F ~X 1-
color index brightblue white "~N ~X 1-
Is this a bug? Is there a better syntax for messages that match
multiple patterns?
Even better, is there a way I could have a rule that sets just the
foreground or just the background? E.g. if I could say
color index brightblue default "~N"
color index default white "~X 1-"
and a message that was both new and had attachments would take the
foreground color from the first rule but the background color from
the second rule? In practice, what that does is ignore the first
rule and apply the second rule to any message that matches both.
So instead of "default" I'd need something that led mutt not to
set a color, but allow the colors from other rules to apply.
I'm using Mutt 1.14.6 on Ubuntu.
...Akkana
More information about the Mutt-users
mailing list