mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-12 00:50:43 -08:00
Simplify igc--format-bytes-human-readable
Suggested by Pip Cet. * lisp/emacs-lisp/igc.el (igc--format-bytes-human-readable): Use file-size-human-readable.
This commit is contained in:
parent
6312088fd3
commit
cb287ece7b
1 changed files with 2 additions and 20 deletions
|
|
@ -152,27 +152,9 @@ IGC statistics:
|
|||
|
||||
(defun igc--format-bytes-human-readable (n)
|
||||
(let* ((negative (< n 0))
|
||||
(n (abs n))
|
||||
(units (eval-when-compile
|
||||
(cl-map 'vector
|
||||
(lambda (p) (cons (ash 1 (car p)) (cdr p)))
|
||||
'((10 . "K")
|
||||
(20 . "M")
|
||||
(30 . "G")
|
||||
(40 . "T")
|
||||
(50 . "P")
|
||||
(60 . "E")))))
|
||||
(pos (cl-position-if (lambda (p) (< n (car p))) units))
|
||||
(p (cl-case pos
|
||||
((nil 0) '(1 . ""))
|
||||
(t (aref units (1- pos)))))
|
||||
(base (car p))
|
||||
(name (cdr p))
|
||||
(rem (mod n base)))
|
||||
(n (abs n)))
|
||||
(concat (if negative "-" "")
|
||||
(cond ((= rem 0) (number-to-string (/ n base)))
|
||||
(t (format "%.1f" (/ (float n) base))))
|
||||
name)))
|
||||
(file-size-human-readable n))))
|
||||
|
||||
(defun igc--format-bytes (n)
|
||||
(cl-ecase igc--number-format
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue