branch : pmacs2
This commit is contained in:
moculus 2009-04-08 14:57:25 +00:00
parent 185ee1a061
commit 701728fbd9
2 changed files with 30 additions and 15 deletions

14
code_examples/email Normal file
View File

@ -0,0 +1,14 @@
From: Erik Osheim <erik@osheim.org>
To: All Systems Go! <systems@solutionsforprogress.com>
Date: Wednesday, April 8th 2009
Subject: Ahoy!
Quoth Alec Wood <awood@solutionsforprogress.com>:
> I got this crazy email; here it is:
>
> Also sprach Emily Record <erecord@solutionsforprogress.com>:
>> This is double-quoted:
>>
>>> Hi there!!!
This is outer text.

View File

@ -1,29 +1,30 @@
import re import re
import color, mode, method from mode import Fundamental
import mode.text from method import WrapParagraph
from mode.text import ContinuedRule, WordRule, TextInsertSpace
from lex import Grammar, PatternRule from lex import Grammar, PatternRule
class MuttGrammar(Grammar): class MuttGrammar(Grammar):
rules = [ rules = [
PatternRule(name=r'mutt_header', pattern=r'^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'), PatternRule('mutt_header', '^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'),
PatternRule(name=r'quoteb', pattern=r'^ *(?:(?: *>){3})*(?: *>){2}.*$'), PatternRule('quotec', '^ *(?:(?: *>){3})*(?: *>){3}.*$'),
PatternRule(name=r'quotea', pattern=r'^ *(?:(?: *>){3})*(?: *>){1}.*$'), PatternRule('quoteb', '^ *(?:(?: *>){3})*(?: *>){2}.*$'),
PatternRule(name=r'quotec', pattern=r'^ *(?:(?: *>){3})*(?: *>){3}.*$'), PatternRule('quotea', '^ *(?:(?: *>){3})*(?: *>){1}.*$'),
PatternRule(name=r'email', pattern=r'(?:^|(?<=[ :]))<?[^<>@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'), PatternRule('email', r'(?:^|(?<=[ :]))<?[^<>@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'),
PatternRule(name=r'url', pattern=r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'), PatternRule('url', r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'),
mode.text.ContinuedRule(), ContinuedRule(),
mode.text.WordRule(), WordRule(),
PatternRule(name=r'punct', pattern=r'[^a-zA-Z0-9_]'), PatternRule('punct', '[^a-zA-Z0-9_]'),
PatternRule(name=r'stuff', pattern=r'[a-zA-Z0-9_]+'), PatternRule('stuff', '[a-zA-Z0-9_]+'),
] ]
class MuttWrapParagraph(method.WrapParagraph): class MuttWrapParagraph(WrapParagraph):
limit = 72 limit = 72
empty_re = re.compile('^(?: *>.*| *)$') empty_re = re.compile('^(?: *>.*| *)$')
class MuttInsertSpace(mode.text.TextInsertSpace): class MuttInsertSpace(TextInsertSpace):
wrapper = MuttWrapParagraph wrapper = MuttWrapParagraph
class Mutt(mode.Fundamental): class Mutt(Fundamental):
name = 'Mutt' name = 'Mutt'
grammar = MuttGrammar() grammar = MuttGrammar()
colors = { colors = {