" Vim syntax file
" Language:	Mail file
" Maintainer:	Felix von Leitner <leitner@math.fu-berlin.de>
" Last change:	1997 April 28
" Last change by mool:	1997 May 28

" Remove any old syntax stuff hanging around
syntax clear

syntax case ignore

" The mail header is recognized starting with a "keyword:" line and ending
" with an empty line or other line that can't be in the header.
" All lines of the header are highlighted
syntax region	mailHeader	start="^[-a-z]\+: " skip="^[ \t]" end="^[-a-z]*[^-a-z:]"S-1 end="^[^:]*$"S end="^---*" contains mailHeaderKey mailSubject

syntax region	mailHeaderKey	contained start="^\(From\|To\|Cc\|BCc\|Reply-To\).*" skip=",$" end="$" contains mailEmail
syntax match	mailHeaderKey	contained "^Date"

syntax match	mailSubject	contained "^Subject.*"

syntax match	mailEmail	contained "[_a-z\.A-Z0-9-]\+@[a-zA-Z0-9\./\-]\+"
syntax match	mailEmail	contained "<.\{-}>"

syntax region	mailSignature	start="^-- *$" end="^$"

syntax match	mailQuoted	"^\([A-Za-z]\+>\|[]:|}>][]>:|}-]*\).*$"

" Need to sync on the header.  Assume we can do that within a hundred lines
syntax sync lines=100

if !exists("did_mail_syntax_inits")
  let did_mail_syntax_inits = 1
  " The default methods for highlighting.  Can be overridden later
  highlight link mailHeaderKey		Identifier
  highlight link mailHeader		Statement
  highlight link mailQuoted		Comment
  highlight link mailSignature		PreProc
  highlight link mailEmail		Special
  highlight link mailSubject		String
endif
