From 04f33f1ed9cdfed6a3e44a55d333cd19d58424ca Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 9 Apr 2011 09:59:26 +0300 Subject: [PATCH] Produce more accurate results from file-size-human-readable. 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 | 6 ++++++ lisp/files.el | 5 ++++- lisp/ls-lisp.el | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 07d77bc9d64..b7d80c636a7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -12,6 +12,12 @@ 2011-04-08 Eli Zaretskii + * 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. diff --git a/lisp/files.el b/lisp/files.el index fd241041b74..5b29f3790e8 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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)) diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index 44e8bce5b8d..9314f934dc1 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el @@ -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) -- 2.39.2