summaryrefslogtreecommitdiff
path: root/alot/commands/namedqueries.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2018-06-23 16:32:29 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2018-07-24 22:05:56 +0100
commit7d5120f85fafaf52884ed2549431f3f47294e760 (patch)
treec7d8cf3cdd5f2d0463be2778f85c8310295d6dda /alot/commands/namedqueries.py
parent0a0b21fab575fdf4cca01ef7a7b1e95ad7125c89 (diff)
add select command for namedqueries buffer
Diffstat (limited to 'alot/commands/namedqueries.py')
-rw-r--r--alot/commands/namedqueries.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/alot/commands/namedqueries.py b/alot/commands/namedqueries.py
new file mode 100644
index 00000000..362e2bb6
--- /dev/null
+++ b/alot/commands/namedqueries.py
@@ -0,0 +1,30 @@
+# Copyright (C) 2011-2018 Patrick Totzke <patricktotzke@gmail.com>
+# This file is released under the GNU GPL, version 3 or a later revision.
+# For further details see the COPYING file
+import argparse
+
+from . import Command, registerCommand
+from .globals import SearchCommand
+
+MODE = 'namedqueries'
+
+
+@registerCommand(MODE, 'select', arguments=[
+ (['filt'], {'nargs': argparse.REMAINDER,
+ 'help': 'additional filter to apply to query'}),
+])
+class NamedqueriesSelectCommand(Command):
+
+ """search for messages with selected query"""
+ def __init__(self, filt=None, **kwargs):
+ self._filt = filt
+ Command.__init__(self, **kwargs)
+
+ def apply(self, ui):
+ query_name = ui.current_buffer.get_selected_query()
+ query = ['query:"%s"' % query_name]
+ if self._filt:
+ query.extend(['and'] + self._filt)
+
+ cmd = SearchCommand(query=query)
+ ui.apply_command(cmd)