[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7df1adab1e1 6/8: Use file-size-human-readable in eshell
From: |
Stefan Kangas |
Subject: |
master 7df1adab1e1 6/8: Use file-size-human-readable in eshell |
Date: |
Sat, 5 Aug 2023 12:00:12 -0400 (EDT) |
branch: master
commit 7df1adab1e1a9a37920f3fa107794c2d081ebaf4
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>
Use file-size-human-readable in eshell
* lisp/eshell/esh-util.el (eshell-printable-size): Simplify using
file-size-human-readable.
---
lisp/eshell/esh-util.el | 40 +++++++++-------------------------------
1 file changed, 9 insertions(+), 31 deletions(-)
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))))
- master updated (5683c4bad3c -> 8e20da1517a), Stefan Kangas, 2023/08/05
- master 25641c3e882 2/8: Add crossref to set-default-file-modes docstring, Stefan Kangas, 2023/08/05
- master 8e20da1517a 8/8: Simplify rng-substq with cl-substitute, Stefan Kangas, 2023/08/05
- master 3b2b0b5f921 5/8: Fix eshell "ls" command for files larger than 1TiB, Stefan Kangas, 2023/08/05
- master ed395444504 7/8: Make eshell-redisplay into alias for redisplay, Stefan Kangas, 2023/08/05
- master 7df1adab1e1 6/8: Use file-size-human-readable in eshell,
Stefan Kangas <=
- master ee788ab2f81 4/8: ; * lisp/eshell/esh-util.el: Delete redundant autoload., Stefan Kangas, 2023/08/05
- master 3f8db3bbe5e 1/8: image-dired: Fix gallery directory permissions, Stefan Kangas, 2023/08/05
- master 88ce2a5624b 3/8: Simplify pcomplete-uniquify-list, Stefan Kangas, 2023/08/05