+ ;; Find the appropriate format for displaying uid, gid, and
+ ;; file size, by finding the longest strings among all the
+ ;; files we are about to display.
+ (dolist (elt file-alist)
+ (setq attr (cdr elt)
+ fuid (nth 2 attr)
+ uid-len (if (stringp fuid) (string-width fuid)
+ (length (format "%d" fuid)))
+ fgid (nth 3 attr)
+ gid-len (if (stringp fgid) (string-width fgid)
+ (length (format "%d" fgid)))
+ file-size (nth 7 attr))
+ (if (> uid-len max-uid-len)
+ (setq max-uid-len uid-len))
+ (if (> gid-len max-gid-len)
+ (setq max-gid-len gid-len))
+ (if (> file-size max-file-size)
+ (setq max-file-size file-size)))
+ (setq ls-lisp-uid-d-fmt (format " %%-%dd" max-uid-len))
+ (setq ls-lisp-uid-s-fmt (format " %%-%ds" max-uid-len))
+ (setq ls-lisp-gid-d-fmt (format " %%-%dd" max-gid-len))
+ (setq ls-lisp-gid-s-fmt (format " %%-%ds" max-gid-len))
+ (setq ls-lisp-filesize-d-fmt
+ (format " %%%dd"
+ (if (memq ?s switches)
+ (length (format "%.0f"
+ (fceiling (/ max-file-size 1024.0))))
+ (length (format "%.0f" max-file-size)))))
+ (setq ls-lisp-filesize-f-fmt
+ (format " %%%d.0f"
+ (if (memq ?s switches)
+ (length (format "%.0f"
+ (fceiling (/ max-file-size 1024.0))))
+ (length (format "%.0f" max-file-size)))))