summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-01-03 01:36:50 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-01-03 01:36:50 +0000
commit4e45e2f12520bd2dc06549953c3c17993583c244 (patch)
tree6cca4f9908aed48f22d702fa175ab3dc1d476a58 /alot
parentdb04b61d40e5ea9ce6169cd0004748466dd0ef1c (diff)
add new search command: "sort"
to change the used sort order in current search buffer. This also integrates the --sort parameter to the refine command
Diffstat (limited to 'alot')
-rw-r--r--alot/commands/search.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/alot/commands/search.py b/alot/commands/search.py
index 4d794dc8..ede8924c 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -82,27 +82,39 @@ class ToggleThreadTagCommand(Command):
@registerCommand(MODE, 'refine', usage='refine query', arguments=[
+ (['--sort'], {'help':'sort order', 'choices':[
+ 'oldest_first', 'newest_first', 'message_id', 'unsorted']}),
(['query'], {'nargs':argparse.REMAINDER, 'help':'search string'})])
+@registerCommand(MODE, 'sort', usage='set sort order', arguments=[
+ (['sort'], {'help':'sort order', 'choices':[
+ 'oldest_first', 'newest_first', 'message_id', 'unsorted']}),
+])
class RefineCommand(Command):
"""refine the querystring of this buffer"""
- def __init__(self, query=None, **kwargs):
+ def __init__(self, query=None, sort=None, **kwargs):
"""
:param query: new querystring given as list of strings as returned by
argparse
:type query: list of str
"""
- self.querystring = ' '.join(query)
+ if query is None:
+ self.querystring = None
+ else:
+ self.querystring = ' '.join(query)
+ self.sort_order = sort
Command.__init__(self, **kwargs)
def apply(self, ui):
- if self.querystring:
+ if self.querystring or self.sort_order:
sbuffer = ui.current_buffer
oldquery = sbuffer.querystring
if self.querystring not in [None, oldquery]:
sbuffer.querystring = self.querystring
sbuffer = ui.current_buffer
- sbuffer.rebuild()
- ui.update()
+ if self.sort_order:
+ sbuffer.sort_order = self.sort_order
+ sbuffer.rebuild()
+ ui.update()
else:
ui.notify('empty query string')