branch : pmacs2
This commit is contained in:
moculus 2007-08-03 22:19:16 +00:00
parent bd73a8dbfb
commit bceacdd919
3 changed files with 1833 additions and 1 deletions

View File

@ -10,7 +10,7 @@ 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 import mode.c, mode.python, mode.perl, mode.nasm, mode.sh, mode.sql, mode.java, mode.lisp
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,6 +107,7 @@ 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,
} }
# 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
@ -140,6 +141,7 @@ class Application(object):
'.css': 'css', '.css': 'css',
'.rst': 'rst', '.rst': 'rst',
'.java': 'java', '.java': 'java',
'.el': 'lisp',
} }
self.mode_detection = { self.mode_detection = {
'python': 'python', 'python': 'python',

1755
code_examples/flymake.el Normal file

File diff suppressed because it is too large Load Diff

75
mode/lisp.py Normal file
View File

@ -0,0 +1,75 @@
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 LispGrammar(Grammar):
rules = [
PatternRule(r'comment', r';.*$'),
# 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'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'symbol', 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'bareword', r"[a-zA-Z_][a-zA-Z0-9-_]*"),
# PatternRule(r'methodcall', r'(?<=\. )[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
# PatternRule(r'functioncall', r'[a-zA-Z_][a-zA-Z0-9_]*(?= *\()'),
# PatternRule(r'system_identifier', r'__[a-zA-Z0-9_]+__'),
# PatternRule(r'private_identifier', r'__[a-zA-Z0-9_]*'),
# PatternRule(r'hidden_identifier', r'_[a-zA-Z0-9_]*'),
# PatternRule(r'identifier', r'[a-zA-Z_][a-zA-Z0-9_]*'),
# PatternRule(r'delimiter', r'\(|\)|\[|\]|{|}|@|,|:|\.|`|=|;|\+=|-=|\*=|/=|//=|%=|&=|\|=|\^=|>>=|<<=|\*\*='),
# PatternRule(r"operator", r"\+|<>|<<|<=|<|-|>>|>=|>|\*\*|&|\*|\||/|\^|==|//|~|!=|%"),
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'"""'),
# RegionRule(r'string', r"'''", StringGrammar, r"'''"),
RegionRule(r'string', r'"', StringGrammar, r'"'),
# RegionRule(r'string', r"'", StringGrammar, r"'"),
# PatternRule(r'continuation', r'\\\n$'),
# PatternRule(r'eol', r'\n$'),
]
class LispTabber(tab2.StackTabber):
pass
class Lisp(mode2.Fundamental):
tabbercls = LispTabber
grammar = LispGrammar
opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'}
closetokens = ('delimiter',)
closetags = {')': '(', ']': '[', '}': '{'}
colors = {
'keyword': ('cyan', 'default'),
'reserved': ('blue', 'default'),
'symbol': ('magenta', '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 "Lisp"