Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable concatenation of search queries (split by " / ") #1537

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions alot/buffers/search.py
Original file line number Diff line number Diff line change
@@ -61,20 +61,28 @@ def rebuild(self, reverse=False):
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)
except NotmuchError:
self.ui.notify('malformed query string: %s' % self.querystring,
'error')
self.listbox = urwid.ListBox([])
self.body = self.listbox
return

self.threadlist = IterableWalker(threads, ThreadlineWidget,
dbman=self.dbman,
reverse=reverse)
self.result_count = 0
self.threadlist = None
querylist = self.querystring.split(' / ')
for query in querylist:
try:
self.result_count += self.dbman.count_messages(query)
threads = self.dbman.get_threads(
query, order, exclude_tags)
except NotmuchError:
self.ui.notify('malformed query string: %s' % query,
'error')
self.listbox = urwid.ListBox([])
self.body = self.listbox
return

iterablewalker = IterableWalker(threads, ThreadlineWidget,
dbman=self.dbman,
reverse=reverse)
if self.threadlist:
self.threadlist.append(iterablewalker)
else:
self.threadlist = iterablewalker

self.listbox = urwid.ListBox(self.threadlist)
self.body = self.listbox
4 changes: 4 additions & 0 deletions alot/walker.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
# Copyright © 2018 Dylan Baker
# This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
import itertools
import logging
import urwid

@@ -92,3 +93,6 @@ def _get_next_item(self):

def get_lines(self):
return self.lines

def append(self, iterableWalker):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this is called after somebody started iterating over the IterableWalker already? Is that a case we have to think about? Even if this method is trivial it might be worth it to add a docstring to mention such constrains (if there are some).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I'll try to test that case somehow.

self.iterable = itertools.chain(self.iterable, iterableWalker.iterable)