unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch: Enable -h switch in ls-lisp.el
@ 2003-04-28 22:08 Eduardo Muñoz
  0 siblings, 0 replies; only message in thread
From: Eduardo Muñoz @ 2003-04-28 22:08 UTC (permalink / raw)



I patched ls-lisp.el as follows. Maybe it will be usefull.


$ diff -c  ls-lisp.1.42.4.1.el ls-lisp.new.el
*** ls-lisp.1.42.4.1.el	Mon Apr 28 23:51:13 2003
--- ls-lisp.new.el	Mon Apr 28 23:53:37 2003
***************
*** 497,503 ****
  			(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)
  	    " "
--- 497,503 ----
  			(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)
  	    " "
***************
*** 537,542 ****
--- 537,551 ----
  	 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)
  
  ;;; ls-lisp.el ends here


-- 
Eduardo Muñoz          | (prog () 10 (print "Hello world!")
http://213.97.131.125/ |          20 (go 10))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-04-28 22:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-28 22:08 Patch: Enable -h switch in ls-lisp.el Eduardo Muñoz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).