Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pazz/alot
Browse files Browse the repository at this point in the history
  • Loading branch information
pazz committed Sep 23, 2021
2 parents b4ec642 + a814a77 commit f17029d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
7 changes: 1 addition & 6 deletions alot/buffers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@ def rebuild(self, reverse=False, restore_focus=True):
if restore_focus and self.threadlist:
selected_thread = self.get_selected_thread()

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.result_count = self.dbman.count_messages(self.querystring)
threads = self.dbman.get_threads(
self.querystring, order, exclude_tags)
threads = self.dbman.get_threads(self.querystring, order)
except NotmuchError:
self.ui.notify('malformed query string: %s' % self.querystring,
'error')
Expand Down
23 changes: 15 additions & 8 deletions alot/db/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ def __init__(self, path=None, ro=False):
self.writequeue = deque([])
self.processes = []

@property
def exclude_tags(self):
exclude_tags = settings.get('exclude_tags')
if exclude_tags is not None:
return exclude_tags

exclude_tags = settings.get_notmuch_setting('search', 'exclude_tags')
if exclude_tags:
return [t for t in exclude_tags.split(';') if t]

def flush(self):
"""
write out all queued write-commands in order, each one in a separate
Expand Down Expand Up @@ -243,14 +253,14 @@ def count_messages(self, querystring):
"""returns number of messages that match `querystring`"""
db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
return db.count_messages(querystring,
exclude_tags=settings.get('exclude_tags'))
exclude_tags=self.exclude_tags)

def collect_tags(self, querystring):
"""returns tags of messages that match `querystring`"""
db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
tagset = notmuch2._tags.ImmutableTagSet(
db.messages(querystring,
exclude_tags=settings.get('exclude_tags')),
exclude_tags=self.exclude_tags),
'_iter_p',
notmuch2.capi.lib.notmuch_messages_collect_tags)
return [t for t in tagset]
Expand All @@ -259,7 +269,7 @@ def count_threads(self, querystring):
"""returns number of threads that match `querystring`"""
db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
return db.count_threads(querystring,
exclude_tags=settings.get('exclude_tags'))
exclude_tags=self.exclude_tags)

@contextlib.contextmanager
def _with_notmuch_thread(self, tid):
Expand Down Expand Up @@ -309,7 +319,7 @@ def get_named_queries(self):
return {k[6:]: db.config[k] for k in db.config if
k.startswith('query.')}

def get_threads(self, querystring, sort='newest_first', exclude_tags=None):
def get_threads(self, querystring, sort='newest_first'):
"""
asynchronously look up thread ids matching `querystring`.
Expand All @@ -318,9 +328,6 @@ def get_threads(self, querystring, sort='newest_first', exclude_tags=None):
: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`,
Expand All @@ -330,7 +337,7 @@ def get_threads(self, querystring, sort='newest_first', exclude_tags=None):
db = Database(path=self.path, mode=Database.MODE.READ_ONLY)
for t in db.threads(querystring,
sort=self._sort_orders[sort],
exclude_tags=settings.get('exclude_tags')):
exclude_tags=self.exclude_tags):
yield t.threadid

def add_message(self, path, tags=None, afterwards=None):
Expand Down
4 changes: 2 additions & 2 deletions alot/defaults/alot.rc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ attachment_prefix = string(default='~')
input_timeout = float(default=1.0)

# A list of tags that will be excluded from search results by default. Using an excluded tag in a query will override that exclusion.
# .. note:: this config setting is equivalent to, but independent of, the 'search.exclude_tags' in the notmuch config.
exclude_tags = force_list(default=list())
# .. note:: when set, this config setting will overrule the 'search.exclude_tags' in the notmuch config.
exclude_tags = force_list(default=None)

# display background colors set by ANSI character escapes
interpret_ansi_background = boolean(default=True)
Expand Down
4 changes: 2 additions & 2 deletions docs/source/configuration/alotrc_table
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@
.. describe:: 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.
.. note:: this config setting is equivalent to, but independent of, the 'search.exclude_tags' in the notmuch config.
.. note:: when set, this config setting will overrule the 'search.exclude_tags' in the notmuch config.

:type: string list
:default: ,
:default: None


.. _flush-retry-timeout:
Expand Down

0 comments on commit f17029d

Please sign in to comment.