Highlight email headers with different colors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Highlight email headers with different colors

Ian N
Hello,
I am a new vim+mutt user. I am wondering how to highlight email headers (from, To, CC, Subject, ...) with different colors.
I have done my homework by searching FAQs and more, but I didn't find any answer.
Thank you for your help.
Ian

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/b992fcc4-b473-4c67-ab90-d14a2ee2ab89n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

meine
On Sun, Jan 31, 2021 at 10:02:02PM -0800, Ian N wrote:
> Hello,
> I am a new vim+mutt user. I am wondering how to highlight email headers
> (from, To, CC, Subject, ...) with different colors.

I have the following color settings in my muttrc. Don't know if all
settings are technically correct, but it gives different colors for
different parts of an email. Just put them into your muttrc and see if
it works for you.

//meine


## MUTT COLOURS

# Colours for items in the index
color index brightcyan black ~N
# Hmm, don't like this.
#color index brightgreen black "~N (~x byers.world)|(~x byers.x)|(~x langly.levallois123.axialys.net)|(~x the.earth.li)"
color index brightyellow black ~F
color index black green ~T
color index brightred black ~D
mono index bold ~N
mono index bold ~F
mono index bold ~T
mono index bold ~D

# Highlights inside the body of a message.

# URLs
color body brightgreen black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"
color body brightgreen black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"
mono body bold "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"

# email addresses
color body brightgreen black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"
#mono body bold "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"

# header
color header green black "^from:"
color header green black "^to:"
color header green black "^cc:"
color header green black "^date:"
color header yellow black "^newsgroups:"
color header yellow black "^reply-to:"
color header brightcyan black "^subject:"
color header red black "^x-spam-rule:"
color header green black "^x-mailer:"
color header yellow black "^message-id:"
color header yellow black "^Organization:"
color header yellow black "^Organisation:"
color header yellow black "^User-Agent:"
color header yellow black "^message-id: .*pine"
color header yellow black "^X-Fnord:"
color header yellow black "^X-WebTV-Stationery:"
color header yellow black "^X-Message-Flag:"
color header yellow black "^X-Spam-Status:"
color header yellow black "^X-SpamProbe:"
color header red black "^X-SpamProbe: SPAM"

# Coloring quoted text - coloring the first 7 levels:
color quoted cyan black
color quoted1 yellow black
color quoted2 red black
color quoted3 green black
color quoted4 cyan black
color quoted5 yellow black
color quoted6 red black
color quoted7 green black

# Default color definitions
#color hdrdefault white green
color signature brightmagenta black
color indicator black cyan
color attachment black green
color error red black
color message white black
color search brightwhite magenta
color status brightyellow blue
color tree brightblue black
color normal white black
color tilde green black
color bold brightyellow black

#color underline magenta black
color markers brightcyan black

# Colour definitions when on a mono screen
mono bold bold
mono underline underline
mono indicator reverse

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/YBf5pBEHrFzcdA/P%40trackstand.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Christian Brabandt
In reply to this post by Ian N

On So, 31 Jan 2021, Ian N wrote:

> Hello,
> I am a new vim+mutt user. I am wondering how to highlight email headers (from, To, CC, Subject, ...) with different colors.
> I have done my homework by searching FAQs and more, but I didn't find any answer.

Do you want to highlight those headers in vim or in mutt?

Best,
Christian
--
Nicht was wir gestern waren, sondern was wir morgen zusammen sein
werden, vereinigt uns zum Staat.
                -- José Ortega y Gasset

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210201142121.GC2835808%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Ian N
In reply to this post by meine
Thank you for the message and the file you sent.

The color file you sent highlights and colors the email headers when viewing the email. This problem I have solved.

Actually, my problem is about highlighting and coloring email headers in vim, when editing the message.

Thank you.


On Mon, Feb 1, 2021 at 7:52 AM meine <[hidden email]> wrote:
On Sun, Jan 31, 2021 at 10:02:02PM -0800, Ian N wrote:
> Hello,
> I am a new vim+mutt user. I am wondering how to highlight email headers
> (from, To, CC, Subject, ...) with different colors.

I have the following color settings in my muttrc. Don't know if all
settings are technically correct, but it gives different colors for
different parts of an email. Just put them into your muttrc and see if
it works for you.

//meine


## MUTT COLOURS

# Colours for items in the index
color index brightcyan black ~N
# Hmm, don't like this.
#color index brightgreen black "~N (~x byers.world)|(~x byers.x)|(~x langly.levallois123.axialys.net)|(~x the.earth.li)"
color index brightyellow black ~F
color index black green ~T
color index brightred black ~D
mono index bold ~N
mono index bold ~F
mono index bold ~T
mono index bold ~D

