On Wed, Feb 07, 2018 at 10:00:33PM +0000, Cameron Simpson wrote: > On 07Feb2018 01:05, Scott Kostyshak <skostys...@ufl.edu> wrote: > > I would like to color all header lines in the pager if a message pattern > > matches. > > > > As an example, I can use the following to color the index if a message > > was sent to me and not sent to a list: > > > > color index yellow black ~p!~l > > > > But I cannot do the following: > > > > color header yellow black ~p!~l > > > > to color all headers in the pager if a message was sent to me and not > > sent to a list. This is understandable, as the pattern is matched > > against each header. > > > > As for why I would like to do this, I rarely look at the index. I > > configure mutt to go directly to the pager, so that I focus on one email > > at a time. However, I find the message pattern matching useful so I > > would like to be able to use them to color headers in the pager. > > > > Is it possible to use the message pattern mechanism to color headers > > showing in the pager? > > Yes, you need to be a little indirect. > > My setup has these lines: > > color header $colour_hl1 default "^(from|subject):" > color header $colour_hl1 default "^(x-spam-status):" > > Where $colour_hl1 happens to be cyan. What you want to do is, instead of > defining your header rules once, define them per message via a message-hook. > Example (untested): > > message-hook . 'set my_hdr_colour=green' > message-hook ~p!~l 'set my_hdr_colour=yellow' > message-hook . 'color header $my_hdr_colour default' > > so that a colour is chosen per message, then applied to your settings. > > Cheers, > Cameron Simpson <c...@cskk.id.au> (formerly c...@zip.com.au)
I think that does the trick! I had to change the last of the three hooks to be the following (note the dot at the end): message-hook . 'color header $my_hdr_colour default .' Thank you very much for taking the time to understand what I was trying to achieve, and for the helpful solution, Cameron. Best, Scott -- Scott Kostyshak Assistant Professor of Economics University of Florida https://people.clas.ufl.edu/skostyshak/