Skip to content

Commit c0ca7f0

Browse files
committed
Enable concatenation of search queries (split by " / ")
1 parent 32b885d commit c0ca7f0

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

alot/buffers/search.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,26 @@ def rebuild(self, reverse=False):
6161
if exclude_tags:
6262
exclude_tags = [t for t in exclude_tags.split(';') if t]
6363

64-
try:
65-
self.result_count = self.dbman.count_messages(self.querystring)
66-
threads = self.dbman.get_threads(
67-
self.querystring, order, exclude_tags)
68-
except NotmuchError:
69-
self.ui.notify('malformed query string: %s' % self.querystring,
70-
'error')
71-
self.listbox = urwid.ListBox([])
72-
self.body = self.listbox
73-
return
74-
75-
self.threadlist = IterableWalker(threads, ThreadlineWidget,
76-
dbman=self.dbman,
77-
reverse=reverse)
64+
querylist = self.querystring.split(' / ')
65+
for query in querylist:
66+
try:
67+
self.result_count = self.dbman.count_messages(query)
68+
threads = self.dbman.get_threads(
69+
query, order, exclude_tags)
70+
except NotmuchError:
71+
self.ui.notify('malformed query string: %s' % query,
72+
'error')
73+
self.listbox = urwid.ListBox([])
74+
self.body = self.listbox
75+
return
76+
77+
iterablewalker = IterableWalker(threads, ThreadlineWidget,
78+
dbman=self.dbman,
79+
reverse=reverse)
80+
if self.threadlist:
81+
self.threadlist.append(iterablewalker)
82+
else:
83+
self.threadlist = iterablewalker
7884

7985
self.listbox = urwid.ListBox(self.threadlist)
8086
self.body = self.listbox

alot/walker.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
import urwid
77

88

9+
def chain(*iterables):
10+
for iterable in iterables:
11+
yield from iterable
12+
13+
914
class IterableWalker(urwid.ListWalker):
1015

1116
"""An urwid walker for iterables.
@@ -92,3 +97,6 @@ def _get_next_item(self):
9297

9398
def get_lines(self):
9499
return self.lines
100+
101+
def append(self, iterableWalker):
102+
self.iterable = chain(self.iterable, iterableWalker.iterable)

0 commit comments

Comments
 (0)