aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ls-lisp.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 1d0ace7613e..54c76a9d725 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -65,6 +65,8 @@
65 65
66;;; Code: 66;;; Code:
67 67
68(eval-when-compile (require 'cl))
69
68(defgroup ls-lisp nil 70(defgroup ls-lisp nil
69 "Emulate the ls program completely in Emacs Lisp." 71 "Emulate the ls program completely in Emacs Lisp."
70 :version "21.1" 72 :version "21.1"
@@ -533,7 +535,7 @@ SWITCHES, TIME-INDEX and NOW give the full switch list and time data."
533 (if group 535 (if group
534 (format " %-8s" group) 536 (format " %-8s" group)
535 (format " %-8d" gid)))))) 537 (format " %-8d" gid))))))
536 (format (if (floatp file-size) " %8.0f" " %8d") file-size) 538 (ls-lisp-format-file-size file-size (memq ?h switches))
537 " " 539 " "
538 (ls-lisp-format-time file-attr time-index now) 540 (ls-lisp-format-time file-attr time-index now)
539 " " 541 " "
@@ -587,6 +589,15 @@ All ls time options, namely c, t and u, are handled."
587 time)) 589 time))
588 (error "Unk 0 0000")))) 590 (error "Unk 0 0000"))))
589 591
592(defun ls-lisp-format-file-size (file-size human-readable)
593 (if (or (not human-readable)
594 (< file-size 1024))
595 (format (if (floatp file-size) " %8.0f" " %8d") file-size)
596 (do ((file-size (/ file-size 1024.0) (/ file-size 1024.0))
597 ;; kilo, mega, giga, tera, peta, exa
598 (post-fixes (list "k" "M" "G" "T" "P" "E") (cdr post-fixes)))
599 ((< file-size 1024) (format " %7.0f%s" file-size (car post-fixes))))))
600
590(provide 'ls-lisp) 601(provide 'ls-lisp)
591 602
592;;; ls-lisp.el ends here 603;;; ls-lisp.el ends here