# Highlights inside the body of a message.

# URLs
color body brightgreen black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"
color body brightgreen black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"
mono body bold "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"

# email addresses
color body brightgreen black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"
#mono body bold "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"

# header
color header green black "^from:"
color header green black "^to:"
color header green black "^cc:"
color header green black "^date:"
color header yellow black "^newsgroups:"
color header yellow black "^reply-to:"
color header brightcyan black "^subject:"
color header red black "^x-spam-rule:"
color header green black "^x-mailer:"
color header yellow black "^message-id:"
color header yellow black "^Organization:"
color header yellow black "^Organisation:"
color header yellow black "^User-Agent:"
color header yellow black "^message-id: .*pine"
color header yellow black "^X-Fnord:"
color header yellow black "^X-WebTV-Stationery:"
color header yellow black "^X-Message-Flag:"
color header yellow black "^X-Spam-Status:"
color header yellow black "^X-SpamProbe:"
color header red black "^X-SpamProbe: SPAM"

# Coloring quoted text - coloring the first 7 levels:
color quoted cyan black
color quoted1 yellow black
color quoted2 red black
color quoted3 green black
color quoted4 cyan black
color quoted5 yellow black
color quoted6 red black
color quoted7 green black

# Default color definitions
#color hdrdefault white green
color signature brightmagenta black
color indicator black cyan
color attachment black green
color error red black
color message white black
color search brightwhite magenta
color status brightyellow blue
color tree brightblue black
color normal white black
color tilde green black
color bold brightyellow black

#color underline magenta black
color markers brightcyan black

# Colour definitions when on a mono screen
mono bold bold
mono underline underline
mono indicator reverse

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/YBf5pBEHrFzcdA/P%40trackstand.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAKjEDgbBAGUc2v294-2ZsfCzh8SMjWNfS-ehTk-CBhTc2%2B6-ig%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

meine
> Actually, my problem is about highlighting and coloring email headers in
> vim, when *editing the message*.

OK. In my setup I don't see any headers when editing an email -- just a
window with regular Vim. After I quit vim and get back into mutt, I see
the headers, but that is just to, from, subject etc and as/needs no
coloring.

When replying to an email there is only one line above the message that
states 'soandso wrote:', but nothing more.

//meine

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/YBg2%2BiA5hxF8VIZ8%40trackstand.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Ian-3
In reply to this post by Christian Brabandt
I want the headers colored in vim, when I edit/write the message.
I have no problems for coloring the headers when viewing the messages in mutt.



On Monday, February 1, 2021 at 9:21:29 AM UTC-5 [hidden email] wrote:

On So, 31 Jan 2021, Ian N wrote:

> Hello,
> I am a new vim+mutt user. I am wondering how to highlight email headers (from, To, CC, Subject, ...) with different colors.
> I have done my homework by searching FAQs and more, but I didn't find any answer.

Do you want to highlight those headers in vim or in mutt?

Best,
Christian
--
Nicht was wir gestern waren, sondern was wir morgen zusammen sein
werden, vereinigt uns zum Staat.
-- José Ortega y Gasset

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/2ed0395f-cb1f-40e3-94d5-2b6c4467825fn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Christian Brabandt

On Mo, 01 Feb 2021, Ian wrote:

> I want the headers colored in vim, when I edit/write the message.
> I have no problems for coloring the headers when viewing the messages in mutt.

I am using mutt with vim and :set edit_headers so I see some headers in
each message. If you have your filetype plugin enabled, Vim should
detect a mail from mutt as filetype mail and it colors headers already
using the provided syntax file for the mail filetype  (see
$VIMRUNTIME/syntax/mail.vim).

If this is not enough for you, have a look inside this runtime file to
see how to color different headers.


Best,
Christian
--
Ich fürchte mich nicht vor dem, was zu fürchten ist, ich fürchte mich
nur vor der Furcht.
                -- Johann Christian Friedrich Hölderlin

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210202074022.GD2835808%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Ian N
Thank you Christian!
This is exactly what I have already done.

Indeed, the mail.vim file highlights all the mail headers, with the same color (white in this case). 

My question is about how to customize these colors (when writing the mail) - say From: field blue, To: field red, ...
 
I am trying to understand the mail.vim file. It seems it defines the mail header fields all together and colors them with one color.

I am looking for a way to customize the mail header fields 
colors individually. 
Ian

On Tue, Feb 2, 2021 at 2:40 AM Christian Brabandt <[hidden email]> wrote:

On Mo, 01 Feb 2021, Ian wrote:

