summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
Diffstat (limited to 'alot')
-rw-r--r--alot/buffer.py14
-rw-r--r--alot/command.py2
-rw-r--r--alot/message.py4
3 files changed, 19 insertions, 1 deletions
diff --git a/alot/buffer.py b/alot/buffer.py
index fe500536..4b5e6264 100644
--- a/alot/buffer.py
+++ b/alot/buffer.py
@@ -22,6 +22,7 @@ from notmuch.globals import NotmuchError
import widgets
import settings
+import command
from walker import IteratorWalker
from message import decode_header
@@ -216,7 +217,6 @@ class ThreadBuffer(Buffer):
childcount[p] -= 1
bars.append(childcount[p] > 0)
-#TODO unfold unread
mwidget = widgets.MessageWidget(m, even=(num % 2 == 0),
depth=depth,
bars_at=bars)
@@ -237,6 +237,18 @@ class ThreadBuffer(Buffer):
def get_focus(self):
return self.body.get_focus()
+ def unfold_matching(self, querystring):
+ for mw in self.get_message_widgets():
+ msg = mw.get_message()
+ if msg.matches(querystring):
+ if 'unread' in msg.get_tags():
+ msg.remove_tags(['unread'])
+ self.ui.apply_command(command.FlushCommand())
+ mw.fold(visible=True)
+
+ def get_message_widgets(self):
+ return self.body.body.contents
+
class TagListBuffer(Buffer):
def __init__(self, ui, alltags=[], filtfun=None):
diff --git a/alot/command.py b/alot/command.py
index 56cdd591..55ab9c51 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -73,10 +73,12 @@ class OpenThreadCommand(Command):
def apply(self, ui):
if not self.thread:
self.thread = ui.current_buffer.get_selected_thread()
+ query = ui.current_buffer.querystring
ui.logger.info('open thread view for %s' % self.thread)
sb = buffer.ThreadBuffer(ui, self.thread)
ui.buffer_open(sb)
+ sb.unfold_matching(query)
class SearchCommand(Command):
diff --git a/alot/message.py b/alot/message.py
index 276469f1..6c78580b 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -152,6 +152,10 @@ class Message:
def accumulate_body(self):
return extract_body(self.get_email())
+ def matches(self, querystring):
+ searchfor = querystring + ' AND id:' + self._id
+ return self._dbman.count_messages(searchfor) > 0
+
def extract_body(mail):
bodytxt = ''