pmacs3/mode/mutt.py

55 lines
2.0 KiB
Python
Raw Normal View History

import re
2009-04-08 10:57:25 -04:00
from mode import Fundamental
from method import WrapParagraph
from mode.text import ContinuedRule, WordRule, TextInsertSpace
2007-10-21 20:52:48 -04:00
from lex import Grammar, PatternRule
2007-07-21 11:40:53 -04:00
class MuttGrammar(Grammar):
rules = [
2009-04-08 10:57:25 -04:00
PatternRule('mutt_header', '^(?:From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|Delivered-To|Date):'),
PatternRule('quotec', '^ *(?:(?: *>){3})*(?: *>){3}.*$'),
PatternRule('quoteb', '^ *(?:(?: *>){3})*(?: *>){2}.*$'),
PatternRule('quotea', '^ *(?:(?: *>){3})*(?: *>){1}.*$'),
PatternRule('email', r'(?:^|(?<=[ :]))<?[^<>@\n ]+@(?:[^<>@\.\n ]+\.)*[^<>@\.\n ]+>?'),
PatternRule('url', r'(?:^|(?<= ))(?:http|https|ftp|sftp|file|smtp|smtps|torrent|news|jabber|irc|telnet)://(?:[^\.\n ]+\.)*[^\.\n ]+'),
ContinuedRule(),
WordRule(),
PatternRule('punct', '[^a-zA-Z0-9_]'),
PatternRule('stuff', '[a-zA-Z0-9_]+'),
2007-07-21 11:40:53 -04:00
]
2009-04-08 10:57:25 -04:00
class MuttWrapParagraph(WrapParagraph):
2008-04-18 23:32:08 -04:00
limit = 72
empty_re = re.compile('^(?: *>.*| *)$')
2009-04-08 10:57:25 -04:00
class MuttInsertSpace(TextInsertSpace):
2008-04-18 23:32:08 -04:00
wrapper = MuttWrapParagraph
2009-04-08 10:57:25 -04:00
class Mutt(Fundamental):
name = 'Mutt'
grammar = MuttGrammar()
colors = {
'mutt_header': ('green', 'default', 'bold'),
'email': ('cyan', 'default', 'bold'),
'url': ('cyan', 'default', 'bold'),
'quotea': ('yellow', 'default', 'bold'),
'quoteb': ('cyan', 'default', 'bold'),
'quotec': ('magenta', 'default', 'bold'),
'misspelled': ('red', 'default', 'bold'),
'cont.start': ('default', 'default', 'bold'),
'cont.end': ('default', 'default', 'bold'),
'word': ('default', 'default', 'bold'),
'punct': ('default', 'default', 'bold'),
'stuff': ('default', 'default', 'bold'),
2007-07-21 11:40:53 -04:00
}
2008-04-19 20:25:17 -04:00
actions = [MuttInsertSpace, MuttWrapParagraph]
config = {
'mutt.margin': 72,
}
_bindings = {
'learn-word': ('C-c l',),
'mutt-wrap-paragraph': ('M-q',),
'mutt-insert-space': ('SPACE',),
}
2007-10-19 02:41:33 -04:00
install = Mutt.install