diff options
author | josch <j.schauer@email.de> | 2013-05-09 14:47:10 +0200 |
---|---|---|
committer | josch <j.schauer@email.de> | 2013-05-09 14:47:10 +0200 |
commit | 92059afcd0275c83dd8ec91698aa1c1249b17cd8 (patch) | |
tree | 7ddee1a13906155507986ee150d4aa1a380c4fe8 /alot/buffers.py | |
parent | 50f80419b0b76f557823925436d79aadbe6771e9 (diff) |
add 'next unfolded' and 'previous unfolded' as thread move commands
Diffstat (limited to 'alot/buffers.py')
-rw-r--r-- | alot/buffers.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index 12e0dbc2..f633f171 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -511,6 +511,43 @@ class ThreadBuffer(Buffer): if newpos is not None: self.body.set_focus(newpos) + def focus_property(self, prop, direction): + """does a walk in the given direction and focuses the + first message tree that matches the given property""" + newpos = self.get_selected_mid() + newpos = direction(newpos) + while newpos is not None: + MT = self._tree[newpos] + if prop(MT): + newpos = self._sanitize_position((newpos,)) + self.body.set_focus(newpos) + break + newpos = direction(newpos) + + def focus_next_matching(self, querystring): + """focus next matching message in depth first order""" + self.focus_property( + lambda x: x._message.matches(querystring), + self._tree.next_position) + + def focus_prev_matching(self, querystring): + """focus previous matching message in depth first order""" + self.focus_property( + lambda x: x._message.matches(querystring), + self._tree.prev_position) + + def focus_next_unfolded(self): + """focus next unfolded message in depth first order""" + self.focus_property( + lambda x: not x.is_collapsed(x.root), + self._tree.next_position) + + def focus_prev_unfolded(self): + """focus previous unfolded message in depth first order""" + self.focus_property( + lambda x: not x.is_collapsed(x.root), + self._tree.prev_position) + def expand(self, msgpos): """expand message at given position""" MT = self._tree[msgpos] |