color body paragraphs

color body paragraphs

Post by Troy Piggi » Thu, 01 Feb 2007 09:51:13


Was trying to figure out a way to get mutt to color more than one
line. For example, if a code block was being quoted with
verbatim marks like this:

#v+
code goes here
more code goes here
#v-

Is it possible to write a color body pattern that colors
everything between the verbatim marks?

I was thinking something like this, but it didn't work:

color body magenta default "^#v\+(.*\n)+^#v\-"

Has anyone tried something like this?

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://www.yqcomputer.com/ ~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4pr6OSck1ma9u6LwXm5l6Di2e6t5MGSRb8OTen4g7OPa3Xs7MIr8p7
 
 
 

color body paragraphs

Post by Rudy Taras » Fri, 02 Feb 2007 13:19:34

Hey Troy,




Unless I misunderstand the question, you can get verbatim coloring
with these lines in your .slrnrc;

#v+
% If non-zero, #v+ and #v- will be used as markers of verbatim lines
set process_verbatim_marks 1
% If non-zero, #v+/#v- verbatim marks will be hidden
set hide_verbatim_marks 0
color verbatim "green" "default"
#v-

Something tells me that's not the answer you're looking for though.

/rudy

 
 
 

color body paragraphs

Post by Gary Johns » Fri, 02 Feb 2007 15:23:26


I think mutt can color only single lines, but I'm not sure--I don't
have
access to the code at the moment.

However, I have colored multi-line patterns by setting
'display_filter' to a
Perl script that inserts ANSI color escape sequences in the message
text
before it's displayed.

HTH,
Gary
 
 
 

color body paragraphs

Post by Troy Piggi » Fri, 02 Feb 2007 17:26:24

* Rudy Taraschi is quoted & my replies are inline below :


The only thing you misunderstood is that I am talking about mutt,
not slrn ;)


Already got that taken care of.


Nope :)

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://www.yqcomputer.com/ ~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4pr6OSck1ma9u6LwXm5l6Di2e6t5MGSRb8OTen4g7OPa3Xs7MIr8p7
 
 
 

color body paragraphs

Post by Troy Piggi » Fri, 02 Feb 2007 17:29:25

* Gary Johnson is quoted & my replies are inline below :


Aah, nice idea. Don't suppose you could point me in the
direction of said script? :)

PS - I'm using your mail-to-filter - thanks for that :)

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://www.yqcomputer.com/ ~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4pr6OSck1ma9u6LwXm5l6Di2e6t5MGSRb8OTen4g7OPa3Xs7MIr8p7
 
 
 

color body paragraphs

Post by Troy Piggi » Sat, 03 Feb 2007 21:26:58

* Gary Johnson is quoted & my replies are inline below :


I've been looking into this a bit. Can't get it to work, and I'm
curious what I'm doing wrong.

I have used this line in a bash script to colourise tail words
with success:

#v+
FILE=/path/to/file
WORD=match_me
FG_COL=123
BG_COL=234
tail -n 30 -f ${FILE} | perl -pe \
"s/${WORD}/\e[38;5;${FG_COL}m\e[48;5;${BG_COL}m$&\e[0m/g"
#v-

So I added something like this to my display filter script, but
it has no effect:

#v+
sed -e 'stuff' \
| t-prot -aceklmt -S=5 --bigq=20,10 --diff -Mmutt --sigsmax=1 \
--spass -L${HOME}/.mutt/mlfooters -A${HOME}/.mutt/adfooters \
\
| ${HOME}/bin/mail-to-filter \
| perl -pe "s/the/\e[38;5;0m\e[48;5;196m$&\e[0m/g"
#v-

Without the last line it works fine. With the last line it still
works, but the word "the" is not colourised (once I get it
working I'll try more complicated matches etc).

Any ideas?

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://www.yqcomputer.com/ ~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4pr6OSck1ma9u6LwXm5l6Di2e6t5MGSRb8OTen4g7OPa3Xs7MIr8p7
 
 
 

color body paragraphs

Post by Rudy Taras » Sun, 04 Feb 2007 07:13:10


Well, why didn't you say so?

[rereads Troy's original post]

Oh well ... at least one of us is awake ;-)

What you're trying to do won't work because of one simple fact;
mutt's built-in pager does it's pattern matching and color
formatting on a line by line basis, and doesn't remember what
happened in the previous lines (see pager.c in the mutt source)

Here's a recipe to get you started on what you want to do. When I
first wrote it, I had great plans to make it perfect, but never
touched it again because (a) I'm lazy and (b) it works. It can
definitely be optimized and improved upon (bolding or undelining
should be inhibited within verbatim blocks because it does funny
things). Let me know how it goes, or if anything is unclear.
Cheers!

/rudy


1) make sure you have the following lines in your ~/.muttrc

set pager=builtin
set allow_ansi
auto_view text/plain

2) make sure you have this in your ~/.mailcap

text/plain; sed -f mutt_display_filter.sed ; copiousoutput

3) create a file called ~/mutt_display_filter.sed with these lines:

/^#v+/,/^#v-/s/.*/\x1B[33m&/
s/^_\([^_]*\)_/\x1B[4m\1\x1B[0m/g
s/ _\([^_]*\)_/ \x1B[4m\1\x1B[0m/g
s/^\*\([^\*]*\)\*/\x1B[1m\1\x1B[0m/g
s/ \*\([^\*]*\)\*/ \x1B[1m\1\x1B[0m/g
 
 
 

color body paragraphs

Post by Troy Piggi » Sun, 04 Feb 2007 17:17:23

* Rudy Taraschi is quoted & my replies are inline below :


[snip]

:)


Thanks mate. That works!
I have questions below.


In my pager, the text in verbatim marks comes out yellow, or
color3, in 256 colour term. I'm having trouble figuring out
where the colours are set above. I have in the past used:

perl -pe "s/${WORD}/\e[38;5;${FG_COL}m\e[48;5;${BG_COL}m$&\e[0m/g"

understanding the ink: ESC [38;5;<color>m and paper: ESC [48;5;<color>m

I should point out that I just copied your code above rather than
using ctrl-v etc.

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://www.yqcomputer.com/ ~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4pr6OSck1ma9u6LwXm5l6Di2e6t5MGSRb8OTen4g7OPa3Xs7MIr8p7
 
 
 

color body paragraphs

Post by Troy Piggi » Mon, 05 Feb 2007 08:28:31

* Troy Piggins is quoted & my replies are inline below :


[snip]

Sorry - figured it out - the [33m is yellow.


[4m is underline.


[1m is bold.


Don't mind me :)

Thanks again.

--
Troy Piggins ,-O (o- O All your sigs are belong to us.
http://www.yqcomputer.com/ ~troy O ) //\ O
RLU#415538 `-O V_/_ OOO
hackerkey://v3sw5HPUhw5ln4pr6OSck1ma9u6LwXm5l6Di2e6t5MGSRb8OTen4g7OPa3Xs7MIr8p7