diff options
-rw-r--r-- | alot/db/thread.py | 21 | ||||
-rw-r--r-- | alot/defaults/alot.rc.spec | 4 | ||||
-rw-r--r-- | docs/source/configuration/alotrc_table | 11 |
3 files changed, 29 insertions, 7 deletions
diff --git a/alot/db/thread.py b/alot/db/thread.py index 8bb94a10..d3cd0757 100644 --- a/alot/db/thread.py +++ b/alot/db/thread.py @@ -1,6 +1,7 @@ # Copyright (C) 2011-2012 Patrick Totzke <patricktotzke@gmail.com> # This file is released under the GNU GPL, version 3 or a later revision. # For further details see the COPYING file +import operator from datetime import datetime from message import Message @@ -144,12 +145,11 @@ class Thread(object): def get_authors(self): """ returns a list of authors (name, addr) of the messages. - The authors are ordered by msg date and unique (by addr). + The authors are ordered by msg date and unique (by name/addr). :rtype: list of (str, str) """ if self._authors is None: - self._authors = [] seen = {} msgs = self.get_messages().keys() msgs_with_date = filter(lambda m: m.get_date() is not None, msgs) @@ -157,11 +157,18 @@ class Thread(object): # sort messages with date and append the others msgs_with_date.sort(None, lambda m: m.get_date()) msgs = msgs_with_date + msgs_without_date - for m in msgs: - pair = m.get_author() - if not pair[1] in seen: - seen[pair[1]] = True - self._authors.append(pair) + orderby = settings.get('thread_authors_order_by') + if orderby == 'latest_message': + for i, m in enumerate(msgs): + pair = m.get_author() + seen[pair] = i + else: # i.e. first_message + for i, m in enumerate(msgs): + pair = m.get_author() + if pair not in seen: + seen[pair] = i + self._authors = [ name for name, addr in + sorted(seen.items(), key=operator.itemgetter(1)) ] return self._authors def get_authors_string(self, own_addrs=None, replace_own=None): diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index 327bbc28..efeb3497 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -58,6 +58,10 @@ thread_authors_me = string(default='Me') # the thread subject thread_subject = option('oldest', 'notmuch', default='notmuch') +# When constructing the unique list of thread authors, order by date of +# author's first or latest message in thread +thread_authors_order_by = option('first_message', 'latest_message', default='first_message') + # set terminal command used for spawning shell commands terminal_cmd = string(default='x-terminal-emulator -e') diff --git a/docs/source/configuration/alotrc_table b/docs/source/configuration/alotrc_table index 35b11fa2..4125e7fc 100644 --- a/docs/source/configuration/alotrc_table +++ b/docs/source/configuration/alotrc_table @@ -559,6 +559,17 @@ :default: True +.. _thread-authors-order-by: + +.. describe:: thread_authors_order_by + + In which order to list authors. By default, list authors in the order they + joined the conversation. + + :type: option, one of ['first_message', 'latest_message'] + :default: first_message + + .. _thread-statusbar: .. describe:: thread_statusbar |