fixed python tabbing, readded case insensitivity to literal searches
--HG-- branch : pmacs2
This commit is contained in:
parent
1dd0f520ec
commit
085e2e2f9e
|
@ -38,7 +38,7 @@ class PythonGrammar(Grammar):
|
||||||
]
|
]
|
||||||
|
|
||||||
class PythonTabber(tab2.StackTabber):
|
class PythonTabber(tab2.StackTabber):
|
||||||
#endlevel_names = ('pass', 'return', 'yield', 'raise', 'break', 'continue')
|
# NOTE: yield might initially seem like an endlevel name, but it's not one.
|
||||||
endlevel_names = ('pass', 'return', 'raise', 'break', 'continue')
|
endlevel_names = ('pass', 'return', 'raise', 'break', 'continue')
|
||||||
startlevel_names = ('if', 'try', 'class', 'def', 'for', 'while', 'try')
|
startlevel_names = ('if', 'try', 'class', 'def', 'for', 'while', 'try')
|
||||||
def __init__(self, m):
|
def __init__(self, m):
|
||||||
|
@ -50,11 +50,8 @@ class PythonTabber(tab2.StackTabber):
|
||||||
# we always know that line 0 is indented at the 0 level
|
# we always know that line 0 is indented at the 0 level
|
||||||
return True
|
return True
|
||||||
tokens = self.get_tokens(y)
|
tokens = self.get_tokens(y)
|
||||||
#if not tokens:
|
t0 = tokens[0]
|
||||||
# # if a line has no tokens, we don't know much about its indentation
|
if t0.name == 'keyword' and t0.string in self.startlevel_names:
|
||||||
# return False
|
|
||||||
#elif tokens[0].name in self.startlevel_names:
|
|
||||||
if tokens[0].name in self.startlevel_names:
|
|
||||||
# if a line has no whitespace and beings with something like
|
# if a line has no whitespace and beings with something like
|
||||||
# 'while','class','def','if',etc. then we can start at it
|
# 'while','class','def','if',etc. then we can start at it
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -36,7 +36,9 @@ def _make_regex(w, s):
|
||||||
try:
|
try:
|
||||||
if w.buffer.method.is_literal:
|
if w.buffer.method.is_literal:
|
||||||
s = search.escape_literal(s)
|
s = search.escape_literal(s)
|
||||||
return re.compile(s)
|
return re.compile(s, re.IGNORECASE)
|
||||||
|
else:
|
||||||
|
return re.compile(s)
|
||||||
except:
|
except:
|
||||||
raise search.IllegalPatternError, "failed to compile: %r" % s
|
raise search.IllegalPatternError, "failed to compile: %r" % s
|
||||||
|
|
||||||
|
@ -134,5 +136,5 @@ def _end(w):
|
||||||
w.application.close_mini_buffer()
|
w.application.close_mini_buffer()
|
||||||
w.application.clear_highlighted_ranges()
|
w.application.clear_highlighted_ranges()
|
||||||
w.application.last_search = w.buffer.make_string()
|
w.application.last_search = w.buffer.make_string()
|
||||||
w.buffer.method.old_cursor = None
|
#w.buffer.method.old_cursor = None
|
||||||
w.buffer.method.old_window = None
|
#w.buffer.method.old_window = None
|
||||||
|
|
Loading…
Reference in New Issue