lisp improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-09-11 22:26:41 +00:00
parent 6865b2a4e9
commit a6fb81d077
3 changed files with 20 additions and 4 deletions

View File

@ -127,7 +127,8 @@ class Application(object):
'python', 'replace', 'rst', 'scheme', 'search', 'sh', 'sql', 'python', 'replace', 'rst', 'scheme', 'search', 'sh', 'sql',
'tt', 'text', 'text2', 'which', 'xml', 'cheetah', 'colortext', 'tt', 'text', 'text2', 'which', 'xml', 'cheetah', 'colortext',
'latex', 'insertmini', 'conf', 'haskell', 'erlang', 'latex', 'insertmini', 'conf', 'haskell', 'erlang',
'iperl', 'iperlmini', 'ipython', 'ipythonmini' 'iperl', 'iperlmini', 'ipython', 'ipythonmini',
'bds', #XYZ
) )
for name in names: for name in names:
exec("import mode.%s; mode.%s.install(self)" % (name, name)) exec("import mode.%s; mode.%s.install(self)" % (name, name))

View File

@ -2,6 +2,7 @@ import commands, os.path, sets, string, sys, traceback
import color, completer, default, mode, method, regex, tab import color, completer, default, mode, method, regex, tab
from point import Point from point import Point
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
from mode.lisp import LispTabber, LispCommentRegion, LispUncommentRegion
class StringGrammar(Grammar): class StringGrammar(Grammar):
rules = [ rules = [
@ -12,6 +13,7 @@ class StringGrammar(Grammar):
class ELispGrammar(Grammar): class ELispGrammar(Grammar):
rules = [ rules = [
PatternRule(r'comment', r';.*$'), PatternRule(r'comment', r';.*$'),
PatternRule(r'delimiter', r'[()]'),
PatternRule(r'elisp_reserved', r'(?:nil)(?![a-zA-Z0-9_])'), PatternRule(r'elisp_reserved', r'(?:nil)(?![a-zA-Z0-9_])'),
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_])'), 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_])'),
PatternRule(r'elisp_symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"), PatternRule(r'elisp_symbol', r"'[a-zA-Z_][a-zA-Z0-9-_]*"),
@ -25,14 +27,15 @@ class ELispGrammar(Grammar):
PatternRule(r'eol', r'\n$'), PatternRule(r'eol', r'\n$'),
] ]
class ELispTabber(tab.StackTabber): #class ELispTabber(tab.StackTabber):
pass # pass
class ELisp(mode.Fundamental): class ELisp(mode.Fundamental):
modename = 'ELisp' modename = 'ELisp'
tabwidth = 2
basenames = ['.emacs'] basenames = ['.emacs']
extensions = ['.el'] extensions = ['.el']
tabbercls = ELispTabber tabbercls = LispTabber
grammar = ELispGrammar grammar = ELispGrammar
opentokens = ('delimiter',) opentokens = ('delimiter',)
opentags = {'(': ')', '[': ']', '{': '}'} opentags = {'(': ')', '[': ']', '{': '}'}
@ -49,5 +52,7 @@ class ELisp(mode.Fundamental):
self.add_bindings('close-paren', (')',)) self.add_bindings('close-paren', (')',))
self.add_bindings('close-brace', ('}',)) self.add_bindings('close-brace', ('}',))
self.add_bindings('close-bracket', (']',)) self.add_bindings('close-bracket', (']',))
self.add_bindings('lisp-comment-region', ('C-c #',))
self.add_bindings('lisp-uncomment-region', ('C-u C-C #',))
install = ELisp.install install = ELisp.install

View File

@ -3,6 +3,7 @@ import color, completer, default, mode, method, regex, tab
from point import Point from point import Point
from lex import Grammar, PatternRule, RegionRule, OverridePatternRule from lex import Grammar, PatternRule, RegionRule, OverridePatternRule
from mode.python import StringGrammar from mode.python import StringGrammar
from method import CommentRegion, UncommentRegion
class LispGrammar(Grammar): class LispGrammar(Grammar):
rules = [ rules = [
@ -13,6 +14,11 @@ class LispGrammar(Grammar):
PatternRule(r'eol', r'\n'), PatternRule(r'eol', r'\n'),
] ]
class LispCommentRegion(CommentRegion):
commentc = ';'
class LispUncommentRegion(UncommentRegion):
commentc = ';'
class LispTabber(tab.StackTabber): class LispTabber(tab.StackTabber):
wsre = regex.whitespace wsre = regex.whitespace
wst = ('spaces', 'null', 'eol',) wst = ('spaces', 'null', 'eol',)
@ -43,10 +49,14 @@ class Lisp(mode.Fundamental):
opentags = {'(': ')'} opentags = {'(': ')'}
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '('} closetags = {')': '('}
actions = [LispCommentRegion, LispUncommentRegion]
def __init__(self, w): def __init__(self, w):
mode.Fundamental.__init__(self, w) mode.Fundamental.__init__(self, w)
self.add_bindings('close-paren', (')',)) self.add_bindings('close-paren', (')',))
self.add_bindings('close-brace', ('}',)) self.add_bindings('close-brace', ('}',))
self.add_bindings('close-bracket', (']',)) self.add_bindings('close-bracket', (']',))
self.add_action_and_bindings('lisp-comment-region', ('C-c #',))
self.add_action_and_bindings('lisp-uncomment-region', ('C-u C-C #',))
install = Lisp.install install = Lisp.install