]> git.eshelyaron.com Git - emacs.git/commitdiff
Produce more accurate results from file-size-human-readable.
authorEli Zaretskii <eliz@gnu.org>
Sat, 9 Apr 2011 06:59:26 +0000 (09:59 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 9 Apr 2011 06:59:26 +0000 (09:59 +0300)
 lisp/files.el (file-size-human-readable): Produce one digit after
 decimal, like "ls -lh" does.
 lisp/ls-lisp.el (ls-lisp-format-file-size): Allow for 7 characters in
 the file size representation.

lisp/ChangeLog
lisp/files.el
lisp/ls-lisp.el

index 07d77bc9d64488b2c74716f967236cf0752da988..b7d80c636a71120b4e7c0bf49144471fe0bdc7a9 100644 (file)
 
 2011-04-08  Eli Zaretskii  <eliz@gnu.org>
 
+       * files.el (file-size-human-readable): Produce one digit after
+       decimal, like "ls -lh" does.
+
+       * ls-lisp.el (ls-lisp-format-file-size): Allow for 7 characters in
+       the file size representation.
+
        * simple.el (list-processes): If async subprocesses are not
        available, error out with a clear error message.
 
index fd241041b742a7d36faad1bf303dcaf84c83d573..5b29f3790e89b40b2fa0b6d24693fe12ed21e26d 100644 (file)
@@ -1162,7 +1162,10 @@ Optional second argument FLAVOR controls the units and the display format:
     (while (and (>= file-size power) (cdr post-fixes))
       (setq file-size (/ file-size power)
            post-fixes (cdr post-fixes)))
-    (format "%.0f%s%s" file-size
+    (format (if (> (mod file-size 1.0) 0.05)
+               "%.1f%s%s"
+             "%.0f%s%s")
+           file-size
            (if (and (eq flavor 'iec) (string= (car post-fixes) "k"))
                "K"
              (car post-fixes))
index 44e8bce5b8db042e4c64de1b01b25ced4272a9ba..9314f934dc1a532aba202f0f8b4b9b3a87efb918 100644 (file)
@@ -724,7 +724,7 @@ All ls time options, namely c, t and u, are handled."
                  ls-lisp-filesize-f-fmt
                ls-lisp-filesize-d-fmt)
              file-size)
-    (format " %4s" (file-size-human-readable file-size))))
+    (format " %7s" (file-size-human-readable file-size))))
 
 (provide 'ls-lisp)