From 7dac9a1984b2d2e789de0983a028dfbc1bcfd940 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Sat, 3 Jul 2010 23:33:05 -0400 Subject: [PATCH] make indenting with tabs work better --HG-- branch : pmacs2 --- method/introspect.py | 4 +++- regex.py | 9 +++++---- tab.py | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/method/introspect.py b/method/introspect.py index d53b8b2..72a6fa7 100644 --- a/method/introspect.py +++ b/method/introspect.py @@ -99,7 +99,9 @@ class GetToken(Method): if token is None: w.set_error('No Token') else: - w.set_error('Token: %r (%s)' % (token.string, token.fqname())) + # HACK: fix up our internal tab representation + s = regex.internal_tab.sub('\t', token.string) + w.set_error('Token: %s (%s)' % (repr(s)[1:], token.fqname())) class TokenComplete(Method): '''Complete token names based on other tokens in the buffer''' diff --git a/regex.py b/regex.py index 7b51f9d..d36f8ae 100644 --- a/regex.py +++ b/regex.py @@ -16,11 +16,12 @@ meta_chars = re.compile(r'([\.\^\$\*\+\?\{\}\(\)\[\]\|\"\'\\,])') shell_command = re.compile(r'^[^ ]+') # whitespace regexes -leading_whitespace = re.compile('^ *') -trailing_whitespace = re.compile(' *$') -whitespace = re.compile(r'^[ \n]*$') +leading_whitespace = re.compile('^[ \t]*') +trailing_whitespace = re.compile(r'[ \t]*$') +whitespace = re.compile(r'^[ \t\n]*$') space = re.compile('^ *$') -leading_whitespace2 = re.compile('^( *?)(.*?)\n?$') +leading_whitespace2 = re.compile(r'^([ \t]*?)(.*?)\n?$') +internal_tab = re.compile(r'\t *\t') # word regexes word = re.compile('^[A-Za-z0-9_]+$') diff --git a/tab.py b/tab.py index 7e3db85..886587b 100644 --- a/tab.py +++ b/tab.py @@ -12,7 +12,8 @@ class Marker(object): class Tabber(object): wsre = regex.whitespace wst = ('spaces', 'null', 'eol',) - sre = regex.space + #sre = regex.space + sre = regex.whitespace st = ('spaces', 'null',) def __init__(self, m): self.mode = m