Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] [PATCH] Show unread message count in thread index
@ 2007-11-05 10:01 Colin Bell
  2007-11-07  2:09 ` William Morgan
  0 siblings, 1 reply; 8+ messages in thread
From: Colin Bell @ 2007-11-05 10:01 UTC (permalink / raw)


Hi,

This patch shows the unread message count in the thread index as well
as the total number of messages in the thread.

E.G:


2:17pm Marcus,Grant,William (1/ 3)  [sup-talk] [PATCH] Check IMAP
2:15pm Marcus,William       (0/ 2)  [sup-talk] [PATCH] More IMAP/

--
Col

-------------- next part --------------
A non-text attachment was scrubbed...
Name: unread.diff
Type: application/octet-stream
Size: 1745 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071105/167121b3/attachment.obj 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-05 10:01 [sup-talk] [PATCH] Show unread message count in thread index Colin Bell
@ 2007-11-07  2:09 ` William Morgan
  2007-11-07  3:55   ` Colin Bell
  2007-11-07 10:29   ` Colin Bell
  0 siblings, 2 replies; 8+ messages in thread
From: William Morgan @ 2007-11-07  2:09 UTC (permalink / raw)


Hi Colin,

Excerpts from Colin Bell's message of Mon Nov 05 02:01:31 -0800 2007:
> This patch shows the unread message count in the thread index as well
> as the total number of messages in the thread.

I personally don't like this, because I feel like it clutters up
index-mode. But I'd like people to be able to do this sort of thing.

How about an "index-mode-widget" hook instead, that lets you replace the
"(###)" with any string you want, based on the thread? (And if the
return value is nil, use the current thread.size string.)

You'll have to scan over them twice to get the sizing right, but it
shouldn't be too bad of a patch...

-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-07  2:09 ` William Morgan
@ 2007-11-07  3:55   ` Colin Bell
  2007-11-07 10:29   ` Colin Bell
  1 sibling, 0 replies; 8+ messages in thread
From: Colin Bell @ 2007-11-07  3:55 UTC (permalink / raw)


Excerpts from William Morgan's message of Wed Nov 07 13:09:46 +1100 2007:
> I personally don't like this, because I feel like it clutters up
> index-mode. But I'd like people to be able to do this sort of thing.
>
> How about an "index-mode-widget" hook instead, that lets you replace the
> "(###)" with any string you want, based on the thread? (And if the
> return value is nil, use the current thread.size string.)

Good idea. I'll try to take a look at it tonight.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-07  2:09 ` William Morgan
  2007-11-07  3:55   ` Colin Bell
@ 2007-11-07 10:29   ` Colin Bell
  2007-11-07 20:08     ` William Morgan
  1 sibling, 1 reply; 8+ messages in thread
From: Colin Bell @ 2007-11-07 10:29 UTC (permalink / raw)


Excerpts from William Morgan's message of Wed Nov 07 13:09:46 +1100 2007:
> How about an "index-mode-widget" hook instead, that lets you replace the
> "(###)" with any string you want, based on the thread? (And if the
> return value is nil, use the current thread.size string.)
>
> You'll have to scan over them twice to get the sizing right, but it
> shouldn't be too bad of a patch...
>

Attempt 2 :-)

I've attached an example hook as well as the diff. If you accept the
patch something like the example should go up on the wiki.

Please take a careful look at this patch as I am just learning Ruby so
I've probably done a few silly things.

index-mode-widget
-----------------
File: ~/.sup/hooks/index-mode-widget.rb
Executes when formatting the output of the number of messages for each thread in the thread index.
Variables:
      thread: The message thread to be formatted.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widget.diff
Type: application/octet-stream
Size: 2708 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071107/dd62a04e/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: index-mode-widget.rb
Type: application/octet-stream
Size: 203 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071107/dd62a04e/attachment-0001.obj 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-07 10:29   ` Colin Bell
@ 2007-11-07 20:08     ` William Morgan
  2007-11-07 21:09       ` Marcus Williams
  0 siblings, 1 reply; 8+ messages in thread
