annotate runtime/syntax/mail.vim @ 2022:430793c2a231 v7.2.319

updated for version 7.2-319
author vimboss
date Wed, 16 Dec 2009 17:49:39 +0000
parents 149d8b46404c
children 7bc41231fbc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Mail file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Previous Maintainer: Felix von Leitner <leitner@math.fu-berlin.de>
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
4 " Maintainer: Gautam Iyer <gi1242@users.sourceforge.net>
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
5 " Last Change: Thu 17 Jan 2008 11:25:44 AM PST
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 if exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " The mail header is recognized starting with a "keyword:" line and ending
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " with an empty line or other line that can't be in the header. All lines of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " the header are highlighted. Headers of quoted messages (quoted with >) are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " also highlighted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 " Syntax clusters
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 syn cluster mailHeaderFields contains=mailHeaderKey,mailSubject,mailHeaderEmail,@mailLinks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 syn cluster mailLinks contains=mailURL,mailEmail
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 syn cluster mailQuoteExps contains=mailQuoteExp1,mailQuoteExp2,mailQuoteExp3,mailQuoteExp4,mailQuoteExp5,mailQuoteExp6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 syn case match
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " For "From " matching case is required. The "From " is not matched in quoted
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " emails
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 301
diff changeset
25 " According to RFC 2822 any printable ASCII character can appear in a field
96cd8222a819 updated for version 7.1a
vimboss
parents: 301
diff changeset
26 " name, except ':'.
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
27 syn region mailHeader contains=@mailHeaderFields,@NoSpell start="^From .*\d\d\d\d$" skip="^\s" end="\v^[!-9;-~]*([^!-~]|$)"me=s-1
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
28 syn match mailHeaderKey contained contains=mailEmail,@NoSpell "^From\s.*\d\d\d\d$"
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
29 " Usenet headers
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
30 syn match mailHeaderKey contained contains=mailHeaderEmail,mailEmail,@NoSpell "\v(^(\> ?)*)@<=(Newsgroups|Followup-To|Message-ID|Supersedes|Control):.*$"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 " Nothing else depends on case. Headers in properly quoted (with "> " or ">")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " emails are matched
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1125
diff changeset
35 syn region mailHeader keepend contains=@mailHeaderFields,@mailQuoteExps,@NoSpell start="^\z(\(> \?\)*\)\v(newsgroups|x-([a-z\-])*|path|xref|message-id|from|((in-)?reply-)?to|b?cc|subject|return-path|received|date|replied):" skip="^\z1\s" end="\v^\z1[!-9;-~]*([^!-~]|$)"me=s-1 end="\v^\z1@!"me=s-1 end="\v^\z1(\> ?)+"me=s-1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 164
diff changeset
37 syn region mailHeaderKey contained contains=mailHeaderEmail,mailEmail,@mailQuoteExps,@NoSpell start="\v(^(\> ?)*)@<=(to|b?cc):" skip=",$" end="$"
ef254e0f2365 updated for version 7.0063
vimboss
parents: 164
diff changeset
38 syn match mailHeaderKey contained contains=mailHeaderEmail,mailEmail,@NoSpell "\v(^(\> ?)*)@<=(from|reply-to):.*$"
301
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
39 syn match mailHeaderKey contained contains=@NoSpell "\v(^(\> ?)*)@<=date:"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
40 syn match mailSubject contained "\v^subject:.*$"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
41 syn match mailSubject contained contains=@NoSpell "\v(^(\> ?)+)@<=subject:.*$"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " Anything in the header between < and > is an email address
301
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
44 syn match mailHeaderEmail contained contains=@NoSpell "<.\{-}>"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 7
diff changeset
46 " Mail Signatures. (Begin with "-- ", end with change in quote level)
301
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
47 syn region mailSignature keepend contains=@mailLinks,@mailQuoteExps start="^--\s$" end="^$" end="^\(> \?\)\+"me=s-1
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
48 syn region mailSignature keepend contains=@mailLinks,@mailQuoteExps,@NoSpell start="^\z(\(> \?\)\+\)--\s$" end="^\z1$" end="^\z1\@!"me=s-1 end="^\z1\(> \?\)\+"me=s-1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " URLs start with a known protocol or www,web,w3.
301
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
51 syn match mailURL contains=@NoSpell `\v<(((https?|ftp|gopher)://|(mailto|file|news):)[^' <>"]+|(www|web|w3)[a-z0-9_-]*\.[a-z0-9._-]+\.[^' <>"]+)[a-z0-9/]`
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
52 syn match mailEmail contains=@NoSpell "\v[_=a-z\./+0-9-]+\@[a-z0-9._-]+\a{2}"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " Make sure quote markers in regions (header / signature) have correct color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 syn match mailQuoteExp1 contained "\v^(\> ?)"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 syn match mailQuoteExp2 contained "\v^(\> ?){2}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 syn match mailQuoteExp3 contained "\v^(\> ?){3}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 syn match mailQuoteExp4 contained "\v^(\> ?){4}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 syn match mailQuoteExp5 contained "\v^(\> ?){5}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 syn match mailQuoteExp6 contained "\v^(\> ?){6}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 " Even and odd quoted lines. order is imporant here!
301
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
63 syn match mailQuoted1 contains=mailHeader,@mailLinks,mailSignature,@NoSpell "^\([a-z]\+>\|[]|}>]\).*$"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
64 syn match mailQuoted2 contains=mailHeader,@mailLinks,mailSignature,@NoSpell "^\(\([a-z]\+>\|[]|}>]\)[ \t]*\)\{2}.*$"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
65 syn match mailQuoted3 contains=mailHeader,@mailLinks,mailSignature,@NoSpell "^\(\([a-z]\+>\|[]|}>]\)[ \t]*\)\{3}.*$"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
66 syn match mailQuoted4 contains=mailHeader,@mailLinks,mailSignature,@NoSpell "^\(\([a-z]\+>\|[]|}>]\)[ \t]*\)\{4}.*$"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
67 syn match mailQuoted5 contains=mailHeader,@mailLinks,mailSignature,@NoSpell "^\(\([a-z]\+>\|[]|}>]\)[ \t]*\)\{5}.*$"
006e9c8a6a8a updated for version 7.0079
vimboss
parents: 230
diff changeset
68 syn match mailQuoted6 contains=mailHeader,@mailLinks,mailSignature,@NoSpell "^\(\([a-z]\+>\|[]|}>]\)[ \t]*\)\{6}.*$"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " Need to sync on the header. Assume we can do that within 100 lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 if exists("mail_minlines")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 exec "syn sync minlines=" . mail_minlines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 syn sync minlines=100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 hi def link mailHeader Statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 hi def link mailHeaderKey Type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 hi def link mailSignature PreProc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 hi def link mailHeaderEmail mailEmail
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 hi def link mailEmail Special
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 hi def link mailURL String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 hi def link mailSubject LineNR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 hi def link mailQuoted1 Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 hi def link mailQuoted3 mailQuoted1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 hi def link mailQuoted5 mailQuoted1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 hi def link mailQuoted2 Identifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 hi def link mailQuoted4 mailQuoted2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 hi def link mailQuoted6 mailQuoted2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 hi def link mailQuoteExp1 mailQuoted1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 hi def link mailQuoteExp2 mailQuoted2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 hi def link mailQuoteExp3 mailQuoted3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 hi def link mailQuoteExp4 mailQuoted4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 hi def link mailQuoteExp5 mailQuoted5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 hi def link mailQuoteExp6 mailQuoted6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 let b:current_syntax = "mail"