summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/commands/globals.py91
-rw-r--r--alot/commands/search.py22
-rw-r--r--alot/db/manager.py37
-rw-r--r--tests/db/test_manager.py9
4 files changed, 0 insertions, 159 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)
diff --git a/alot/db/manager.py b/alot/db/manager.py
index 3c3ce7d6..806982b5 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -154,10 +154,6 @@ class DBManager:
msg.thaw()
logging.debug('thaw')
- elif cmd == 'setconfig':
- key = current_item[2]
- value = current_item[3]
- db.set_config(key, value)
else: # tag/set/untag
querystring, tags = current_item[2:]
@@ -431,36 +427,3 @@ class DBManager:
raise DatabaseError(msg)
else:
self.writequeue.append(('add', afterwards, path, tags))
-
- def save_named_query(self, alias, querystring, afterwards=None):
- """
- add an alias for a query string.
-
- These are stored in the notmuch database and can be used as part of
- more complex queries using the syntax "query:alias".
- See :manpage:`notmuch-search-terms(7)` for more info.
-
- :param alias: name of shortcut
- :type alias: str
- :param querystring: value, i.e., the full query string
- :type querystring: str
- :param afterwards: callback to trigger after adding the alias
- :type afterwards: callable or None
- """
- if self.ro:
- raise DatabaseROError()
- self.writequeue.append(('setconfig', afterwards, 'query.' + alias,
- querystring))
-
- def remove_named_query(self, alias, afterwards=None):
- """
- remove a named query from the notmuch database.
-
- :param alias: name of shortcut
- :type alias: str
- :param afterwards: callback to trigger after adding the alias
- :type afterwards: callable or None
- """
- if self.ro:
- raise DatabaseROError()
- self.writequeue.append(('setconfig', afterwards, 'query.' + alias, ''))
diff --git a/tests/db/test_manager.py b/tests/db/test_manager.py
index 02df63d9..0f3a64ac 100644
--- a/tests/db/test_manager.py
+++ b/tests/db/test_manager.py
@@ -76,12 +76,3 @@ class TestDBManager(utilities.TestCaseClassCleanup):
# let global settings manager read our temporary notmuch config
settings.read_notmuch_config(cls.notmuch_config_path)
-
- def test_save_named_query(self):
- alias = 'key'
- querystring = 'query string'
- self.manager.save_named_query(alias, querystring)
- self.manager.flush()
-
- named_queries_dict = self.manager.get_named_queries()
- self.assertDictEqual(named_queries_dict, {alias: querystring})