[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [elpa] externals/consult-recoll c5926ca3eb 1/2: format for size anno
From: |
Visuwesh |
Subject: |
Re: [elpa] externals/consult-recoll c5926ca3eb 1/2: format for size annotation |
Date: |
Fri, 14 Oct 2022 07:14:02 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
[வியாழன் அக்டோபர் 13, 2022] Stefan Monnier wrote:
> I see we have `memory-report--format` which does something similar.
> I'm pretty sure we have other chunks of code doing the same elsewhere.
> Should Someone™ introduce a function in `subr.el` or somesuch to solve
> it once and for all?
Don't we already have `file-size-human-readable' for that?
> Stefan
>> +(defun consult-recoll--format-size (bytes)
>> + "Format the given size with adaptive units."
>> + (let ((szn (string-to-number bytes)))
>> + (cond ((< szn 1024) (format "%s bytes" szn))
>> + ((< szn 1048576) (format "%.1f Kbs" (/ szn 1024.0)))
>> + ((< szn 1073741824) (format "%.1f Mbs" (/ szn 1024 1024)))
>> + (t (format "%.1fs Gbs" (/ szn 1024 1024 1024))))))
>> +