add support for better case indentation

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2012-09-13 22:00:35 -06:00
parent 4ae87e7e2c
commit 7349b13195
1 changed files with 8 additions and 1 deletions

9
tab.py
View File

@ -252,6 +252,7 @@ class StackTabber2(Tabber):
open_test_tokens = {'delimiter': set(['('])} open_test_tokens = {'delimiter': set(['('])}
close_test_tokens = {'delimiter': set([')'])} close_test_tokens = {'delimiter': set([')'])}
control_tokens = {'keyword': set(['if', 'else', 'while', 'do', 'for'])} control_tokens = {'keyword': set(['if', 'else', 'while', 'do', 'for'])}
case_tokens = {'keyword': set(['case'])}
end_at_eof = True end_at_eof = True
end_at_tokens = {} end_at_tokens = {}
continue_tokens = {} continue_tokens = {}
@ -421,6 +422,7 @@ class StackTabber2(Tabber):
# block. e.g. else switch() { ... } # block. e.g. else switch() { ... }
if t.string in self.close_scope_tokens.get(t.fqname(), empty): if t.string in self.close_scope_tokens.get(t.fqname(), empty):
self._pop('control') self._pop('control')
self._pop('case')
# if we do want implicit continuation, see if we need it. # if we do want implicit continuation, see if we need it.
name, s = t.fqname(), t.string name, s = t.fqname(), t.string
@ -513,5 +515,10 @@ class StackTabber2(Tabber):
if i == start: if i == start:
self._save_curr_level() self._save_curr_level()
self._pop_while('continue'); self._pop_while('continue');
#self._append_unless('control', name, self._get_next_level(), y)
self._append_unless('pre-control', name, self._get_next_level(), y) self._append_unless('pre-control', name, self._get_next_level(), y)
elif s in self.case_tokens.get(name, {}):
if top is not None and top.name == 'case':
self._pop('case')
if i == 0:
self._save_curr_level()
self._append_unless('case', name, self._get_next_level(), y)