diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2018-06-25 15:55:35 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-07-24 22:05:57 +0100 |
commit | 297121e1d6c56424612faa510216b90b1827fad5 (patch) | |
tree | 75d67fee08bbfa2e87de5d7b2b6dfeb54afab1b8 /alot/db/manager.py | |
parent | 945616cdc1dba5bf0cc6a7618a06d18176cb6fff (diff) |
add setter for (notmuch) configs to database manager
these can be used to define/remove new named query strings
Diffstat (limited to 'alot/db/manager.py')
-rw-r--r-- | alot/db/manager.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/alot/db/manager.py b/alot/db/manager.py index 14925816..0ea9e7db 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -152,6 +152,11 @@ class DBManager(object): path = current_item[2] db.remove_message(path) + 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:] query = db.create_query(querystring) @@ -446,3 +451,36 @@ class DBManager(object): raise DatabaseROError() path = message.get_filename() self.writequeue.append(('remove', afterwards, path)) + + 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, '')) |