Subject: bug#35756: closed (Re: bug#35756: [PATCH] file-size-human-readable: fix glitches and add optional space)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 23 Jun 2019 18:30:02 +0000

Your bug report

#35756: [PATCH] file-size-human-readable: fix glitches and add optional space

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
35756: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=35756
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#35756: [PATCH] file-size-human-readable: fix glitches and add optional space
From: Mattias Engdegård <[email-masked]>
To: Lars Ingebrigtsen <[email-masked]>
Cc: Eli Zaretskii <[email-masked]>, [email-masked]
Date: Sun, 23 Jun 2019 20:29:47 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

23 juni 2019 kl. 18.56 skrev Lars Ingebrigtsen <[email-masked]>:
> 
> Looks good to me.  The only thing is:
> 
> In end of data:
> files.el:7717:1:Warning: the function `string-empty-p' is not known to be
>    defined.
> 
> That function is from subr-x, and I if I remember correctly, files.el
> isn't supposed to load that file...

Thanks, pushed with that function call eliminated in favour of (string= x "").

Subject: [PATCH] file-size-human-readable: fix glitches and add optional space
From: Mattias Engdegård <[email-masked]>
To: [email-masked]
Date: Wed, 15 May 2019 22:02:50 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

The `file-size-human-readable' function is very useful but could do with some better formatting: normally, a space goes between the number and unit; you don't write '3kg' or '25m/s' but '3 kg' and '25 m/s' (sloppy British newspapers notwithstanding). We could add an optional argument so that the caller can use the spacing of preference; the default should probably be no space, for compatibility.

For some reason, only the `iec' mode adds an actual unit (B) to the result; the default and `si' modes just append a scale prefix. Of course a user can append the unit of choice, as in:

  (concat (file-size-human-readable size 'si) "B")

which permits the function to be used for other units than bytes, such as "bit/s" (although the name makes it clear that it is intended for file sizes only). However, spacing complicates things, since we want

  (file-size-human-readable 14 'si " ")

to return "14", not "14 ", but the latter is what we need when appending the unit.
I'm not sure how to fix this. We could add another optional argument, UNIT say, which is the string to use as unit, defaulting to "B" in `iec' mode and the empty string otherwise. The attached patch does not address this.

There is also a small glitch to be fixed:

 (file-size-human-readable 3 'iec) => "3iB"

which of course should be "3B".