65 |
|
|
66 |
;;; Code: |
;;; Code: |
67 |
|
|
|
;;;###autoload |
|
68 |
(defgroup ls-lisp nil |
(defgroup ls-lisp nil |
69 |
"Emulate the ls program completely in Emacs Lisp." |
"Emulate the ls program completely in Emacs Lisp." |
70 |
:version "21.1" |
:version "21.1" |
129 |
(const :tag "Show Group" gid)) |
(const :tag "Show Group" gid)) |
130 |
:group 'ls-lisp) |
:group 'ls-lisp) |
131 |
|
|
132 |
(defcustom ls-lisp-use-insert-directory-program nil |
(defcustom ls-lisp-use-insert-directory-program |
133 |
|
(not (memq system-type '(macos ms-dos windows-nt))) |
134 |
"*Non-nil causes ls-lisp to revert back to using `insert-directory-program'. |
"*Non-nil causes ls-lisp to revert back to using `insert-directory-program'. |
135 |
This is useful on platforms where ls-lisp is dumped into Emacs, such as |
This is useful on platforms where ls-lisp is dumped into Emacs, such as |
136 |
Microsoft Windows, but you would still like to use a program to list |
Microsoft Windows, but you would still like to use a program to list |
138 |
:type 'boolean |
:type 'boolean |
139 |
:group 'ls-lisp) |
:group 'ls-lisp) |
140 |
|
|
141 |
|
;;; Autoloaded because it is let-bound in `recover-session', `mail-recover-1'. |
142 |
|
;;;###autoload |
143 |
(defcustom ls-lisp-support-shell-wildcards t |
(defcustom ls-lisp-support-shell-wildcards t |
144 |
"*Non-nil means ls-lisp treats file patterns as shell wildcards. |
"*Non-nil means ls-lisp treats file patterns as shell wildcards. |
145 |
Otherwise they are treated as Emacs regexps (for backward compatibility)." |
Otherwise they are treated as Emacs regexps (for backward compatibility)." |
146 |
:type 'boolean |
:type 'boolean |
147 |
:group 'ls-lisp) |
:group 'ls-lisp) |
148 |
|
|
149 |
|
(defcustom ls-lisp-format-time-list |
150 |
|
'("%b %e %H:%M" |
151 |
|
"%b %e %Y") |
152 |
|
"*List of `format-time-string' specs to display file time stamps. |
153 |
|
They are used whenever a locale is not specified to use instead. |
154 |
|
|
155 |
|
Syntax: (EARLY-TIME-FORMAT OLD-TIME-FORMAT) |
156 |
|
|
157 |
|
The EARLY-TIME-FORMAT is used if file has been modified within the |
158 |
|
current year. The OLD-TIME-FORMAT is used for older files. To use ISO |
159 |
|
8601 dates, you could set: |
160 |
|
|
161 |
|
\(setq ls-lisp-format-time-list |
162 |
|
'(\"%Y-%m-%d %H:%M\" |
163 |
|
\"%Y-%m-%d \"))" |
164 |
|
:type '(list (string :tag "Early time format") |
165 |
|
(string :tag "Old time format")) |
166 |
|
:group 'ls-lisp) |
167 |
|
|
168 |
|
(defvar original-insert-directory nil |
169 |
|
"This holds the original function definition of `insert-directory'.") |
170 |
|
|
171 |
;; Remember the original insert-directory function |
;; Remember the original insert-directory function |
172 |
(or (featurep 'ls-lisp) ; FJW: unless this file is being reloaded! |
(or (featurep 'ls-lisp) ; FJW: unless this file is being reloaded! |
173 |
(fset 'original-insert-directory (symbol-function 'insert-directory))) |
(setq original-insert-directory (symbol-function 'insert-directory))) |
174 |
|
|
175 |
;; This stub is to allow ls-lisp to parse symbolic links via another |
;; This stub is to allow ls-lisp to parse symbolic links via another |
176 |
;; library such as w32-symlinks.el from |
;; library such as w32-symlinks.el from |
177 |
;; http://centaur.qmw.ac.uk/Emacs/: |
;; http://centaur.maths.qmw.ac.uk/Emacs/: |
178 |
(defun ls-lisp-parse-symlink (file-name) |
(defun ls-lisp-parse-symlink (file-name) |
179 |
"This stub may be redefined to parse FILE-NAME as a symlink. |
"This stub may be redefined to parse FILE-NAME as a symlink. |
180 |
It should return nil or the link target as a string." |
It should return nil or the link target as a string." |
206 |
to match file names. It does not support all `ls' switches -- those |
to match file names. It does not support all `ls' switches -- those |
207 |
that work are: A a c i r S s t u U X g G B C R and F partly." |
that work are: A a c i r S s t u U X g G B C R and F partly." |
208 |
(if ls-lisp-use-insert-directory-program |
(if ls-lisp-use-insert-directory-program |
209 |
(original-insert-directory file switches wildcard full-directory-p) |
(funcall original-insert-directory |
210 |
|
file switches wildcard full-directory-p) |
211 |
;; We need the directory in order to find the right handler. |
;; We need the directory in order to find the right handler. |
212 |
(let ((handler (find-file-name-handler (expand-file-name file) |
(let ((handler (find-file-name-handler (expand-file-name file) |
213 |
'insert-directory))) |
'insert-directory))) |
582 |
(setq locale nil)) |
(setq locale nil)) |
583 |
(format-time-string |
(format-time-string |
584 |
(if (and (<= past-cutoff diff) (<= diff 0)) |
(if (and (<= past-cutoff diff) (<= diff 0)) |
585 |
(if locale "%m-%d %H:%M" "%b %e %H:%M") |
(if locale "%m-%d %H:%M" (nth 0 ls-lisp-format-time-list)) |
586 |
(if locale "%Y-%m-%d " "%b %e %Y")) |
(if locale "%Y-%m-%d " (nth 1 ls-lisp-format-time-list))) |
587 |
time)) |
time)) |
588 |
(error "Unk 0 0000")))) |
(error "Unk 0 0000")))) |
589 |
|
|