emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/ls-lisp.el


From: Juanma Barranquero
Subject: [Emacs-diffs] Changes to emacs/lisp/ls-lisp.el
Date: Thu, 01 May 2003 07:28:44 -0400

Index: emacs/lisp/ls-lisp.el
diff -c emacs/lisp/ls-lisp.el:1.48 emacs/lisp/ls-lisp.el:1.49
*** emacs/lisp/ls-lisp.el:1.48  Mon Jan 20 00:44:47 2003
--- emacs/lisp/ls-lisp.el       Thu May  1 07:16:21 2003
***************
*** 65,70 ****
--- 65,72 ----
  
  ;;; Code:
  
+ (eval-when-compile (require 'cl))
+ 
  (defgroup ls-lisp nil
    "Emulate the ls program completely in Emacs Lisp."
    :version "21.1"
***************
*** 533,539 ****
                        (if group
                            (format " %-8s" group)
                          (format " %-8d" gid))))))
!           (format (if (floatp file-size) " %8.0f" " %8d") file-size)
            " "
            (ls-lisp-format-time file-attr time-index now)
            " "
--- 535,541 ----
                        (if group
                            (format " %-8s" group)
                          (format " %-8d" gid))))))
!           (ls-lisp-format-file-size file-size (memq ?h switches))
            " "
            (ls-lisp-format-time file-attr time-index now)
            " "
***************
*** 586,591 ****
--- 588,602 ----
             (if locale "%Y-%m-%d " (nth 1 ls-lisp-format-time-list)))
           time))
        (error "Unk  0  0000"))))
+ 
+ (defun ls-lisp-format-file-size (file-size human-readable)
+   (if (or (not human-readable)
+           (< file-size 1024))
+       (format (if (floatp file-size) " %8.0f" " %8d") file-size)
+     (do ((file-size (/ file-size 1024.0) (/ file-size 1024.0))
+          ;; kilo, mega, giga, tera, peta, exa
+          (post-fixes (list "k" "M" "G" "T" "P" "E") (cdr post-fixes)))
+         ((< file-size 1024) (format " %7.0f%s"  file-size (car 
post-fixes))))))
  
  (provide 'ls-lisp)
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]