comparison lisp/ls-lisp.el @ 25194:daf6b641fb0e

(ls-lisp-delete-matching): List argument is now alist of filenames and attributes. (ls-lisp-insert-directory): Use directory-files-and-attributes for speed.
author Geoff Voelker <voelker@cs.washington.edu>
date Fri, 06 Aug 1999 20:41:07 +0000
parents 2f2786f7d960
children 09c7b74fa57f
comparison
equal deleted inserted replaced
25193:953155ee541a 25194:daf6b641fb0e
132 (let* ((dir (file-name-as-directory file)) 132 (let* ((dir (file-name-as-directory file))
133 (default-directory dir);; so that file-attributes works 133 (default-directory dir);; so that file-attributes works
134 (sum 0) 134 (sum 0)
135 elt 135 elt
136 short 136 short
137 (file-list (directory-files dir nil wildcard)) 137 (file-alist (directory-files-and-attributes dir nil wildcard))
138 file-alist
139 (now (current-time)) 138 (now (current-time))
140 ;; do all bindings here for speed 139 ;; do all bindings here for speed
141 file-size 140 file-size
142 fil attr) 141 fil attr)
143 (cond ((memq ?A switches) 142 (cond ((memq ?A switches)
144 (setq file-list 143 (setq file-alist
145 (ls-lisp-delete-matching "^\\.\\.?$" file-list))) 144 (ls-lisp-delete-matching "^\\.\\.?$" file-alist)))
146 ((not (memq ?a switches)) 145 ((not (memq ?a switches))
147 ;; if neither -A nor -a, flush . files 146 ;; if neither -A nor -a, flush . files
148 (setq file-list 147 (setq file-alist
149 (ls-lisp-delete-matching "^\\." file-list)))) 148 (ls-lisp-delete-matching "^\\." file-alist))))
150 (setq file-alist
151 (mapcar
152 (function
153 (lambda (x)
154 ;; file-attributes("~bogus") bombs
155 (cons x (file-attributes (expand-file-name x)))))
156 ;; inserting the call to directory-files right here
157 ;; seems to stimulate an Emacs bug
158 ;; ILLEGAL DATATYPE (#o37777777727) or #o67
159 file-list))
160 ;; ``Total'' line (filled in afterwards). 149 ;; ``Total'' line (filled in afterwards).
161 (insert (if (car-safe file-alist) 150 (insert (if (car-safe file-alist)
162 "total \007\n" 151 "total \007\n"
163 ;; Shell says ``No match'' if no files match 152 ;; Shell says ``No match'' if no files match
164 ;; the wildcard; let's say something similar. 153 ;; the wildcard; let's say something similar.
199 (defun ls-lisp-delete-matching (regexp list) 188 (defun ls-lisp-delete-matching (regexp list)
200 ;; Delete all elements matching REGEXP from LIST, return new list. 189 ;; Delete all elements matching REGEXP from LIST, return new list.
201 ;; Should perhaps use setcdr for efficiency. 190 ;; Should perhaps use setcdr for efficiency.
202 (let (result) 191 (let (result)
203 (while list 192 (while list
204 (or (string-match regexp (car list)) 193 (or (string-match regexp (car (car list)))
205 (setq result (cons (car list) result))) 194 (setq result (cons (car list) result)))
206 (setq list (cdr list))) 195 (setq list (cdr list)))
207 result)) 196 result))
208 197
209 (defun ls-lisp-handle-switches (file-alist switches) 198 (defun ls-lisp-handle-switches (file-alist switches)