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',
'iperl', 'iperlmini', 'ipython', 'ipythonmini', 'awk',
'shell', 'shellmini', 'fstab', 'yacc', 'pipe',
'mbox', 'error', 'lua', 'lily', 'forth'
'mbox', 'error', 'lua', 'lily', 'forth',
)
for name in names:
exec("import mode.%s; mode.%s.install(self)" % (name, name))

View File

@ -1,4 +1,7 @@
import os
import regex
from method import Method
from method.shell import Interact
from mode import Fundamental
from tab import StackTabber
from lex import Grammar, PatternRule, RegionRule
@ -6,13 +9,13 @@ from mode.python import StringGrammar2
class LispGrammar(Grammar):
rules = [
PatternRule(r'comment', r';.*$'),
PatternRule(r'delimiter', r'[()]'),
PatternRule(r'keyword', r'(?:or|not|list|let\*|let|lambda|if|cons|c[ad]+r|apply|and)(?![^\"\' \t()])'),
PatternRule(r'lisp_word', r"[^\"' \t()]+"),
RegionRule(r'string', r'"', StringGrammar2, r'"'),
PatternRule(r'spaces', r' +'),
PatternRule(r'eol', r'\n'),
PatternRule('comment', ';.*$'),
PatternRule('delimiter', "[()']"),
PatternRule('keyword', r'(?:or|not|list|let\*|let|lambda|if|cons|c[ad]+r|apply|and)(?![^\"\' \t()])'),
PatternRule('lisp_word', r"[^\"' \t()]+"),
RegionRule('string', '"', StringGrammar2, '"'),
PatternRule('spaces', ' +'),
PatternRule('eol', r'\n'),
]
class LispTabber(StackTabber):
@ -36,8 +39,21 @@ class LispTabber(StackTabber):
self._append(token.string, level)
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):
name = 'Lisp'
extensions = ['.lisp']
tabwidth = 2
tabbercls = LispTabber
grammar = LispGrammar
@ -46,10 +62,9 @@ class Lisp(Fundamental):
opentags = {'(': ')'}
closetokens = ('delimiter',)
closetags = {')': '('}
actions = [ClispStart, ClispLoadFile]
_bindings = {
'close-paren': (')',),
'close-brace': ('}',),
'close-bracket': (']',),
'close-paren': (')',),
}
commentc = ';'