diff --git a/application.py b/application.py index c0813b6..81ee65f 100755 --- a/application.py +++ b/application.py @@ -11,7 +11,7 @@ import mode2 import mode.mini, mode.search, mode.replace, mode.which import mode.console, mode.consolemini import mode.c, mode.python, mode.perl, mode.nasm, mode.sh, mode.sql, mode.java -import mode.elisp, mode.scheme +import mode.lisp, mode.elisp, mode.scheme import mode.blame, mode.diff, mode.dir import mode.xml, mode.tt, mode.css, mode.javascript, mode.html import mode.text, mode.mutt @@ -108,8 +108,11 @@ class Application(object): 'bds': mode.bds.BDS, 'rst': mode.rst.RST, 'java': mode.java.Java, - 'elisp': mode.elisp.ELisp, - 'scheme': mode.scheme.Scheme, + + # lisp dialects + 'lisp': mode.lisp.Lisp, + 'scheme': mode.scheme.Scheme, + 'elisp': mode.elisp.ELisp, } # these are used in this order to determine which mode to open certain diff --git a/method.py b/method.py index 72124c4..fc4ce8b 100644 --- a/method.py +++ b/method.py @@ -399,11 +399,11 @@ class PopKill(Method): class DeleteLeft(Method): '''Delete the character to the left of the cursor''' def _execute(self, w, **vargs): - cursor = w.logical_cursor() - line = w.buffer.lines[cursor.y] - if cursor.x >= 4 and line[0:cursor.x].isspace(): - w.kill(Point(cursor.x-4, cursor.y), - Point(cursor.x, cursor.y)) + (x, y) = w.logical_cursor().xy() + line = w.buffer.lines[y] + tabwidth = w.mode.tabwidth + if x >= tabwidth and x % tabwidth == 0 and line[0:x].isspace(): + w.kill(Point(x - tabwidth, y), Point(x, y)) else: w.left_delete() class DeleteRight(Method): @@ -558,8 +558,8 @@ class InsertTab(Method): i = None if i is None: - #raise Exception, repr(w.mode.tabber.lines) - w.insert_string_at_cursor(' ') + #w.insert_string_at_cursor(' ') + w.insert_string_at_cursor(' ' * w.mode.tabwidth) else: j = w.buffer.count_leading_whitespace(cursor.y) if i != j: @@ -842,8 +842,9 @@ class IndentBlock(Method): w.input_line = "Empty kill region" return lines = w.buffer.lines[p1.y:p2.y] + tstr = ' ' * w.mode.tabwidth for i in range(0, len(lines)): - lines[i] = ' ' + lines[i] + lines[i] = tstr + lines[i] w.buffer.delete(Point(0, p1.y), Point(0, p2.y)) w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n') diff --git a/mode/scheme.py b/mode/scheme.py index 3cece60..4adfe13 100644 --- a/mode/scheme.py +++ b/mode/scheme.py @@ -2,18 +2,13 @@ import commands, os.path, sets, string, sys, traceback import color, completer, default, mode2, method, regex, tab2 from point2 import Point from lex3 import Grammar, PatternRule, RegionRule, OverridePatternRule - -class StringGrammar(Grammar): - rules = [ - PatternRule(r'octal', r'\\[0-7]{3}'), - PatternRule(r'escaped', r'\\.'), - ] +import mode.lisp class SchemeGrammar(Grammar): rules = [ PatternRule(r'comment', r';.*$'), PatternRule(r'delimiter', r'[()]'), - RegionRule(r'string', r'"', StringGrammar, r'"'), + RegionRule(r'string', r'"', mode.lisp.StringGrammar, r'"'), PatternRule(r'spaces', r' +'), PatternRule(r'eol', r'\n'), PatternRule(r'abbrev', r"'|`|,\@|,"), @@ -35,15 +30,8 @@ class SchemeGrammar(Grammar): PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][a-zA-Z0-9!$%&*/:<=>?^_~+-.@]*|\+|-|...'), ] -class SchemeTabber(tab2.StackTabber): - def _handle_open_token(self, currlvl, y, i): - level = self.get_curr_level() + 4 - token = self.get_token(y, i) - self._append(token.string, level) - return currlvl - class Scheme(mode2.Fundamental): - tabbercls = SchemeTabber + tabbercls = mode.lisp.LispTabber grammar = SchemeGrammar opentokens = ('delimiter',) opentags = {'(': ')'} diff --git a/mode2.py b/mode2.py index 133fa0f..43b21b0 100644 --- a/mode2.py +++ b/mode2.py @@ -72,6 +72,7 @@ class Handler(object): class Fundamental(Handler): '''This is the default mode''' + tabwidth = 4 tabbercls = None grammar = None lexer = None diff --git a/window2.py b/window2.py index 6652f28..43f37b7 100644 --- a/window2.py +++ b/window2.py @@ -11,6 +11,8 @@ WORD_LETTERS = list(string.letters + string.digits) # error. both buffer and window need to be aware of this possibility for points. class Window(object): + margins = ((80, 'blue'),) + margins_visible = False def __init__(self, b, a, height=24, width=80, mode_name=None): self.buffer = b self.application = a @@ -25,8 +27,6 @@ class Window(object): self.width = width self.input_line = "" - self.margins = [(80, 'blue')] - self.margins_visible = False if mode_name is not None: pass