From: Stefan Kangas Date: Sat, 5 Aug 2023 12:49:26 +0000 (+0200) Subject: Use file-size-human-readable in eshell X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7df1adab1e1a9a37920f3fa107794c2d081ebaf4;p=emacs.git Use file-size-human-readable in eshell * lisp/eshell/esh-util.el (eshell-printable-size): Simplify using file-size-human-readable. --- diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index 82b0d9fc623..6353e3d4aae 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el @@ -439,37 +439,15 @@ Prepend remote identification of `default-directory', if any." (error "human-readable must be 1000 or 1024")) (let ((size (float (or filesize 0)))) (if human-readable - (if (< size human-readable) - (if (= (round size) 0) - "0" - (if block-size - "1.0k" - (format "%.0f" size))) - (setq size (/ size human-readable)) - (if (< size human-readable) - (if (<= size 9.94) - (format "%.1fk" size) - (format "%.0fk" size)) - (setq size (/ size human-readable)) - (if (< size human-readable) - (let ((str (if (<= size 9.94) - (format "%.1fM" size) - (format "%.0fM" size)))) - (if use-colors - (put-text-property 0 (length str) - 'face 'bold str)) - str) - (setq size (/ size human-readable)) - (if (< size human-readable) - (let ((str (if (<= size 9.94) - (format "%.1fG" size) - (format "%.0fG" size)))) - (if use-colors - (put-text-property 0 (length str) - 'face 'bold-italic str)) - str) - (let ((flavor (and (= human-readable 1000) 'si))) - (file-size-human-readable filesize flavor)))))) + (let* ((flavor (and (= human-readable 1000) 'si)) + (str (file-size-human-readable size flavor))) + (if (not use-colors) + str + (cond ((> size (expt human-readable 3)) + (propertize str 'face 'bold-italic)) + ((> size (expt human-readable 2)) + (propertize str 'face 'bold)) + (t str)))) (if block-size (setq size (/ size block-size))) (format "%.0f" size))))