2007-08-04 16:16:30 -04:00
|
|
|
import commands, os.path, sets, string, sys, traceback
|
2007-10-21 20:55:29 -04:00
|
|
|
import color, completer, default, mode, method, regex, tab
|
2007-10-21 20:50:11 -04:00
|
|
|
from point import Point
|
2007-10-21 20:52:48 -04:00
|
|
|
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
|
2007-08-04 16:16:30 -04:00
|
|
|
|
|
|
|
class StringGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(r'octal', r'\\[0-7]{3}'),
|
|
|
|
PatternRule(r'escaped', r'\\.'),
|
|
|
|
]
|
|
|
|
|
|
|
|
class ELispGrammar(Grammar):
|
|
|
|
rules = [
|
|
|
|
PatternRule(r'comment', r';.*$'),
|
2008-03-16 11:39:17 -04:00
|
|
|
PatternRule(r'elisp_reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
|
2008-03-16 01:23:14 -04:00
|
|
|
PatternRule(r'elisp_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_])'),
|
2008-03-16 11:39:17 -04:00
|
|
|
PatternRule(r'elisp_symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
|
|
|
|
PatternRule(r'elisp_type', r":[a-zA-Z_][a-zA-Z0-9-_]*"),
|
2007-08-04 16:16:30 -04:00
|
|
|
PatternRule(r'attribute', r"&[a-zA-Z_][a-zA-Z0-9-_]*"),
|
|
|
|
PatternRule(r'bareword', r"[a-zA-Z_][a-zA-Z0-9-_]*"),
|
2008-03-16 11:39:17 -04:00
|
|
|
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_])"),
|
2007-08-04 16:16:30 -04:00
|
|
|
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$'),
|
|
|
|
]
|
|
|
|
|
2007-10-21 20:55:29 -04:00
|
|
|
class ELispTabber(tab.StackTabber):
|
2007-08-04 16:16:30 -04:00
|
|
|
pass
|
|
|
|
|
2007-10-21 20:55:29 -04:00
|
|
|
class ELisp(mode.Fundamental):
|
2007-10-18 17:07:35 -04:00
|
|
|
modename = 'ELisp'
|
|
|
|
basenames = ['.emacs']
|
|
|
|
extensions = ['.el']
|
2007-08-04 16:16:30 -04:00
|
|
|
tabbercls = ELispTabber
|
|
|
|
grammar = ELispGrammar
|
|
|
|
opentokens = ('delimiter',)
|
|
|
|
opentags = {'(': ')', '[': ']', '{': '}'}
|
|
|
|
closetokens = ('delimiter',)
|
|
|
|
closetags = {')': '(', ']': '[', '}': '{'}
|
2007-10-18 17:07:35 -04:00
|
|
|
colors = {
|
2008-03-16 11:39:17 -04:00
|
|
|
'elisp_keyword': ('cyan', 'default'),
|
|
|
|
'elisp_reserved': ('blue', 'default'),
|
|
|
|
'elisp_symbol': ('magenta', 'default'),
|
|
|
|
'elisp_type': ('blue', 'default'),
|
2007-08-04 16:16:30 -04:00
|
|
|
}
|
|
|
|
def __init__(self, w):
|
2007-10-21 20:55:29 -04:00
|
|
|
mode.Fundamental.__init__(self, w)
|
2007-08-04 16:16:30 -04:00
|
|
|
# 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',))
|
2007-10-19 02:41:33 -04:00
|
|
|
|
|
|
|
install = ELisp.install
|