summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alot/buffers.py7
-rw-r--r--alot/commands/globals.py3
-rw-r--r--alot/db/manager.py7
-rw-r--r--docs/source/configuration/config_options.rst16
-rw-r--r--docs/source/usage/modes/global.rst3
5 files changed, 32 insertions, 4 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):
diff --git a/docs/source/configuration/config_options.rst b/docs/source/configuration/config_options.rst
index eba44bc1..c654a102 100644
--- a/docs/source/configuration/config_options.rst
+++ b/docs/source/configuration/config_options.rst
@@ -9,3 +9,19 @@ if the type says "boolean" you may only provide "True" or "False" as values in y
otherwise alot will complain on startup. Strings *may* be quoted but do not need to be.
.. include:: alotrc_table
+
+Notmuch options
+---------------
+
+The following lists the notmuch options that alot reads.
+
+.. _search.exclude_tags:
+
+.. describe:: search.exclude_tags
+
+ A list of tags that will be excluded from search results by
+ default. Using an excluded tag in a query will override that
+ exclusion.
+
+ :type: semicolon separated list
+ :default: empty list
diff --git a/docs/source/usage/modes/global.rst b/docs/source/usage/modes/global.rst
index f9f0b880..066acde7 100644
--- a/docs/source/usage/modes/global.rst
+++ b/docs/source/usage/modes/global.rst
@@ -26,7 +26,8 @@ The following commands are available globally
.. describe:: search
- open a new search buffer
+ open a new search buffer. Search obeys the notmuch
+ :ref:`search.exclude_tags <search.exclude_tags>` setting.
argument
search string