(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))))