;;; em-ls.el --- implementation of ls in Lisp
-;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
;; Author: John Wiegley <johnw@gnu.org>
;;; Code:
(eval-when-compile
- (require 'cl)
+ (require 'cl-lib)
(require 'eshell))
(require 'esh-util)
(require 'esh-opt)
;;;###autoload
-(eshell-defgroup eshell-ls nil
+(progn
+(defgroup eshell-ls nil
"This module implements the \"ls\" utility fully in Lisp. If it is
passed any unrecognized command switches, it will revert to the
operating system's version. This version of \"ls\" uses text
properties to colorize its output based on the setting of
`eshell-ls-use-colors'."
:tag "Implementation of `ls' in Lisp"
- :group 'eshell-module)
+ :group 'eshell-module))
;;; User Variables:
"How to display time information in `eshell-ls-file'.
This is passed to `format-time-string' as a format string.
To display the date using the current locale, use \"%b \%e\"."
+ :version "24.1"
:type 'string
:group 'eshell-ls)
(let ((insert-func 'eshell-buffered-print)
(error-func 'eshell-error)
(flush-func 'eshell-flush))
- (eshell-do-ls args)))
+ (apply 'eshell-do-ls args)))
(put 'eshell/ls 'eshell-no-numeric-conversions t)
(defvar numeric-uid-gid)
(defvar reverse-list)
(defvar show-all)
+(defvar show-almost-all)
(defvar show-recursive)
(defvar show-size)
(defvar sort-method)
(defun eshell-do-ls (&rest args)
"Implementation of \"ls\" in Lisp, passing ARGS."
(funcall flush-func -1)
- ;; process the command arguments, and begin listing files
+ ;; Process the command arguments, and begin listing files.
(eshell-eval-using-options
"ls" (if eshell-ls-initial-args
(list eshell-ls-initial-args args)
args)
`((?a "all" nil show-all
- "show all files in directory")
+ "do not ignore entries starting with .")
+ (?A "almost-all" nil show-almost-all
+ "do not list implied . and ..")
(?c nil by-ctime sort-method
"sort by last status change time")
(?d "directory" nil dir-literal
(progn
(setcdr fileinfo attr)
(setcar fileinfo (eshell-ls-decorated-name fileinfo)))
- (assert (eq listing-style 'long-listing))
+ (cl-assert (eq listing-style 'long-listing))
(setcar fileinfo
(concat (eshell-ls-decorated-name fileinfo) " -> "
(eshell-ls-decorated-name
;; later when we are going to
;; display user and group names.
(if numeric-uid-gid 'integer 'string))))
- (when (and (not show-all) eshell-ls-exclude-regexp)
+ (when (and show-almost-all
+ (not show-all))
+ (setq entries
+ (remove-if
+ (lambda (entry)
+ (let ((filename (caar entry)))
+ (or (string= filename ".")
+ (string= filename ".."))))
+ entries)))
+ (when (and (not show-all)
+ eshell-ls-exclude-regexp)
(while (and entries (string-match eshell-ls-exclude-regexp
(caar entries)))
(setq entries (cdr entries)))
(let* ((col-vals
(if (eq listing-style 'by-columns)
(eshell-ls-find-column-lengths display-files)
- (assert (eq listing-style 'by-lines))
+ (cl-assert (eq listing-style 'by-lines))
(eshell-ls-find-column-widths display-files)))
(col-widths (car col-vals))
(display-files (cdr col-vals))