-;;;; directory.el - emulate insert-directory completely in Emacs Lisp
+;;; ls-lisp.el --- emulate insert-directory completely in Emacs Lisp
+
+;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
+;; Keywords: unix
;; Copyright (C) 1992 by Sebastian Kremer <sk@thp.uni-koeln.de>
;; INSTALLATION =======================================================
;;
;; Put this file into your load-path. To use it, load it
-;; with (load "directory").
+;; with (load "ls-lisp").
;; OVERVIEW ===========================================================
;; Recognize some more ls switches: R F
\f
+;;; Code:
+
(defun insert-directory (file &optional switches wildcard full-directory-p)
"Insert directory listing for of FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
Optional fourth arg FULL-DIRECTORY-P means file is a directory and
switches do not contain `d', so that a full listing is expected.
-This version of the function comes from `directory.el'.
+This version of the function comes from `ls-lisp.el'.
It does not support ordinary shell wildcards; instead, it allows
regular expressions to match file names.
The switches that work are: A a c i r S s t u"
- (let (handler (handlers file-name-handler-alist))
- (save-match-data
- (while (and (consp handlers) (null handler))
- (if (and (consp (car handlers))
- (stringp (car (car handlers)))
- (string-match (car (car handlers)) file))
- (setq handler (cdr (car handlers))))
- (setq handlers (cdr handlers))))
+ (let ((handler (find-file-name-handler file)))
(if handler
(funcall handler 'insert-directory file switches
wildcard full-directory-p)
+ ;; Convert SWITCHES to a list of characters.
+ (setq switches (append switches nil))
(if wildcard
(setq wildcard (file-name-nondirectory file) ; actually emacs regexp
;; perhaps convert it from shell to emacs syntax?
;; optional arg.
(format " %3d %-8d %-8d %8d "
(nth 1 file-attr) ; no. of links
- (nth 2 file-attr) ; uid
- (nth 3 file-attr) ; gid
+ (if (= (user-uid) (nth 2 file-attr))
+ (user-login-name)
+ (nth 2 file-attr)) ; uid
+ (if (eq system-type 'ms-dos)
+ "root" ; everything is root on MSDOS.
+ (nth 3 file-attr)) ; gid
(nth 7 file-attr) ; size in bytes
)
(ls-lisp-format-time file-attr switches)
(provide 'ls-lisp)
-; eof
+;;; ls-lisp.el ends here