Function: eshell-ls-file

eshell-ls-file is a byte-compiled function defined in em-ls.el.gz.

Signature

(eshell-ls-file FILEINFO &optional SIZE-WIDTH COPY-FILEINFO)

Documentation

Output FILEINFO in long format.

FILEINFO may be a string, or a cons cell whose car is the filename and whose cdr is the list of file attributes.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-ls.el.gz
(defun eshell-ls-file (fileinfo &optional size-width copy-fileinfo)
  "Output FILEINFO in long format.
FILEINFO may be a string, or a cons cell whose car is the
filename and whose cdr is the list of file attributes."
  (if (not (cdr fileinfo))
      (funcall error-func (format "%s: No such file or directory\n"
				  (car fileinfo)))
    (setq fileinfo
	  (eshell-ls-annotate (if copy-fileinfo
				  (cons (car fileinfo)
					(cdr fileinfo))
				fileinfo)))
    (let ((file (car fileinfo))
	  (attrs (cdr fileinfo)))
      (if (not (eq listing-style 'long-listing))
	  (if show-size
	      (funcall insert-func (eshell-ls-size-string attrs size-width)
		       " " file "\n")
	    (funcall insert-func file "\n"))
	(let ((line
	       (concat
		(if show-size
		    (concat (eshell-ls-size-string attrs size-width) " "))
		(format
		 (if numeric-uid-gid
		     "%s%4d %-8s %-8s "
		   "%s%4d %-14s %-8s ")
		 (or (file-attribute-modes attrs) "??????????")
		 (or (file-attribute-link-number attrs) 0)
		 (or (let ((user (file-attribute-user-id attrs)))
		       (and (stringp user)
			    (eshell-substring user 14)))
		     (file-attribute-user-id attrs)
		     "")
		 (or (let ((group (file-attribute-group-id attrs)))
		       (and (stringp group)
			    (eshell-substring group 8)))
		     (file-attribute-group-id attrs)
		     ""))
		(let* ((str (eshell-ls-printable-size (file-attribute-size attrs)))
		       (len (length str)))
		  ;; Let file sizes shorter than 9 align neatly.
		  (if (< len (or size-width 8))
		      (concat (make-string (- (or size-width 8) len) ? ) str)
		    str))
		" " (format-time-string
		     (concat
		      eshell-ls-date-format " "
		      (if (= (decoded-time-year (decode-time))
			     (decoded-time-year
                              (decode-time
			       (nth (cond
				     ((eq sort-method 'by-atime) 4)
				     ((eq sort-method 'by-ctime) 6)
				     (t 5))
                                    attrs))))
			  "%H:%M"
			" %Y")) (nth (cond
			((eq sort-method 'by-atime) 4)
			((eq sort-method 'by-ctime) 6)
			(t 5)) attrs)) " ")))
	  (funcall insert-func line file "\n"))))))