parent
9155446878
commit
9674295203
41
mode/mutt.py
41
mode/mutt.py
|
@ -2,11 +2,9 @@ import re
|
||||||
from mode import Fundamental
|
from mode import Fundamental
|
||||||
from method import WrapParagraph
|
from method import WrapParagraph
|
||||||
from mode.text import ContinuedRule, WordRule, TextInsertSpace
|
from mode.text import ContinuedRule, WordRule, TextInsertSpace
|
||||||
from lex import Grammar, PatternRule
|
from lex import Grammar, PatternRule, RegionRule, PatternMatchRule
|
||||||
|
|
||||||
class MuttGrammar(Grammar):
|
rules = [
|
||||||
rules = [
|
|
||||||
PatternRule('mutt_header', '^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'),
|
|
||||||
PatternRule('quotec', '^ *(?:(?: *>){3})*(?: *>){3}.*$'),
|
PatternRule('quotec', '^ *(?:(?: *>){3})*(?: *>){3}.*$'),
|
||||||
PatternRule('quoteb', '^ *(?:(?: *>){3})*(?: *>){2}.*$'),
|
PatternRule('quoteb', '^ *(?:(?: *>){3})*(?: *>){2}.*$'),
|
||||||
PatternRule('quotea', '^ *(?:(?: *>){3})*(?: *>){1}.*$'),
|
PatternRule('quotea', '^ *(?:(?: *>){3})*(?: *>){1}.*$'),
|
||||||
|
@ -14,9 +12,14 @@ class MuttGrammar(Grammar):
|
||||||
PatternRule('url', 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 ]+'),
|
||||||
ContinuedRule(),
|
ContinuedRule(),
|
||||||
WordRule(),
|
WordRule(),
|
||||||
PatternRule('punct', '[^a-zA-Z0-9_]'),
|
PatternRule('punctuation', '[^a-zA-Z0-9_]'),
|
||||||
PatternRule('stuff', '[a-zA-Z0-9_]+'),
|
PatternRule('data', '[a-zA-Z0-9_]+'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class HeaderGrammar(Grammar): rules = [PatternRule('header', '^.+:')] + rules
|
||||||
|
class BodyGrammar(Grammar): rules = rules
|
||||||
|
class MuttGrammar(Grammar):
|
||||||
|
rules = [RegionRule('mutt', '^', HeaderGrammar, '^\n$', BodyGrammar, '')]
|
||||||
|
|
||||||
class MuttWrapParagraph(WrapParagraph):
|
class MuttWrapParagraph(WrapParagraph):
|
||||||
limit = 72
|
limit = 72
|
||||||
|
@ -28,18 +31,18 @@ class Mutt(Fundamental):
|
||||||
name = 'Mutt'
|
name = 'Mutt'
|
||||||
grammar = MuttGrammar()
|
grammar = MuttGrammar()
|
||||||
colors = {
|
colors = {
|
||||||
'mutt_header': ('green', 'default', 'bold'),
|
'mutt.header': ('green', 'default', 'bold'),
|
||||||
'email': ('cyan', 'default', 'bold'),
|
'mutt.email': ('cyan', 'default', 'bold'),
|
||||||
'url': ('cyan', 'default', 'bold'),
|
'mutt.url': ('cyan', 'default', 'bold'),
|
||||||
'quotea': ('yellow', 'default', 'bold'),
|
'mutt.quotea': ('yellow', 'default', 'bold'),
|
||||||
'quoteb': ('cyan', 'default', 'bold'),
|
'mutt.quoteb': ('cyan', 'default', 'bold'),
|
||||||
'quotec': ('magenta', 'default', 'bold'),
|
'mutt.quotec': ('magenta', 'default', 'bold'),
|
||||||
'misspelled': ('red', 'default', 'bold'),
|
'mutt.misspelled': ('red', 'default', 'bold'),
|
||||||
'cont.start': ('default', 'default', 'bold'),
|
'mutt.cont.start': ('default', 'default'),
|
||||||
'cont.end': ('default', 'default', 'bold'),
|
'mutt.cont.end': ('default', 'default'),
|
||||||
'word': ('default', 'default', 'bold'),
|
'mutt.word': ('default', 'default'),
|
||||||
'punct': ('default', 'default', 'bold'),
|
'mutt.punctuation': ('default', 'default'),
|
||||||
'stuff': ('default', 'default', 'bold'),
|
'mutt.data': ('default', 'default'),
|
||||||
}
|
}
|
||||||
actions = [MuttInsertSpace, MuttWrapParagraph]
|
actions = [MuttInsertSpace, MuttWrapParagraph]
|
||||||
config = {
|
config = {
|
||||||
|
|
Loading…
Reference in New Issue