From 7349b13195940e55c351ebeaecece686fa517bcf Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Thu, 13 Sep 2012 22:00:35 -0600 Subject: [PATCH] add support for better case indentation --HG-- branch : pmacs2 --- tab.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tab.py b/tab.py index 0fc329e..2fd5774 100644 --- a/tab.py +++ b/tab.py @@ -252,6 +252,7 @@ class StackTabber2(Tabber): open_test_tokens = {'delimiter': set(['('])} close_test_tokens = {'delimiter': set([')'])} control_tokens = {'keyword': set(['if', 'else', 'while', 'do', 'for'])} + case_tokens = {'keyword': set(['case'])} end_at_eof = True end_at_tokens = {} continue_tokens = {} @@ -421,6 +422,7 @@ class StackTabber2(Tabber): # block. e.g. else switch() { ... } if t.string in self.close_scope_tokens.get(t.fqname(), empty): self._pop('control') + self._pop('case') # if we do want implicit continuation, see if we need it. name, s = t.fqname(), t.string @@ -513,5 +515,10 @@ class StackTabber2(Tabber): if i == start: self._save_curr_level() 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) + 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)