From a968dae8b009409292d558d5c49f99a543d2fec5 Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 16 Mar 2008 06:16:41 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- README | 8 +++--- application.py | 8 +++++- code_examples/python-overrides.py | 3 +- mode/bds.py | 48 +++++++++---------------------- mode/c.py | 6 ---- 5 files changed, 27 insertions(+), 46 deletions(-) diff --git a/README b/README index 656658f..67d6be6 100644 --- a/README +++ b/README @@ -80,10 +80,10 @@ Quick Start Guide: C-x C-c quit NOTE: the notation used corresponds to the following: - C-x hold Control then press x. - M-x hold Meta then press x. - C-c j hold Control then press c, and then press j - C-x C-s hold Control then press x, then hold Control then press s + C-x hold Control and press x. + M-x hold Meta and press x. + C-c j hold Control and press c, then press j + C-x C-s hold Control and press x, then hold Control and press s 6. Other documentation: diff --git a/application.py b/application.py index 58c33f5..3abcf21 100755 --- a/application.py +++ b/application.py @@ -48,7 +48,13 @@ class Application(object): self.error_string = "" self.error_timestamp = None self.input = keyinput.Handler() - self.token_colors = {} + # let's prepopulate some default token colors + self.token_colors = { + 'comment': ('red', 'default'), + 'comment.start': ('red', 'default'), + 'comment.null': ('red', 'default'), + 'comment.end': ('red', 'default'), + } self.default_color = ('default', 'default',) # initialize our colors diff --git a/code_examples/python-overrides.py b/code_examples/python-overrides.py index ee31e90..6e395f0 100644 --- a/code_examples/python-overrides.py +++ b/code_examples/python-overrides.py @@ -8,5 +8,6 @@ def do_junk(*args): s = "bar" #@@:string:python - s = "lambda x, y: 'result: %d' % x + y" + #@@:string.string:sql + s = "lambda x, y: 'select * from foo where x = %d and y = %d;' % x + y" s = "lambda x, y: 'result: %d' % x + y" diff --git a/mode/bds.py b/mode/bds.py index 019f754..ddf6ab4 100644 --- a/mode/bds.py +++ b/mode/bds.py @@ -9,17 +9,17 @@ from mode.perl import StringGrammar class BDSGrammar(Grammar): rules = [ RegionRule(r'comment', r''), - RegionRule(r'tag', r'< */?', TagGrammar, r'/?>'), + RegionRule(r'xml_tag', r'< */?', TagGrammar, r'/?>'), PatternRule(r'delimiter', r'[\[\]\{\}\(\),\?:]'), - PatternRule(r'derived', r'(?:FM|CD|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'), - PatternRule(r'question', r'GQ[0-9]{3}-[0-9]{3}-[0-9]{3}:MQ[0-9]{3}-[0-9]{3}-[0-9]{3}'), - PatternRule(r'bdsfunc', r'[A-Z_][A-Z0-9_]+(?= *\()'), - PatternRule(r'perlfunc', r'[a-zA-Z_][a-zA-Z0-9_]+(?= *\()'), - PatternRule(r'misquoted', r"'[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?'"), - PatternRule(r'misquoted', r'"[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?"'), + PatternRule(r'bds_derived', r'(?:FM|CD|FS|FM|TA)[0-9]{3}-[0-9]{3}-[0-9]{3}'), + PatternRule(r'bds_question', r'GQ[0-9]{3}-[0-9]{3}-[0-9]{3}:MQ[0-9]{3}-[0-9]{3}-[0-9]{3}'), + PatternRule(r'bds_function', r'[A-Z_][A-Z0-9_]+(?= *\()'), + PatternRule(r'bds_perlfunc', r'[a-zA-Z_][a-zA-Z0-9_]+(?= *\()'), + PatternRule(r'bds_misquoted', r"'[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?'"), + PatternRule(r'bds_misquoted', r'"[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3}(?::[A-Z]{2}[0-9]{3}-[0-9]{3}-[0-9]{3})?"'), RegionRule(r'string', '"', StringGrammar, '"'), RegionRule(r'string', "'", Grammar, "'"), - PatternRule(r'operator', r'(?:>=|<=|>|<|==|&&|\|\||eq|ne)'), + PatternRule(r'bds_operator', r'(?:>=|<=|>|<|==|&&|\|\||eq|ne)'), ] class BDS(mode.Fundamental): @@ -31,32 +31,12 @@ class BDS(mode.Fundamental): closetokens = ('delimiter',) closetags = {')': '(', ']': '[', '}': '{'} colors = { - # comments - 'comment.start': ('red', 'default'), - 'comment.null': ('red', 'default'), - 'comment.end': ('red', 'default'), - # xml tag - 'tag.start': ('default', 'default'), - 'tag.namespace': ('magenta', 'default'), - 'tag.name': ('blue', 'default'), - 'tag.attrname': ('blue', 'default'), - 'tag.string.start': ('cyan', 'default'), - 'tag.string.null': ('cyan', 'default'), - 'tag.string.end': ('cyan', 'default'), - 'tag.end': ('default', 'default'), - # strings - 'string.start': ('green', 'default'), - 'string.octal': ('magenta', 'default'), - 'string.escaped': ('magenta', 'default'), - 'string.null': ('green', 'default'), - 'string.end': ('green', 'default'), - # keywords, etc - 'derived': ('yellow', 'default'), - 'question': ('yellow', 'default'), - 'misquoted': ('yellow', 'red'), - 'bdsfunc': ('magenta', 'default'), - 'perlfunc': ('magenta', 'default'), - 'operator': ('magenta', 'default'), + 'bds_derived': ('yellow', 'default'), + 'bds_question': ('yellow', 'default'), + 'bds_misquoted': ('yellow', 'red'), + 'bds_function': ('magenta', 'default'), + 'bds_perlfunc': ('magenta', 'default'), + 'bds_operator': ('magenta', 'default'), } def __init__(self, w): mode.Fundamental.__init__(self, w) diff --git a/mode/c.py b/mode/c.py index 07f2ec7..8cdd2b7 100644 --- a/mode/c.py +++ b/mode/c.py @@ -188,10 +188,6 @@ class C(mode.Fundamental): 'macrocomment.start': ('red', 'default'), 'macrocomment.null': ('red', 'default'), 'macrocomment.end': ('red', 'default'), - 'comment': ('red', 'default'), - 'comment.start': ('red', 'default'), - 'comment.end': ('red', 'default'), - 'comment.null': ('red', 'default'), 'include': ('blue', 'default'), 'header': ('green', 'default'), @@ -231,8 +227,6 @@ class C(mode.Fundamental): 'string.end': ('green', 'default'), 'integer': ('green', 'default'), 'float': ('green', 'default'), - - 'bizzaro': ('magenta', 'green'), } def __init__(self, w): mode.Fundamental.__init__(self, w)