parent
bceacdd919
commit
d484d5b676
|
@ -10,7 +10,8 @@ from point2 import Point
|
||||||
import mode2
|
import mode2
|
||||||
import mode.mini, mode.search, mode.replace, mode.which
|
import mode.mini, mode.search, mode.replace, mode.which
|
||||||
import mode.console, mode.consolemini
|
import mode.console, mode.consolemini
|
||||||
import mode.c, mode.python, mode.perl, mode.nasm, mode.sh, mode.sql, mode.java, mode.lisp
|
import mode.c, mode.python, mode.perl, mode.nasm, mode.sh, mode.sql, mode.java
|
||||||
|
import mode.elisp, mode.scheme
|
||||||
import mode.blame, mode.diff, mode.dir
|
import mode.blame, mode.diff, mode.dir
|
||||||
import mode.xml, mode.tt, mode.css, mode.javascript, mode.html
|
import mode.xml, mode.tt, mode.css, mode.javascript, mode.html
|
||||||
import mode.text, mode.mutt
|
import mode.text, mode.mutt
|
||||||
|
@ -107,7 +108,8 @@ class Application(object):
|
||||||
'bds': mode.bds.BDS,
|
'bds': mode.bds.BDS,
|
||||||
'rst': mode.rst.RST,
|
'rst': mode.rst.RST,
|
||||||
'java': mode.java.Java,
|
'java': mode.java.Java,
|
||||||
'lisp': mode.lisp.Lisp,
|
'elisp': mode.elisp.ELisp,
|
||||||
|
'scheme': mode.scheme.Scheme,
|
||||||
}
|
}
|
||||||
|
|
||||||
# these are used in this order to determine which mode to open certain
|
# these are used in this order to determine which mode to open certain
|
||||||
|
@ -120,6 +122,7 @@ class Application(object):
|
||||||
'.bash_profile': 'sh',
|
'.bash_profile': 'sh',
|
||||||
'.profile': 'sh',
|
'.profile': 'sh',
|
||||||
'components.xml': 'bds',
|
'components.xml': 'bds',
|
||||||
|
'.emacs': 'elisp',
|
||||||
}
|
}
|
||||||
self.mode_extensions = {
|
self.mode_extensions = {
|
||||||
'.py': 'python',
|
'.py': 'python',
|
||||||
|
@ -141,7 +144,7 @@ class Application(object):
|
||||||
'.css': 'css',
|
'.css': 'css',
|
||||||
'.rst': 'rst',
|
'.rst': 'rst',
|
||||||
'.java': 'java',
|
'.java': 'java',
|
||||||
'.el': 'lisp',
|
'.el': 'elisp',
|
||||||
}
|
}
|
||||||
self.mode_detection = {
|
self.mode_detection = {
|
||||||
'python': 'python',
|
'python': 'python',
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
import commands, os.path, sets, string, sys, traceback
|
||||||
|
import color, completer, default, mode2, method, regex, tab2
|
||||||
|
from point2 import Point
|
||||||
|
from lex3 import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
|
|
||||||
|
class StringGrammar(Grammar):
|
||||||
|
rules = [
|
||||||
|
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||||
|
PatternRule(r'escaped', r'\\.'),
|
||||||
|
]
|
||||||
|
|
||||||
|
class ELispGrammar(Grammar):
|
||||||
|
rules = [
|
||||||
|
PatternRule(r'comment', r';.*$'),
|
||||||
|
PatternRule(r'reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
|
||||||
|
PatternRule(r'keyword', r'(?:while|when|unless|setq|require|or|not|mapcar|list|let|lambda|if|exists|equal|defvar|defun|defalias|count|cons|cdr|car|apply|and)(?![a-zA-Z0-9_])'),
|
||||||
|
PatternRule(r'symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
PatternRule(r'type', r":[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
PatternRule(r'attribute', r"&[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
PatternRule(r'bareword', r"[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
PatternRule(r"integer", r"(?<![\.0-9a-zA-Z_])(?:0|[1-9][0-9]*|0[0-7]+|0[xX][0-9a-fA-F]+)[lL]?(?![\.0-9a-zA-Z_])"),
|
||||||
|
PatternRule(r"float", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)(?![\.0-9a-zA-Z_])"),
|
||||||
|
PatternRule(r"imaginary", r"(?<![\.0-9a-zA-Z_])(?:[0-9]+|(?:[0-9]+\.[0-9]*|\.[0-9]+|(?:[0-9]|[0-9]+\.[0-9]*|\.[0-9]+)[eE][\+-]?[0-9]+)[jJ])(?![\.0-9a-zA-Z_])"),
|
||||||
|
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||||
|
PatternRule(r'eol', r'\n$'),
|
||||||
|
]
|
||||||
|
|
||||||
|
class ELispTabber(tab2.StackTabber):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ELisp(mode2.Fundamental):
|
||||||
|
tabbercls = ELispTabber
|
||||||
|
grammar = ELispGrammar
|
||||||
|
opentokens = ('delimiter',)
|
||||||
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
||||||
|
closetokens = ('delimiter',)
|
||||||
|
closetags = {')': '(', ']': '[', '}': '{'}
|
||||||
|
colors = {
|
||||||
|
'keyword': ('cyan', 'default'),
|
||||||
|
'reserved': ('blue', 'default'),
|
||||||
|
'symbol': ('magenta', 'default'),
|
||||||
|
'type': ('blue', 'default'),
|
||||||
|
'string.start': ('green', 'default'),
|
||||||
|
'string.null': ('green', 'default'),
|
||||||
|
'string.octal': ('magenta', 'default'),
|
||||||
|
'string.escaped': ('magenta', 'default'),
|
||||||
|
'string.format': ('yellow', 'default'),
|
||||||
|
'string.end': ('green', 'default'),
|
||||||
|
'integer': ('default', 'default'),
|
||||||
|
'float': ('default', 'default'),
|
||||||
|
'imaginary': ('default', 'default'),
|
||||||
|
'comment': ('red', 'default'),
|
||||||
|
}
|
||||||
|
def __init__(self, w):
|
||||||
|
mode2.Fundamental.__init__(self, w)
|
||||||
|
# tag matching
|
||||||
|
self.add_bindings('close-paren', (')',))
|
||||||
|
self.add_bindings('close-brace', ('}',))
|
||||||
|
self.add_bindings('close-bracket', (']',))
|
||||||
|
## add lisp-specific methods
|
||||||
|
#self.add_action_and_bindings(LispCheckSyntax(), ('C-c s',))
|
||||||
|
def name(self):
|
||||||
|
return "ELisp"
|
|
@ -15,8 +15,10 @@ class LispGrammar(Grammar):
|
||||||
# PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
# PatternRule(r'functionname', r'(?<=def )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
# PatternRule(r'classname', r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
# PatternRule(r'classname', r'(?<=class )[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||||
PatternRule(r'reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
|
PatternRule(r'reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
|
||||||
PatternRule(r'keyword', r'(?:while|unless|setq|require|mapcar|list|let|lambda|if|defvar|defalias|cons|cdr|car)(?![a-zA-Z0-9_])'),
|
PatternRule(r'keyword', r'(?:while|when|unless|setq|require|or|not|mapcar|list|let|lambda|if|exists|equal|defvar|defun|defalias|count|cons|cdr|car|apply|and)(?![a-zA-Z0-9_])'),
|
||||||
PatternRule(r'symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
|
PatternRule(r'symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
PatternRule(r'type', r":[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
|
PatternRule(r'attribute', r"&[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
# PatternRule(r"builtin", r'(?<!\.)(?:zip|xrange|vars|unicode|unichr|type|tuple|super|sum|str|staticmethod|sorted|slice|setattr|set|round|repr|reduce|raw_input|range|property|pow|ord|open|oct|object|max|min|map|long|locals|list|len|iter|issubclass|isinstance|int|input|id|hex|hash|hasattr|globals|getattr|frozenset|float|filter|file|execfile|eval|enumerate|divmod|dir|dict|delattr|complex|compile|coerce|cmp|classmethod|chr|callable|bool)(?![a-zA-Z0-9_])'),
|
# PatternRule(r"builtin", r'(?<!\.)(?:zip|xrange|vars|unicode|unichr|type|tuple|super|sum|str|staticmethod|sorted|slice|setattr|set|round|repr|reduce|raw_input|range|property|pow|ord|open|oct|object|max|min|map|long|locals|list|len|iter|issubclass|isinstance|int|input|id|hex|hash|hasattr|globals|getattr|frozenset|float|filter|file|execfile|eval|enumerate|divmod|dir|dict|delattr|complex|compile|coerce|cmp|classmethod|chr|callable|bool)(?![a-zA-Z0-9_])'),
|
||||||
PatternRule(r'bareword', r"[a-zA-Z_][a-zA-Z0-9-_]*"),
|
PatternRule(r'bareword', r"[a-zA-Z_][a-zA-Z0-9-_]*"),
|
||||||
# PatternRule(r'methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
# PatternRule(r'methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
|
||||||
|
@ -52,6 +54,7 @@ class Lisp(mode2.Fundamental):
|
||||||
'keyword': ('cyan', 'default'),
|
'keyword': ('cyan', 'default'),
|
||||||
'reserved': ('blue', 'default'),
|
'reserved': ('blue', 'default'),
|
||||||
'symbol': ('magenta', 'default'),
|
'symbol': ('magenta', 'default'),
|
||||||
|
'type': ('blue', 'default'),
|
||||||
'string.start': ('green', 'default'),
|
'string.start': ('green', 'default'),
|
||||||
'string.null': ('green', 'default'),
|
'string.null': ('green', 'default'),
|
||||||
'string.octal': ('magenta', 'default'),
|
'string.octal': ('magenta', 'default'),
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
import commands, os.path, sets, string, sys, traceback
|
||||||
|
import color, completer, default, mode2, method, regex, tab2
|
||||||
|
from point2 import Point
|
||||||
|
from lex3 import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
|
|
||||||
|
class StringGrammar(Grammar):
|
||||||
|
rules = [
|
||||||
|
PatternRule(r'octal', r'\\[0-7]{3}'),
|
||||||
|
PatternRule(r'escaped', r'\\.'),
|
||||||
|
]
|
||||||
|
|
||||||
|
class SchemeGrammar(Grammar):
|
||||||
|
rules = [
|
||||||
|
PatternRule(r'comment', r';.*$'),
|
||||||
|
PatternRule(r'delimiter', r'\(|\)|,'),
|
||||||
|
|
||||||
|
PatternRule(r'quote', r"'"),
|
||||||
|
PatternRule(r'backquote', r"`"),
|
||||||
|
PatternRule(r'atcomma', r',@'),
|
||||||
|
PatternRule(r'comma', r',@'),
|
||||||
|
|
||||||
|
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||||
|
PatternRule(r'spaces', r' +'),
|
||||||
|
PatternRule(r'eol', r'\n'),
|
||||||
|
|
||||||
|
PatternRule(r'keyword', r'quote|lambda|if|set|begin|cond|and|or|case|let\*|letrec|let|do|delay|quasiquote|else|=>|define|unquote-splicing|unquote'),
|
||||||
|
|
||||||
|
PatternRule(r'predicate', r'(?:boolean|symbol|char|vector|procedure|pair|number|string|port)\?'),
|
||||||
|
PatternRule(r'predicate', r'(?:eqv|equal|complex|real|rational|integer|zero|positive|negative|odd|even|null|list|char=|char<=|char>=|char<|char>|char-ci=|char-ci<=|char-ci>=|char-ci<|char-ci>|char-alphabetic|char-numeric|char-whitespace|char-upper-case|char-lower-case)\?'),
|
||||||
|
|
||||||
|
PatternRule(r'procedure', r'max|min|\+|-|\*|/|abs|quotient|remainder|modulo|lcm|gcd|numerator|denominator|floor|ceiling|truncate|round|rationalize|exp|log|sin|cos|tan|asin|acos|atan|make-rectangular|make-polar|real-part|imag-part|magnitude|angle|not|cons|car|cdr|list-tail|list-ref|list|length|append|reverse|memq|memv|member|assq|assv|assoc|char-upcase|char-downcase|make-string|string|string-ref'),
|
||||||
|
PatternRule(r'procedure', r'char->integer|integer->char'),
|
||||||
|
|
||||||
|
PatternRule(r'mutator', r'(?:set-car|set-cdr|string-set)\!'),
|
||||||
|
|
||||||
|
PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][a-zA-Z0-9!$%&*/:<=>?^_~+-.@]*|\+|-|...'),
|
||||||
|
|
||||||
|
PatternRule(r'boolean', r'#[tf]'),
|
||||||
|
PatternRule(r'char', r'#\\space|#\\newline|#\\.'),
|
||||||
|
|
||||||
|
# these are basically right and very easy
|
||||||
|
PatternRule(r'number', '[+-]?[0-9][^ \n]+'),
|
||||||
|
PatternRule(r'number', '#[bodx][ie]?[^ \n]+'),
|
||||||
|
PatternRule(r'number', '#[ie][bodx]?[^ \n]+'),
|
||||||
|
]
|
||||||
|
|
||||||
|
class SchemeTabber(tab2.StackTabber):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Scheme(mode2.Fundamental):
|
||||||
|
tabbercls = SchemeTabber
|
||||||
|
grammar = SchemeGrammar
|
||||||
|
opentokens = ('delimiter',)
|
||||||
|
opentags = {'(': ')',},
|
||||||
|
closetokens = ('delimiter',)
|
||||||
|
closetags = {')': '(',},
|
||||||
|
colors = {
|
||||||
|
'keyword': ('cyan', 'default'),
|
||||||
|
'reserved': ('blue', 'default'),
|
||||||
|
'symbol': ('magenta', 'default'),
|
||||||
|
'type': ('blue', 'default'),
|
||||||
|
'string.start': ('green', 'default'),
|
||||||
|
'string.null': ('green', 'default'),
|
||||||
|
'string.octal': ('magenta', 'default'),
|
||||||
|
'string.escaped': ('magenta', 'default'),
|
||||||
|
'string.format': ('yellow', 'default'),
|
||||||
|
'string.end': ('green', 'default'),
|
||||||
|
'integer': ('default', 'default'),
|
||||||
|
'float': ('default', 'default'),
|
||||||
|
'imaginary': ('default', 'default'),
|
||||||
|
'comment': ('red', 'default'),
|
||||||
|
}
|
||||||
|
def __init__(self, w):
|
||||||
|
mode2.Fundamental.__init__(self, w)
|
||||||
|
# tag matching
|
||||||
|
self.add_bindings('close-paren', (')',))
|
||||||
|
self.add_bindings('close-brace', ('}',))
|
||||||
|
self.add_bindings('close-bracket', (']',))
|
||||||
|
## add scheme-specific methods
|
||||||
|
#self.add_action_and_bindings(SchemeCheckSyntax(), ('C-c s',))
|
||||||
|
def name(self):
|
||||||
|
return "Scheme"
|
Loading…
Reference in New Issue