make indenting with tabs work better

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-07-03 23:33:05 -04:00
parent dd37bf139b
commit 7dac9a1984
3 changed files with 10 additions and 6 deletions

View File

@ -99,7 +99,9 @@ class GetToken(Method):
if token is None: if token is None:
w.set_error('No Token') w.set_error('No Token')
else: 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): class TokenComplete(Method):
'''Complete token names based on other tokens in the buffer''' '''Complete token names based on other tokens in the buffer'''

View File

@ -16,11 +16,12 @@ meta_chars = re.compile(r'([\.\^\$\*\+\?\{\}\(\)\[\]\|\"\'\\,])')
shell_command = re.compile(r'^[^ ]+') shell_command = re.compile(r'^[^ ]+')
# whitespace regexes # whitespace regexes
leading_whitespace = re.compile('^ *') leading_whitespace = re.compile('^[ \t]*')
trailing_whitespace = re.compile(' *$') trailing_whitespace = re.compile(r'[ \t]*$')
whitespace = re.compile(r'^[ \n]*$') whitespace = re.compile(r'^[ \t\n]*$')
space = re.compile('^ *$') 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 regexes
word = re.compile('^[A-Za-z0-9_]+$') word = re.compile('^[A-Za-z0-9_]+$')

3
tab.py
View File

@ -12,7 +12,8 @@ class Marker(object):
class Tabber(object): class Tabber(object):
wsre = regex.whitespace wsre = regex.whitespace
wst = ('spaces', 'null', 'eol',) wst = ('spaces', 'null', 'eol',)
sre = regex.space #sre = regex.space
sre = regex.whitespace
st = ('spaces', 'null',) st = ('spaces', 'null',)
def __init__(self, m): def __init__(self, m):
self.mode = m self.mode = m