diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-02 20:28:57 +0200 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-08 13:26:00 +0200 |
commit | ba84186f82833b4f5eab2015931e1b05651a48f1 (patch) | |
tree | ce2e20c1aea72ebccea24a67d5c22cb77e8334a9 /alot | |
parent | 3b935dff34da6bfed4d8643946a86086bdb78cba (diff) |
Exclude search.exclude_tags from searches
Fixes #707 and #332.
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'alot')
-rw-r--r-- | alot/buffers.py | 7 | ||||
-rw-r--r-- | alot/commands/globals.py | 3 | ||||
-rw-r--r-- | alot/db/manager.py | 7 |
3 files changed, 14 insertions, 3 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index 93ca60f0..80ec0855 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -260,9 +260,14 @@ class SearchBuffer(Buffer): else: order = self.sort_order + exclude_tags = settings.get_notmuch_setting('search', 'exclude_tags') + if exclude_tags: + exclude_tags = [t for t in exclude_tags.split(';') if t] + try: self.pipe, self.proc = self.dbman.get_threads(self.querystring, - order) + order, + exclude_tags) except NotmuchError: self.ui.notify('malformed query string: %s' % self.querystring, 'error') diff --git a/alot/commands/globals.py b/alot/commands/globals.py index c8acbee6..fcd92e97 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -89,7 +89,8 @@ class ExitCommand(Command): (['query'], {'nargs': argparse.REMAINDER, 'help': 'search string'})]) class SearchCommand(Command): - """open a new search buffer""" + """open a new search buffer. Search obeys the notmuch + :ref:`search.exclude_tags <search.exclude_tags>` setting.""" repeatable = True def __init__(self, query, sort=None, **kwargs): diff --git a/alot/db/manager.py b/alot/db/manager.py index 6bbaca2f..cd0c5073 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -368,7 +368,7 @@ class DBManager(object): sender.close() return receiver, process - def get_threads(self, querystring, sort='newest_first'): + def get_threads(self, querystring, sort='newest_first', exclude_tags=None): """ asynchronously look up thread ids matching `querystring`. @@ -377,6 +377,8 @@ class DBManager(object): :param sort: Sort order. one of ['oldest_first', 'newest_first', 'message_id', 'unsorted'] :type query: str + :param exclude_tags: Tags to exclude by default unless included in the search + :type exclude_tags: list of str :returns: a pipe together with the process that asynchronously writes to it. :rtype: (:class:`multiprocessing.Pipe`, @@ -385,6 +387,9 @@ class DBManager(object): assert sort in self._sort_orders q = self.query(querystring) q.set_sort(self._sort_orders[sort]) + if exclude_tags: + for tag in exclude_tags: + q.exclude_tag(tag) return self.async(q.search_threads, (lambda a: a.get_thread_id())) def query(self, querystring): |