Gnus development mailing list
 help / color / mirror / Atom feed
* rounding down totals
@ 2009-11-12 21:43 Ted Zlatanov
  2010-01-18 17:30 ` Ted Zlatanov
  0 siblings, 1 reply; 2+ messages in thread
From: Ted Zlatanov @ 2009-11-12 21:43 UTC (permalink / raw)
  To: ding

In Gnus, I'd like to display the total number of messages less
precisely, rounding down to the nearest 10^3 power.  Basically:

1 => 1
100 => 100
1000 => 1K
5001 => 5K

I may get fancier with the rounding (e.g. 10+ for 12 and 100+ for 190),
but can anyone tell me if there is an easy way to plug this into the
formats, or do I have to write a bunch of user functions?

Thanks
Ted




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

* Re: rounding down totals
  2009-11-12 21:43 rounding down totals Ted Zlatanov
@ 2010-01-18 17:30 ` Ted Zlatanov
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Zlatanov @ 2010-01-18 17:30 UTC (permalink / raw)
  To: ding

On Thu, 12 Nov 2009 15:43:44 -0600 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> In Gnus, I'd like to display the total number of messages less
TZ> precisely, rounding down to the nearest 10^3 power.  Basically:

TZ> 1 => 1
TZ> 100 => 100
TZ> 1000 => 1K
TZ> 5001 => 5K

TZ> I may get fancier with the rounding (e.g. 10+ for 12 and 100+ for 190),
TZ> but can anyone tell me if there is an easy way to plug this into the
TZ> formats, or do I have to write a bunch of user functions?

I came up with this.  It's extremely customized--you will probably not
like my choices at all, but I was trying to make them visually memorable
and somewhat meaningful.  The look comes out like this:

[ Gnus ♀♀♀♀♀♀♀+ ] 
  [ mine ♂+ ] 
          җҗҗҗҗҗ/җҗҗҗҗҗ    : mail 
*               /          : dev 
                /җҗҗ       : xy 
*               /          : zyx 
*               /          : hr 
              жж/жж        : xyz 
  [ main ♀♀♀+ ] 
              ♀+/♀♀+       : INBOX.mail 
...

I hope this is useful to someone.

In case you're wondering why not just show the counts, my goal was to
avoid numbers in the display.  Visually they are distracting IMO, when
you really want a graphical overview of the groups (the distinction is
similar to showing a table of numbers vs. showing a graph of the
numbers).

I'll see if I can play with actual graphics instead of Unicode symbols,
something like sparklines[1] but I need to find out what Emacs can do in
that area.

Ted

[1] http://en.wikipedia.org/wiki/Sparkline

(setq
 gnus-topic-line-format "%i[ %u&topic-line; ] %v\n"
 gnus-group-line-format "%M%S%p%P %21uX:%B%(%g%)%l %O\n")

(defun gnus-user-format-function-X (group)
  "Return \"unseen/unread\".  For use in the group specifier."
  (let ((unread (tzz-summarize-number (string-to-number gnus-tmp-number-of-unread)))
        (unseen (tzz-summarize-number (gnus-number-of-unseen-articles-in-group gnus-tmp-group))))
    (if (not (or (string-equal unseen "0")))
        (format "%010s/%-010s" unseen unread)
      unread)))

;; this corresponds to a topic line format of "%n %A"
(defun gnus-user-format-function-topic-line (dummy)
  (let* ((topic-face (if (zerop total-number-of-articles)
			 'fl-comment-face
		       'fl-function-name-face)))
    (propertize
     (format "%s %s" name (tzz-summarize-number total-number-of-articles))
     'face topic-face)))

(defun tzz-summarize-number (n)
  (cond
   ((null n) "?")
   ((< n 3) (make-string n ?ж))
   ((< n 7) (make-string n ?җ))
   ((< n 10) (make-string n ?Җ))
   ((< n 50) (concat (make-string (/ n 10) ?♂) "+"))
   ((< n 500) (concat (make-string (/ n 50) ?♀) "+"))
   ((< n 1000) (concat (make-string (/ n 100) ?C) "+"))
   (t "M+")))




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

end of thread, other threads:[~2010-01-18 17:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-12 21:43 rounding down totals Ted Zlatanov
2010-01-18 17:30 ` Ted Zlatanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).