Skip to content

Commit

Permalink
display matched and total in mailcount
Browse files Browse the repository at this point in the history
Now that thread objects remember the original query, enhance the
mailcount to show the number of matched and total messages in a thread
in the search widget analogous to `notmuch search`.

The original width in the default theme was 5: two parentheses plus up
to three digits. We need to increase this 2+3+3+1=9 now (parentheses,
three digits for each of the counts, slash).
  • Loading branch information
mjg committed Dec 30, 2020
1 parent 632fe82 commit dfa682e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions alot/db/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def refresh(self, thread=None):
def _refresh(self, thread):
self._total_messages = len(thread)
self._notmuch_authors_string = thread.authors
self._matched_messages = thread.matched

subject_type = settings.get('thread_subject')
if subject_type == 'notmuch':
Expand Down Expand Up @@ -283,6 +284,10 @@ def get_total_messages(self):
"""returns number of contained messages"""
return self._total_messages

def get_matched_messages(self):
"""returns number of contained messages"""
return self._matched_messages

def matches(self, query):
"""
Check if this thread matches the given notmuch query.
Expand Down
2 changes: 1 addition & 1 deletion alot/defaults/default.theme
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
[[[mailcount]]]
normal = 'default','','light gray','default','g66','default'
focus = 'standout','','yellow','light gray','yellow','g58'
width = 'fit', 5,5
width = 'fit', 9,9
[[[tags]]]
normal = 'bold','','dark cyan','','dark cyan',''
focus = 'standout','','yellow','light gray','yellow','g58'
Expand Down
2 changes: 1 addition & 1 deletion alot/widgets/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def prepare_date_string(thread):


def prepare_mailcount_string(thread):
return "(%d)" % thread.get_total_messages()
return "(%d/%d)" % (thread.get_matched_messages(), thread.get_total_messages())


def prepare_authors_string(thread):
Expand Down

0 comments on commit dfa682e

Please sign in to comment.