diff --git a/application.py b/application.py index 940a94b..f05ece5 100755 --- a/application.py +++ b/application.py @@ -318,7 +318,8 @@ class Application(object): lines = list(candidates) data = '\n'.join(lines) - b = self.data_buffer("*Completions*", data, switch_to=False) + b = self.data_buffer("*Completions*", data, switch_to=False) + b._completion = s b._opened = opened b._previous = previous diff --git a/method/__init__.py b/method/__init__.py index ef564ad..5cf7153 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -490,14 +490,25 @@ class InsertTab(Method): # if no lvl, insert a literal tab if lvl is None: - w.insert_string_at_cursor(' ' * w.mode.tabwidth) + #w.insert_string_at_cursor(' ' * w.mode.tabwidth) + if w.buffer.usetabs: + # see HACK in buffer + w.insert_string_at_cursor('\t \t') + else: + w.insert_string_at_cursor(' ' * w.mode.tabwidth) return # insert the correct amount of whitespace - ws = w.buffer.count_leading_whitespace(y) + ws = w.buffer.count_leading_whitespace(y) if lvl != ws: w.delete(Point(0, y), Point(ws, y)) - w.insert_string(Point(0, y), ' ' * lvl) + if w.buffer.usetabs: + nt = lvl // w.mode.tabwidth + ns = lvl % w.mode.tabwidth + s = ('\t \t' * nt) + (' ' * ns) + else: + s = ' ' * lvl + w.insert_string(Point(0, y), s) x2 = max(x, lvl) if w.logical_cursor().x < x2: w.goto(Point(x2, y)) diff --git a/mode/__init__.py b/mode/__init__.py index aa5ea23..17d11c1 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -1,5 +1,9 @@ +import math +import os +import string +import sys +import traceback from util import defaultdict -import math, os, string import color, method from lex import Lexer from point import Point @@ -458,8 +462,11 @@ class Fundamental(Handler): except Exception, e: if DEBUG: raise - else: - self.window.set_error(str(e)) + exc_type, exc_value, exc_traceback = sys.exc_info() + data = ''.join(traceback.format_tb(exc_traceback)) + self.window.application.data_buffer("*Exception*", data, + switch_to=False) + self.window.set_error(str(e)) def region_added(self, p, newlines): if self.lexer is not None: diff --git a/mode/c.py b/mode/c.py index ee6fff1..92a99e4 100644 --- a/mode/c.py +++ b/mode/c.py @@ -17,9 +17,10 @@ class ErrorGrammar(Grammar): PatternRule('continuation', r'\\\n$'), ] -chr1 = '[a-zA-Z_]' -chr2 = '[a-zA-Z0-9_]' -word = chr1 + chr2 + '*' +chr1 = '[a-zA-Z_]' +chr2 = '[a-zA-Z0-9_]' +word = chr1 + chr2 + '*' +spaces = r'[\t ]+' class MacroGrammar(Grammar): rules = [ @@ -36,7 +37,7 @@ class MacroGrammar(Grammar): class CGrammar(Grammar): rules = [ - PatternRule('spaces', r' +'), + PatternRule('spaces', spaces), PatternMatchRule('x', r'(\()( *)(' + word + r')(\**)( *)(\))( *)(?=[a-zA-Z0-9_\(])', 'delimiter', 'spaces', 'c.type', 'c.operator',