;;; ls-lisp.el --- emulate insert-directory completely in Emacs Lisp
-;; Copyright (C) 1992, 1994 by Sebastian Kremer <sk@thp.uni-koeln.de>
+;; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
;; Maintainer: FSF
This variable is checked by \\[insert-directory] only when `ls-lisp.el'
package is used.")
-(defun insert-directory (file &optional switches wildcard full-directory-p)
+(defvar ls-lisp-dired-ignore-case nil
+ "Non-nil causes dired buffers to sort alphabetically regardless of case.")
+
+(defvar ls-lisp-use-insert-directory-program nil
+ "Non-nil causes ls-lisp to revert back to using `insert-directory-program'.
+This is useful on platforms where ls-lisp is dumped into Emacs, such as
+Microsoft Windows, but you would still like to use a program to list
+the contents of a directory.")
+
+;; Remember the original insert-directory function.
+(fset 'original-insert-directory (symbol-function 'insert-directory))
+
+(defun insert-directory (file switches &optional wildcard full-directory-p)
+ "Insert directory listing for FILE, formatted according to SWITCHES.
+Leaves point after the inserted text.
+SWITCHES may be a string of options, or a list of strings.
+Optional third arg WILDCARD means treat FILE as shell wildcard.
+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 `ls-lisp.el'. Depending upon
+the value of `ls-lisp-use-insert-directory-program', it will use an
+external program if non-nil or the lisp function `ls-lisp-insert-directory'
+otherwise."
+ (if ls-lisp-use-insert-directory-program
+ (original-insert-directory file switches wildcard full-directory-p)
+ (ls-lisp-insert-directory file switches wildcard full-directory-p)))
+
+(defun ls-lisp-insert-directory (file switches &optional wildcard full-directory-p)
"Insert directory listing for FILE, formatted according to SWITCHES.
Leaves point after the inserted text.
Optional third arg WILDCARD means treat FILE as shell wildcard.
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 `ls-lisp.el'. It doesn not
+This version of the function comes from `ls-lisp.el'. It does not
run any external programs or shells. It supports ordinary shell
wildcards if `ls-lisp-support-shell-wildcards' variable is non-nil;
otherwise, it interprets wildcards as regular expressions to match
(ls-lisp-time-lessp (nth index (cdr y))
(nth index (cdr x))))))
(t ; sorted alphabetically
- (function
- (lambda (x y)
- (string-lessp (car x)
- (car y)))))))))
+ (if ls-lisp-dired-ignore-case
+ (function
+ (lambda (x y)
+ (string-lessp (upcase (car x))
+ (upcase (car y)))))
+ (function
+ (lambda (x y)
+ (string-lessp (car x)
+ (car y))))))))))
(if (memq ?r switches) ; reverse sort order
(setq file-alist (nreverse file-alist)))
file-alist)