From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Wed, 07 Nov 2007 12:08:50 -0800 Subject: [sup-talk] [PATCH] Show unread message count in thread index In-Reply-To: <1194430991-sup-3015@lankhmar> References: <1194256715-sup-4315@lankhmar> <1194400626-sup-6556@south> <1194430991-sup-3015@lankhmar> Message-ID: <1194465975-sup-3345@south> Excerpts from Colin Bell's message of Wed Nov 07 02:29:03 -0800 2007: > Please take a careful look at this patch as I am just learning Ruby so > I've probably done a few silly things. I've applied this patch in modified form. There was a little work to be done when the size of the widget changes (namely, if a widget suddenly exceeds the previous size due to a change, the whole screen has to be redrawn). I've also renamed the hook "index-mode-size-widget", in case there are other widgets you'll want to tweak later. :) I've been trying it and I actually quite like this slight modification of your hook code, which only displays the unread/total breakdown in the case where some, but not all, messages in a thread are unread: unread_size = thread.map { |m, *o| m && m.has_label?(:unread) ? 1 : 0 }.sum size = thread.size case when size == 1 : "" when (unread_size == 0) || (unread_size == size) : "(#{size})" else "(#{unread_size}/#{size})" end -- William