Function: ls-lisp-format
ls-lisp-format is a byte-compiled function defined in ls-lisp.el.gz.
Signature
(ls-lisp-format FILE-NAME FILE-ATTR FILE-SIZE SWITCHES TIME-INDEX)
Documentation
Format one line of long ls output for file FILE-NAME.
FILE-ATTR and FILE-SIZE give the file's attributes and size. SWITCHES and TIME-INDEX give the full switch list and time data.
Source Code
;; Defined in /usr/src/emacs/lisp/ls-lisp.el.gz
(defun ls-lisp-format (file-name file-attr file-size switches time-index)
"Format one line of long ls output for file FILE-NAME.
FILE-ATTR and FILE-SIZE give the file's attributes and size.
SWITCHES and TIME-INDEX give the full switch list and time data."
(let ((file-type (file-attribute-type file-attr))
;; t for directory, string (name linked to)
;; for symbolic link, or nil.
(drwxrwxrwx (file-attribute-modes file-attr)))
(concat (if (memq ?i switches) ; inode number
(let ((inode (file-attribute-inode-number file-attr)))
(format " %18d " inode)))
;; nil is treated like "" in concat
(if (memq ?s switches) ; size in K, rounded up
;; In GNU ls, -h affects the size in blocks, displayed
;; by -s, as well.
(if (memq ?h switches)
(format "%7s "
(file-size-human-readable
;; We use 1K as "block size", although
;; most Windows volumes use 4KB to 8KB
;; clusters, and exFAT will usually have
;; clusters of 32KB or even 128KB. See
;; KB article 140365 for the details.
(* 1024.0 (fceiling (/ file-size 1024.0)))))
(format ls-lisp-filesize-b-fmt
(fceiling (/ file-size 1024.0)))))
drwxrwxrwx ; attribute string
(if (memq 'links ls-lisp-verbosity)
(format "%3d" (file-attribute-link-number file-attr)))
;; Numeric uid/gid are more confusing than helpful;
;; Emacs should be able to make strings of them.
;; They tend to be bogus on non-UNIX platforms anyway so
;; optionally hide them.
(if (memq 'uid ls-lisp-verbosity)
;; uid can be a string or an integer
(let ((uid (file-attribute-user-id file-attr)))
(format (if (stringp uid)
ls-lisp-uid-s-fmt
ls-lisp-uid-d-fmt)
uid)))
(if (not (memq ?G switches)) ; GNU ls -- shows group by default
(if (or (memq ?g switches) ; UNIX ls -- no group by default
(memq 'gid ls-lisp-verbosity))
(let ((gid (file-attribute-group-id file-attr)))
(format (if (stringp gid)
ls-lisp-gid-s-fmt
ls-lisp-gid-d-fmt)
gid))))
(ls-lisp-format-file-size file-size (memq ?h switches))
" "
(ls-lisp-format-time file-attr time-index)
" "
(if (not (memq ?F switches)) ; ls-lisp-classify-file already did that
(propertize file-name 'dired-filename t)
file-name)
(if (stringp file-type) ; is a symbolic link
(concat " -> " file-type))
"\n"
)))