Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Change behaviour %k in gnus-summary-line-format?
@ 2003-10-08  8:12 Svend Tollak Munkejord
  2003-10-08 15:49 ` Reiner Steib
  0 siblings, 1 reply; 3+ messages in thread
From: Svend Tollak Munkejord @ 2003-10-08  8:12 UTC (permalink / raw)


Hi,

With

(gnus-summary-line-format 
  "%U%R %(%[%10&user-date;: %-23,23f (%k)%]%B %s%)\n")

the size of the message is displayed due to the %k. If it is in the range
of 100k, I see "0.1M". 

Would it be possible to tell Gnus to display, say, "103k" instead, 1) making
it easier to read, and 2) increasing the number of significant digits by two?

(I use Gnus 5.10.2 and GNU Emacs 21.2).

Cheers,
-- 
Svend Tollak Munkejord 


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

* Re: Change behaviour %k in gnus-summary-line-format?
  2003-10-08  8:12 Change behaviour %k in gnus-summary-line-format? Svend Tollak Munkejord
@ 2003-10-08 15:49 ` Reiner Steib
  2003-10-08 16:49   ` Svend Tollak Munkejord
  0 siblings, 1 reply; 3+ messages in thread
From: Reiner Steib @ 2003-10-08 15:49 UTC (permalink / raw)
  Cc: Frank Haun

On Wed, Oct 08 2003, Svend Tollak Munkejord wrote:

[...]
> the size of the message is displayed due to the %k. If it is in the range
> of 100k, I see "0.1M". 
>
> Would it be possible to tell Gnus to display, say, "103k" instead,
> 1) making it easier to read, and 2) increasing the number of
> significant digits by two?

(defsubst gnus-summary-line-message-size (head)
  "Return pretty-printed version of message size.
This function is intended to be used in
`gnus-summary-line-format-alist'."
  (let ((c (or (mail-header-chars head) -1)))
    (cond ((< c 0) "n/a") ;; chars not available
	  ((< c (* 1000))       (format "%db" c))
	  ((< c (* 1000 10))    (format "%1.1fk" (/ c 1024.0)))
	  ((< c (* 1000 1000))  (format "%dk" (/ c 1024.0)))
	  ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
	  (t (format "%dM" (/ c (* 1024.0 1024)))))))

This will print the numbers as "941b", "1.1k", " 86k", "102k", "472k",
"1.1M".  It seems that users have different preferences here: 100k or
0.1M?  900k or 0.9M?  Some people prefer the former
<news:8665yqqqlp.fsf@pille.fhaun.de>, some the latter
<news:r8hevize.fsf@hschmi22.userfqdn.rz-online.de>.

Is it useful to add another format specifier (say "K") or should we
leave it as an exercise for the user?

,----[ (info "(gnus)Summary Buffer Lines") ]
| `u'
|      User defined specifier.  The next character in the format string
|      should be a letter.  Gnus will call the function
|      `gnus-user-format-function-X', where X is the letter following
|      `%u'.  The function will be passed the current header as argument.
|      The function should return a string, which will be inserted into
|      the summary just like information from any other summary specifier.
`----

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo--- PGP key available via WWW   http://rsteib.home.pages.de/


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

* Re: Change behaviour %k in gnus-summary-line-format?
  2003-10-08 15:49 ` Reiner Steib
@ 2003-10-08 16:49   ` Svend Tollak Munkejord
  0 siblings, 0 replies; 3+ messages in thread
From: Svend Tollak Munkejord @ 2003-10-08 16:49 UTC (permalink / raw)


Today, Reiner Steib <4.uce.03.r.s@nurfuerspam.de> wrote:

> On Wed, Oct 08 2003, Svend Tollak Munkejord wrote:
>
> [...]
>> the size of the message is displayed due to the %k. If it is in the
>> range of 100k, I see "0.1M".
>>
>> Would it be possible to tell Gnus to display, say, "103k" instead,
>> 1) making it easier to read, and 2) increasing the number of
>> significant digits by two?
>
> (defsubst gnus-summary-line-message-size (head)
> "Return pretty-printed version of message size.
> This function is intended to be used in
> `gnus-summary-line-format-alist'."
> (let ((c (or (mail-header-chars head) -1)))
> (cond ((< c 0) "n/a") ;; chars not available
> 	  ((< c (* 1000))       (format "%db" c))
> 	  ((< c (* 1000 10))    (format "%1.1fk" (/ c 1024.0)))
> 	  ((< c (* 1000 1000))  (format "%dk" (/ c 1024.0)))
> 	  ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
> 	  (t (format "%dM" (/ c (* 1024.0 1024)))))))

That was nice. Thanks!

> This will print the numbers as "941b", "1.1k", " 86k", "102k", "472k",
> "1.1M".  It seems that users have different preferences here: 100k or
> 0.1M?  900k or 0.9M?  Some people prefer the former
> <news:8665yqqqlp.fsf@pille.fhaun.de>, some the latter
> <news:r8hevize.fsf@hschmi22.userfqdn.rz-online.de>.

As implicit in my question, I support the former, since "0." takes up the
space of two characters without conveying information.

Regards,
-- 
Svend Tollak Munkejord 


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

end of thread, other threads:[~2003-10-08 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-08  8:12 Change behaviour %k in gnus-summary-line-format? Svend Tollak Munkejord
2003-10-08 15:49 ` Reiner Steib
2003-10-08 16:49   ` Svend Tollak Munkejord

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).