From: William Morgan @ 2007-11-07 20:08 UTC (permalink / raw)


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 <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-07 20:08     ` William Morgan
@ 2007-11-07 21:09       ` Marcus Williams
  2007-11-07 23:12         ` William Morgan
  0 siblings, 1 reply; 8+ messages in thread
From: Marcus Williams @ 2007-11-07 21:09 UTC (permalink / raw)


On 7.11.2007, William Morgan wrote:
> I've also renamed the hook "index-mode-size-widget", in case there are
> other widgets you'll want to tweak later. :)

... status bar for instance :) I'm in the middle of doing one for this
but its causing me bother! Is there any way to get the new message
count without search for unread labels? How fast is that in ferret?
What happens if your result set has 60k messages in it, does it chew
memory? I cant imagine having 60k new messages, but on initial
sup-sync you might on a big mailbox.

Marcus


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-07 21:09       ` Marcus Williams
@ 2007-11-07 23:12         ` William Morgan
  2007-11-08  8:31           ` Marcus Williams
  0 siblings, 1 reply; 8+ messages in thread
From: William Morgan @ 2007-11-07 23:12 UTC (permalink / raw)


Excerpts from Marcus Williams's message of Wed Nov 07 13:09:10 -0800 2007:
> Is there any way to get the new message count without search for
> unread labels?

Nope. Unread is just another label, so you've got to do the search.

> How fast is that in ferret?

Pretty fast!

  $ sh devel/console.sh
  [Wed Nov 07 15:03:42 -0800 2007] loading index...
  [Wed Nov 07 15:03:42 -0800 2007] loaded index of 65765 messages
  >> require 'benchmark'
  >> all = "+label:unread -label:deleted -label:killed -label:spam"
  >> inbox = all + " +label:inbox"
  >> puts Benchmark.measure { Index.ferret.search(all).total_hits }
    0.020000   0.000000   0.020000 (  0.015534)
  >> Index.ferret.search(all).total_hits
  => 57551
  >> puts Benchmark.measure { Index.ferret.search(inbox).total_hits }
  => nil
  >> Index.ferret.search(inbox).total_hits
  => 13

The number in parentheses is elapsed real time. Probably fast enough to
call on every keypress, but feel free to cache it if you like.

> What happens if your result set has 60k messages in it, does it chew
> memory?

Nope. Play around with the methods above. Ferret is pretty good about
this.

> I cant imagine having 60k new messages, but on initial sup-sync you
> might on a big mailbox.

As you can see above, 57k of the 66k messages in my index are new.
(It's the last few years of ruby-talk.) Have I blown your mind? :)


-- 
William <wmorgan-sup at masanjin.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [sup-talk] [PATCH] Show unread message count in thread index
  2007-11-07 23:12         ` William Morgan
@ 2007-11-08  8:31           ` Marcus Williams
  0 siblings, 0 replies; 8+ messages in thread
From: Marcus Williams @ 2007-11-08  8:31 UTC (permalink / raw)


On 7.11.2007, William Morgan wrote:
> > I cant imagine having 60k new messages, but on initial sup-sync you
> > might on a big mailbox.
> 
> As you can see above, 57k of the 66k messages in my index are new.
> (It's the last few years of ruby-talk.) Have I blown your mind? :)

ruby seems to do this regularly (at the moment daily!) :)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-11-08  8:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-05 10:01 [sup-talk] [PATCH] Show unread message count in thread index Colin Bell
2007-11-07  2:09 ` William Morgan
2007-11-07  3:55   ` Colin Bell
2007-11-07 10:29   ` Colin Bell
2007-11-07 20:08     ` William Morgan
2007-11-07 21:09       ` Marcus Williams
2007-11-07 23:12         ` William Morgan
2007-11-08  8:31           ` Marcus Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox