parent
db0479b68d
commit
df66581780
|
@ -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))
|
||||
|
|
35
mode/lisp.py
35
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 = ';'
|
||||
|
||||
|
|
Loading…
Reference in New Issue