From f788ddd0659ae6468871b225f2bd8160a5c656d7 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 5 Apr 2018 09:11:08 +0200 Subject: [PATCH] display per message subjects in thread widget Many senders to not quite grasp the concept of a mail thread, and this "hijack" a thread by replying and changing the subject. In addition, there may be good reasons for replies with changed subject, such as an adjustment of status or the typical patch series threads with individual topics. Currently, all this information is hidden in collapsed view but may be valuable for expanding the right message. Therefore, provide individual subjects for the messages in thread view. --- alot/db/message.py | 7 +++++++ alot/widgets/thread.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/alot/db/message.py b/alot/db/message.py index 6b1a3d9b8..ab08ad124 100644 --- a/alot/db/message.py +++ b/alot/db/message.py @@ -68,6 +68,10 @@ def __init__(self, dbman, msg, thread=None): self._from = '"{}" <{}>'.format(acc.realname, str(acc.address)) else: self._from = '"Unknown" <>' + try: + self._subject = decode_header(msg.header('Subject')) + except (NullPointerError, LookupError): + self._subject = '' def __str__(self): """prettyprint the message""" @@ -132,6 +136,9 @@ def get_message_parts(self): if not msg.is_multipart(): yield msg + def get_subject(self): + return self._subject + def get_tags(self): """returns tags attached to this message as list of strings""" return sorted(self._tags) diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index c5276df83..ffbfb5d46 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -78,9 +78,12 @@ def _render_wrap(size, focus=False): def __str__(self): author, address = self.message.get_author() date = self.message.get_datestring() + subject = self.message.get_subject() rep = author if author != '' else address if date is not None: rep += " (%s)" % date + if subject: + rep += ": %s" % subject return rep def selectable(self):