diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-05-07 16:02:24 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-05-08 17:16:18 +0200 |
commit | 63714d4d203570c636ce9253d7a0e10131da16a9 (patch) | |
tree | 80f8098628a5231ed2521b783869da54587c4ae9 /alot/commands | |
parent | b244c2ff1856abe602e3553b376208f8dfbdce5c (diff) |
db/manager: drop support for adding/removing queries
This is not implemented in notmuch2 and does not really belong in alot.
It can be done better through the notmuch utility.
Diffstat (limited to 'alot/commands')
-rw-r--r-- | alot/commands/globals.py | 91 | ||||
-rw-r--r-- | alot/commands/search.py | 22 |
2 files changed, 0 insertions, 113 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index 19bc0086..1104bd10 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -1087,94 +1087,3 @@ class ReloadCommand(Command): except ConfigError as e: ui.notify('Error when reloading config files:\n {}'.format(e), priority='error') - - -@registerCommand( - MODE, 'savequery', - arguments=[ - (['--no-flush'], {'action': 'store_false', 'dest': 'flush', - 'default': 'True', - 'help': 'postpone a writeout to the index'}), - (['alias'], {'help': 'alias to use for query string'}), - (['query'], {'help': 'query string to store', - 'nargs': '+'}) - ], - help='store query string as a "named query" in the database') -class SaveQueryCommand(Command): - - """save alias for query string""" - repeatable = False - - def __init__(self, alias, query=None, flush=True, **kwargs): - """ - :param alias: name to use for query string - :type alias: str - :param query: query string to save - :type query: str or None - :param flush: immediately write out to the index - :type flush: bool - """ - self.alias = alias - if query is None: - self.query = '' - else: - self.query = ' '.join(query) - self.flush = flush - Command.__init__(self, **kwargs) - - def apply(self, ui): - msg = 'saved alias "%s" for query string "%s"' % (self.alias, - self.query) - - try: - ui.dbman.save_named_query(self.alias, self.query) - logging.debug(msg) - ui.notify(msg) - except DatabaseROError: - ui.notify('index in read-only mode', priority='error') - return - - # flush index - if self.flush: - ui.apply_command(commands.globals.FlushCommand()) - - -@registerCommand( - MODE, 'removequery', - arguments=[ - (['--no-flush'], {'action': 'store_false', 'dest': 'flush', - 'default': 'True', - 'help': 'postpone a writeout to the index'}), - (['alias'], {'help': 'alias to remove'}), - ], - help='removes a "named query" from the database') -class RemoveQueryCommand(Command): - - """remove named query string for given alias""" - repeatable = False - - def __init__(self, alias, flush=True, **kwargs): - """ - :param alias: name to use for query string - :type alias: str - :param flush: immediately write out to the index - :type flush: bool - """ - self.alias = alias - self.flush = flush - Command.__init__(self, **kwargs) - - def apply(self, ui): - msg = 'removed alias "%s"' % (self.alias) - - try: - ui.dbman.remove_named_query(self.alias) - logging.debug(msg) - ui.notify(msg) - except DatabaseROError: - ui.notify('index in read-only mode', priority='error') - return - - # flush index - if self.flush: - ui.apply_command(commands.globals.FlushCommand()) diff --git a/alot/commands/search.py b/alot/commands/search.py index 413dd8e3..5d7a7cbd 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -8,7 +8,6 @@ import logging from . import Command, registerCommand from .globals import PromptCommand from .globals import MoveCommand -from .globals import SaveQueryCommand as GlobalSaveQueryCommand from .common import RetagPromptCommand from .. import commands @@ -239,24 +238,3 @@ class MoveFocusCommand(MoveCommand): ui.update() else: MoveCommand.apply(self, ui) - - -@registerCommand( - MODE, 'savequery', - arguments=[ - (['--no-flush'], {'action': 'store_false', 'dest': 'flush', - 'default': 'True', - 'help': 'postpone a writeout to the index'}), - (['alias'], {'help': 'alias to use for query string'}), - (['query'], {'help': 'query string to store', - 'nargs': argparse.REMAINDER, - }), - ], - help='store query string as a "named query" in the database. ' - 'This falls back to the current search query in search buffers.') -class SaveQueryCommand(GlobalSaveQueryCommand): - def apply(self, ui): - searchbuffer = ui.current_buffer - if not self.query: - self.query = searchbuffer.querystring - GlobalSaveQueryCommand.apply(self, ui) |