From df6658178056dd845cfa070538f024ea04f473c1 Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 31 Mar 2009 14:57:14 +0000 Subject: [PATCH] clisp improvements --HG-- branch : pmacs2 --- application.py | 2 +- mode/lisp.py | 35 +++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/application.py b/application.py index 2d49649..0ad9ad2 100755 --- a/application.py +++ b/application.py @@ -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)) diff --git a/mode/lisp.py b/mode/lisp.py index 33e1404..37a7c43 100644 --- a/mode/lisp.py +++ b/mode/lisp.py @@ -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 = ';'