> I want the headers colored in vim, when I edit/write the message.
> I have no problems for coloring the headers when viewing the messages in mutt.

I am using mutt with vim and :set edit_headers so I see some headers in
each message. If you have your filetype plugin enabled, Vim should
detect a mail from mutt as filetype mail and it colors headers already
using the provided syntax file for the mail filetype  (see
$VIMRUNTIME/syntax/mail.vim).

If this is not enough for you, have a look inside this runtime file to
see how to color different headers.


Best,
Christian
--
Ich fürchte mich nicht vor dem, was zu fürchten ist, ich fürchte mich
nur vor der Furcht.
                -- Johann Christian Friedrich Hölderlin

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210202074022.GD2835808%40256bit.org.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAKjEDgaUzgO%3DGagUArL_y%2BrMozzVBgEzwLHymKdHFVpzY-A%2BzQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Charles Campbell-2
Ian N wrote:

> Thank you Christian!
> This is exactly what I have already done.
>
> Indeed, the mail.vim file highlights all the mail headers, with the
> same color (white in this case).
>
> My question is about how to customize these colors (when writing the
> mail) - say From: field blue, To: field red, ...
> I am trying to understand the mail.vim file. It seems it defines the
> mail header fields all together and colors them with one color.
>
> I am looking for a way to customize the mail header fields
> colors individually.
> Ian
>
You'll need to make a customized syntax/email.vim file. I suggest going
about this one field at a time.

Copy your system's email.vim into $HOME/.vim/syntax/email.vim.
Work with the copy:

Example:
     modify: syn region mailHeader ... remove "|from" from its start pattern
     new syntax: syn region mailHeaderFrom
     new highlighting: hi def mailHeaderFrom (whatever start= cterm=
gui= stuff you want)
     quoted regions: include mailHeaderFrom in mailQuoted[1-6]

Rinse and repeat for whatever fields you want to modify the highlighting
for.

Your version of email.vim will then override the system version, which
you should NOT modify. Future updates to vim could easily wipe your
modified email.vim away should you happen to modify the system version
in place.

Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/2cf3381f-b2d1-5547-1807-2ed04538d8b7%40drchip.org.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Ian-3
Definitely this is the way to go. I did try a few things as you suggested, without success.
This requires some more time to understand the file syntax. But I do not have enough time, nor the expertise to 
properly understand the syntax of the file (which seems very condensed). 
I was expecting anyone has already a solution and willing to share.

Thanks for the suggestions anayway.
On Tuesday, February 2, 2021 at 1:16:35 PM UTC-5 Charles Campbell wrote:
Ian N wrote:

> Thank you Christian!
> This is exactly what I have already done.
>
> Indeed, the mail.vim file highlights all the mail headers, with the
> same color (white in this case).
>
> My question is about how to customize these colors (when writing the
> mail) - say From: field blue, To: field red, ...
> I am trying to understand the mail.vim file. It seems it defines the
> mail header fields all together and colors them with one color.
>
> I am looking for a way to customize the mail header fields
> colors individually.
> Ian
>
You'll need to make a customized syntax/email.vim file. I suggest going
about this one field at a time.

Copy your system's email.vim into $HOME/.vim/syntax/email.vim.
Work with the copy:

Example:
    modify: syn region mailHeader ... remove "|from" from its start pattern
    new syntax: syn region mailHeaderFrom
    new highlighting: hi def mailHeaderFrom (whatever start= cterm=
gui= stuff you want)
    quoted regions: include mailHeaderFrom in mailQuoted[1-6]

Rinse and repeat for whatever fields you want to modify the highlighting
for.

Your version of email.vim will then override the system version, which
you should NOT modify. Future updates to vim could easily wipe your
modified email.vim away should you happen to modify the system version
in place.

Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/35c92a2d-10c5-46c3-bcee-2f4302117443n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Highlight email headers with different colors

Christian Brabandt

On Di, 02 Feb 2021, Ian wrote:

> Definitely this is the way to go. I did try a few things as you suggested, without success.
> This requires some more time to understand the file syntax. But I do not have enough time, nor the expertise to
> properly understand the syntax of the file (which seems very condensed).
> I was expecting anyone has already a solution and willing to share.
>
> Thanks for the suggestions anayway.

I think the file should be named mail.vim, but otherwise Charles has
mentioned the way to go. FWIW, I never felt the way to color different
headers differently, the default here just colors the Subject line
slightly different than the rest and this just good enough for me, so I
never felt the need to adjust the existing syntax file.

Anyhow, if you want to adjust it, you'll have to read up on syntax
highlighting and regular expressions.

Best,
Christian

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210203073505.GA258352%40256bit.org.