summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2011-04-09 09:59:26 +0300
committerEli Zaretskii <eliz@gnu.org>2011-04-09 09:59:26 +0300
commit04f33f1ed9cdfed6a3e44a55d333cd19d58424ca (patch)
treefde0e2644a278b7e49c0871e33a2c4db62d60022 /lisp/files.el
parentd7b898799f330e0543b3f01277114a9e98a7a456 (diff)
downloademacs-04f33f1ed9cdfed6a3e44a55d333cd19d58424ca.tar.gz
emacs-04f33f1ed9cdfed6a3e44a55d333cd19d58424ca.tar.bz2
emacs-04f33f1ed9cdfed6a3e44a55d333cd19d58424ca.zip
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.
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el5
1 files changed, 4 insertions, 1 deletions
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))