Mercurial > emacs
comparison lisp/eshell/em-ls.el @ 32446:aab90b31807c
Added better remote directory support to Eshell, as well as a few bug
fixes. See the ChangeLog.
author | John Wiegley <johnw@newartisans.com> |
---|---|
date | Fri, 13 Oct 2000 09:02:39 +0000 |
parents | 3099993cba0f |
children | 8e57189d61b4 |
comparison
equal
deleted
inserted
replaced
32445:05513a882886 | 32446:aab90b31807c |
---|---|
190 | 190 |
191 (defmacro eshell-ls-applicable (attrs index func file) | 191 (defmacro eshell-ls-applicable (attrs index func file) |
192 "Test whether, for ATTRS, the user UID can do what corresponds to INDEX. | 192 "Test whether, for ATTRS, the user UID can do what corresponds to INDEX. |
193 This is really just for efficiency, to avoid having to stat the file | 193 This is really just for efficiency, to avoid having to stat the file |
194 yet again." | 194 yet again." |
195 `(if (= (user-uid) (nth 2 ,attrs)) | 195 `(if (numberp (nth 2 ,attrs)) |
196 (not (eq (aref (nth 8 ,attrs) ,index) ?-)) | 196 (if (= (user-uid) (nth 2 ,attrs)) |
197 (,(eval func) ,file))) | 197 (not (eq (aref (nth 8 ,attrs) ,index) ?-)) |
198 (,(eval func) ,file)) | |
199 (not (eq (aref (nth 8 ,attrs) | |
200 (+ ,index (if (member (nth 2 ,attrs) | |
201 (eshell-current-ange-uids)) | |
202 0 6))) | |
203 ?-)))) | |
198 | 204 |
199 (defcustom eshell-ls-highlight-alist nil | 205 (defcustom eshell-ls-highlight-alist nil |
200 "*This alist correlates test functions to color. | 206 "*This alist correlates test functions to color. |
201 The format of the members of this alist is | 207 The format of the members of this alist is |
202 | 208 |
263 (defvar numeric-uid-gid) | 269 (defvar numeric-uid-gid) |
264 (defvar reverse-list) | 270 (defvar reverse-list) |
265 (defvar show-all) | 271 (defvar show-all) |
266 (defvar show-recursive) | 272 (defvar show-recursive) |
267 (defvar show-size) | 273 (defvar show-size) |
268 (defvar sort-method)) | 274 (defvar sort-method) |
275 (defvar ange-cache)) | |
269 | 276 |
270 (defun eshell-do-ls (&rest args) | 277 (defun eshell-do-ls (&rest args) |
271 "Implementation of \"ls\" in Lisp, passing ARGS." | 278 "Implementation of \"ls\" in Lisp, passing ARGS." |
272 (funcall flush-func -1) | 279 (funcall flush-func -1) |
273 ;; process the command arguments, and begin listing files | 280 ;; process the command arguments, and begin listing files |
326 (setq block-size eshell-ls-default-blocksize)) | 333 (setq block-size eshell-ls-default-blocksize)) |
327 (unless listing-style | 334 (unless listing-style |
328 (setq listing-style 'by-columns)) | 335 (setq listing-style 'by-columns)) |
329 (unless args | 336 (unless args |
330 (setq args (list "."))) | 337 (setq args (list "."))) |
331 (let ((eshell-ls-exclude-regexp eshell-ls-exclude-regexp)) | 338 (let ((eshell-ls-exclude-regexp eshell-ls-exclude-regexp) ange-cache) |
332 (when ignore-pattern | 339 (when ignore-pattern |
333 (unless (eshell-using-module 'eshell-glob) | 340 (unless (eshell-using-module 'eshell-glob) |
334 (error (concat "-I option requires that `eshell-glob'" | 341 (error (concat "-I option requires that `eshell-glob'" |
335 " be a member of `eshell-modules-list'"))) | 342 " be a member of `eshell-modules-list'"))) |
336 (set-text-properties 0 (length ignore-pattern) nil ignore-pattern) | 343 (set-text-properties 0 (length ignore-pattern) nil ignore-pattern) |
345 (lambda (arg) | 352 (lambda (arg) |
346 (cons (if (and (eshell-under-windows-p) | 353 (cons (if (and (eshell-under-windows-p) |
347 (file-name-absolute-p arg)) | 354 (file-name-absolute-p arg)) |
348 (expand-file-name arg) | 355 (expand-file-name arg) |
349 arg) | 356 arg) |
350 (file-attributes arg)))) args) | 357 (eshell-file-attributes arg)))) args) |
351 t (expand-file-name default-directory))) | 358 t (expand-file-name default-directory))) |
352 (funcall flush-func))) | 359 (funcall flush-func))) |
353 | 360 |
354 (defsubst eshell-ls-printable-size (filesize &optional by-blocksize) | 361 (defsubst eshell-ls-printable-size (filesize &optional by-blocksize) |
355 "Return a printable FILESIZE." | 362 "Return a printable FILESIZE." |
377 (unless (file-name-absolute-p (cadr fileinfo)) | 384 (unless (file-name-absolute-p (cadr fileinfo)) |
378 (setq dir (file-truename | 385 (setq dir (file-truename |
379 (file-name-directory | 386 (file-name-directory |
380 (expand-file-name (car fileinfo)))))) | 387 (expand-file-name (car fileinfo)))))) |
381 (setq attr | 388 (setq attr |
382 (file-attributes | 389 (eshell-file-attributes |
383 (let ((target (if dir | 390 (let ((target (if dir |
384 (expand-file-name (cadr fileinfo) dir) | 391 (expand-file-name (cadr fileinfo) dir) |
385 (cadr fileinfo)))) | 392 (cadr fileinfo)))) |
386 (if dereference-links | 393 (if dereference-links |
387 (file-truename target) | 394 (file-truename target) |
423 (concat (eshell-ls-size-string attrs size-width) " ")) | 430 (concat (eshell-ls-size-string attrs size-width) " ")) |
424 (format | 431 (format |
425 "%s%4d %-8s %-8s " | 432 "%s%4d %-8s %-8s " |
426 (or (nth 8 attrs) "??????????") | 433 (or (nth 8 attrs) "??????????") |
427 (or (nth 1 attrs) 0) | 434 (or (nth 1 attrs) 0) |
428 (or (and (not numeric-uid-gid) | 435 (or (let ((user (nth 2 attrs))) |
429 (nth 2 attrs) | 436 (and (not numeric-uid-gid) |
430 (eshell-substring | 437 user |
431 (user-login-name (nth 2 attrs)) 8)) | 438 (eshell-substring |
439 (if (numberp user) | |
440 (user-login-name user) | |
441 user) 8))) | |
432 (nth 2 attrs) | 442 (nth 2 attrs) |
433 "") | 443 "") |
434 (or (and (not numeric-uid-gid) | 444 (or (let ((group (nth 3 attrs))) |
435 (nth 3 attrs) | 445 (and (not numeric-uid-gid) |
436 (eshell-substring | 446 group |
437 (eshell-group-name (nth 3 attrs)) 8)) | 447 (eshell-substring |
448 (if (numberp group) | |
449 (eshell-group-name group) | |
450 group) 8))) | |
438 (nth 3 attrs) | 451 (nth 3 attrs) |
439 "")) | 452 "")) |
440 (let* ((str (eshell-ls-printable-size (nth 7 attrs))) | 453 (let* ((str (eshell-ls-printable-size (nth 7 attrs))) |
441 (len (length str))) | 454 (len (length str))) |
442 (if (< len 8) | 455 (if (< len 8) |