clisp improvements

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-03-31 14:57:14 +00:00
parent db0479b68d
commit df66581780
2 changed files with 26 additions and 11 deletions

View File

@ -117,7 +117,7 @@ class Application(object):
'latex', 'insertmini', 'conf', 'haskell', 'erlang', 'latex', 'insertmini', 'conf', 'haskell', 'erlang',
'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'awk', 'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'awk',
'shell', 'shellmini', 'fstab', 'yacc', 'pipe', 'shell', 'shellmini', 'fstab', 'yacc', 'pipe',
'mbox', 'error', 'lua', 'lily', 'forth' 'mbox', 'error', 'lua', 'lily', 'forth',
) )
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

@ -1,4 +1,7 @@
import os
import regex import regex
from method import Method
from method.shell import Interact
from mode import Fundamental from mode import Fundamental
from tab import StackTabber from tab import StackTabber
from lex import Grammar, PatternRule, RegionRule from lex import Grammar, PatternRule, RegionRule
@ -6,13 +9,13 @@ from mode.python import StringGrammar2
class LispGrammar(Grammar): class LispGrammar(Grammar):
rules = [ rules = [
PatternRule(r'comment', r';.*$'), PatternRule('comment', ';.*$'),
PatternRule(r'delimiter', r'[()]'), PatternRule('delimiter', "[()']"),
PatternRule(r'keyword', r'(?:or|not|list|let\*|let|lambda|if|cons|c[ad]+r|apply|and)(?![^\"\' \t()])'), PatternRule('keyword', r'(?:or|not|list|let\*|let|lambda|if|cons|c[ad]+r|apply|and)(?![^\"\' \t()])'),
PatternRule(r'lisp_word', r"[^\"' \t()]+"), PatternRule('lisp_word', r"[^\"' \t()]+"),
RegionRule(r'string', r'"', StringGrammar2, r'"'), RegionRule('string', '"', StringGrammar2, '"'),
PatternRule(r'spaces', r' +'), PatternRule('spaces', ' +'),
PatternRule(r'eol', r'\n'), PatternRule('eol', r'\n'),
] ]
class LispTabber(StackTabber): class LispTabber(StackTabber):
@ -36,8 +39,21 @@ class LispTabber(StackTabber):
self._append(token.string, level) self._append(token.string, level)
return currlvl return currlvl
class ClispStart(Interact):
args = []
def _execute(self, w, **vargs):
Interact._execute(self, w, bname='*Clisp*', cmd='clisp')
class ClispLoadFile(Interact):
args = []
def _execute(self, w, **vargs):
Interact._execute(self, w, bname='*Clisp*', cmd='clisp')
b = w.application.get_buffer_by_name('*Clisp*')
path = os.path.realpath(w.buffer.path)
b.pipe_write('(load "%s")\n' % path)
class Lisp(Fundamental): class Lisp(Fundamental):
name = 'Lisp' name = 'Lisp'
extensions = ['.lisp']
tabwidth = 2 tabwidth = 2
tabbercls = LispTabber tabbercls = LispTabber
grammar = LispGrammar grammar = LispGrammar
@ -46,10 +62,9 @@ class Lisp(Fundamental):
opentags = {'(': ')'} opentags = {'(': ')'}
closetokens = ('delimiter',) closetokens = ('delimiter',)
closetags = {')': '('} closetags = {')': '('}
actions = [ClispStart, ClispLoadFile]
_bindings = { _bindings = {
'close-paren': (')',), 'close-paren': (')',),
'close-brace': ('}',),
'close-bracket': (']',),
} }
commentc = ';' commentc = ';'